commit fae2d8a4e5b5560b87cc38d5422f183cc02e178a from: Thomas Böhler date: Tue Dec 6 13:45:28 2022 UTC Initial commit commit - /dev/null commit + fae2d8a4e5b5560b87cc38d5422f183cc02e178a blob - /dev/null blob + 714d9c369a57e73a424a3accdc0414dbf2335e47 (mode 644) --- /dev/null +++ CMakeLists.txt @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(hci_usb) + +target_sources(app PRIVATE src/main.c) blob - /dev/null blob + f3aab7d0f87e71ac231b413c4f2b7a9fe887453e (mode 644) --- /dev/null +++ Kconfig @@ -0,0 +1,7 @@ +# Copyright (c) 2019 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config USB_DEVICE_PID + default USB_PID_BLE_HCI_SAMPLE + +source "Kconfig.zephyr" blob - /dev/null blob + 91e4fb7f4fcd9dbf295e2cfb9661435c80c39a0f (mode 644) --- /dev/null +++ README.rst @@ -0,0 +1,23 @@ +.. _bluetooth-hci-usb-sample: + +Bluetooth: HCI USB +################## + +Overview +******** + +Make a USB Bluetooth dongle out of Zephyr. Requires USB device support from the +board it runs on (e.g. :ref:`nrf52840dk_nrf52840` supports both BLE and USB). + +Requirements +************ + +* Bluetooth stack running on the host (e.g. BlueZ) +* A board with Bluetooth and USB support in Zephyr + +Building and Running +******************** +This sample can be found under :zephyr_file:`samples/bluetooth/hci_usb` in the +Zephyr tree. + +See :ref:`bluetooth samples section ` for details. blob - /dev/null blob + d11758f5a49c463c38b3f4564afad824878468e0 (mode 644) --- /dev/null +++ prj.conf @@ -0,0 +1,29 @@ +CONFIG_STDOUT_CONSOLE=n # disable output to console - we don't see it anyway +CONFIG_GPIO=y +CONFIG_SERIAL=y +CONFIG_UART_INTERRUPT_DRIVEN=y + +CONFIG_BT=y +CONFIG_BT_HCI_RAW=y + +CONFIG_USB_DEVICE_STACK=y +CONFIG_USB_DEVICE_BLUETOOTH=y +CONFIG_USB_DEVICE_BLUETOOTH_VS_H4=n + +# Workaround: Unable to allocate command buffer when using K_NO_WAIT since +# Host number of completed commands does not follow normal flow control. +CONFIG_BT_BUF_CMD_TX_COUNT=10 + +# enable DLE with size of 251 +CONFIG_BT_CTLR=y +# https://lists.zephyrproject.org/g/users/topic/data_length_extension_on/23297993 +CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 +CONFIG_BT_HCI=y +# needs to be set to 251 order to allow CONFIG_BT_CTLR_DATA_LENGTH_MAX to also be set to 251 +CONFIG_BT_BUF_ACL_RX_SIZE=251 +CONFIG_BT_BUF_ACL_TX_SIZE=251 + +# enable 2M PHY and auto update +CONFIG_BT_PHY_UPDATE=y +CONFIG_BT_AUTO_PHY_UPDATE=y +CONFIG_BT_CTLR_PHY_2M=y blob - /dev/null blob + b949f592f39f9455a2d5962697c5510455e60618 (mode 644) --- /dev/null +++ sample.yaml @@ -0,0 +1,9 @@ +sample: + name: Bluetooth over USB sample +tests: + sample.bluetooth.hci_usb: + harness: bluetooth + depends_on: usb_device ble + tags: usb bluetooth + # FIXME: exclude due to build error + platform_exclude: 96b_carbon blob - /dev/null blob + 773dd9eac3d910f8c24c7e8cf1fd078a84dc97db (mode 644) --- /dev/null +++ src/main.c @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2018 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include + +void main(void) +{ + int ret; + + ret = usb_enable(NULL); + if (ret != 0) { + printk("Failed to enable USB"); + return; + } + + printk("Bluetooth over USB sample\n"); +}