File tree Expand file tree Collapse file tree 10 files changed +90
-54
lines changed
subsys/usb/legacy/hci_usb Expand file tree Collapse file tree 10 files changed +90
-54
lines changed Original file line number Diff line number Diff line change 1
1
.. zephyr :code-sample :: bluetooth_hci_usb
2
2
:name: HCI USB
3
- :relevant-api: hci_raw bluetooth _usb_device_core_api usbd_api
3
+ :relevant-api: hci_raw bluetooth usbd_api
4
4
5
5
Turn a Zephyr board into a USB Bluetooth dongle (compatible with all operating systems).
6
6
Original file line number Diff line number Diff line change 1
1
CONFIG_BT=y
2
2
CONFIG_BT_HCI_RAW=y
3
-
4
- CONFIG_USB_DEVICE_STACK=y
5
- CONFIG_USB_DEVICE_PID=0x000B
6
- CONFIG_USB_DEVICE_BLUETOOTH=y
7
- CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
8
-
9
- # We dont want any console or CDC ACM that may cause BlueZ to not detect hci_usb
10
3
CONFIG_SERIAL=n
11
4
CONFIG_CONSOLE=n
12
5
CONFIG_UART_CONSOLE=n
6
+
7
+ CONFIG_USB_DEVICE_STACK_NEXT=y
8
+ CONFIG_SAMPLE_USBD_PID=0x000B
9
+ CONFIG_SAMPLE_USBD_PRODUCT="Zephyr USBD BT HCI"
10
+ CONFIG_USBD_BT_HCI=y
Original file line number Diff line number Diff line change 4
4
sample.bluetooth.hci_usb :
5
5
harness : bluetooth
6
6
depends_on :
7
- - usb_device
7
+ - usbd
8
8
- ble
9
9
tags :
10
10
- usb
11
11
- bluetooth
12
- sample.bluetooth.hci_usb.device_next :
13
- harness : bluetooth
14
- depends_on :
15
- - usb_device
16
- - ble
17
- tags :
18
- - usb
19
- - bluetooth
20
- extra_args : CONF_FILE="usbd_next_prj.conf"
21
- platform_allow : nrf52840dk/nrf52840
Original file line number Diff line number Diff line change 6
6
7
7
#include <zephyr/kernel.h>
8
8
#include <zephyr/sys/printk.h>
9
- #include <zephyr/usb/usb_device.h>
10
9
#include <zephyr/usb/usbd.h>
11
10
12
- #if defined(CONFIG_USB_DEVICE_STACK_NEXT )
13
11
#include <sample_usbd.h>
14
12
15
- static int enable_usb_device_next (void )
13
+ int main (void )
16
14
{
17
- struct usbd_context * sample_usbd = sample_usbd_init_device (NULL );
15
+ struct usbd_context * sample_usbd ;
16
+ int ret ;
18
17
18
+ sample_usbd = sample_usbd_init_device (NULL );
19
19
if (sample_usbd == NULL ) {
20
20
printk ("Failed to initialize USB device" );
21
21
return - ENODEV ;
22
22
}
23
23
24
- return usbd_enable (sample_usbd );
25
- }
26
- #endif /* CONFIG_USB_DEVICE_STACK_NEXT */
27
-
28
- int main (void )
29
- {
30
- int ret ;
31
-
32
- #if defined(CONFIG_USB_DEVICE_STACK_NEXT )
33
- ret = enable_usb_device_next ();
34
- #else
35
- ret = usb_enable (NULL );
36
- #endif
37
-
24
+ ret = usbd_enable (sample_usbd );
38
25
if (ret != 0 ) {
39
26
printk ("Failed to enable USB" );
40
27
return 0 ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ # SPDX-License-Identifier: Apache-2.0
2
+
3
+ cmake_minimum_required (VERSION 3.20.0 )
4
+ find_package (Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} )
5
+ project (hci_usb )
6
+
7
+ target_sources (app PRIVATE src/main.c )
Original file line number Diff line number Diff line change
1
+ .. zephyr :code-sample :: legacy_bluetooth_hci_usb
2
+ :name: Legacy HCI USB
3
+ :relevant-api: hci_raw bluetooth _usb_device_core_api
4
+
5
+ Turn a Zephyr board into a USB Bluetooth dongle (compatible with all operating systems).
6
+
7
+ Overview
8
+ ********
9
+
10
+ Make a USB Bluetooth dongle out of Zephyr.
11
+
12
+ Requirements
13
+ ************
14
+
15
+ * Bluetooth stack running on the host (e.g. BlueZ)
16
+ * A board with Bluetooth and USB support in Zephyr
17
+
18
+ Building and Running
19
+ ********************
20
+ This sample can be found under :zephyr_file: `samples/subsys/usb/legacy/hci_usb ` in the
21
+ Zephyr tree.
Original file line number Diff line number Diff line change
1
+ CONFIG_BT=y
2
+ CONFIG_BT_HCI_RAW=y
3
+
4
+ CONFIG_USB_DEVICE_STACK=y
5
+ CONFIG_USB_DEVICE_PID=0x000B
6
+ CONFIG_USB_DEVICE_BLUETOOTH=y
7
+ CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
8
+
9
+ # We dont want any console or CDC ACM that may cause BlueZ to not detect hci_usb
10
+ CONFIG_SERIAL=n
11
+ CONFIG_CONSOLE=n
12
+ CONFIG_UART_CONSOLE=n
13
+
14
+ # Workaround: Unable to allocate command buffer when using K_NO_WAIT since
15
+ # Host number of completed commands does not follow normal flow control.
16
+ CONFIG_BT_BUF_CMD_TX_COUNT=10
Original file line number Diff line number Diff line change
1
+ sample :
2
+ name : Bluetooth over USB sample
3
+ tests :
4
+ sample.bluetooth.hci_usb.legacy :
5
+ depends_on :
6
+ - usb_device
7
+ - ble
8
+ build_only : true
9
+ tags :
10
+ - usb
11
+ - bluetooth
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2018 Intel Corporation
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ #include <zephyr/kernel.h>
8
+ #include <zephyr/sys/printk.h>
9
+ #include <zephyr/usb/usb_device.h>
10
+
11
+ int main (void )
12
+ {
13
+ int ret ;
14
+
15
+ ret = usb_enable (NULL );
16
+ if (ret != 0 ) {
17
+ printk ("Failed to enable USB" );
18
+ return 0 ;
19
+ }
20
+
21
+ printk ("Bluetooth over USB sample\n" );
22
+ return 0 ;
23
+ }
You can’t perform that action at this time.
0 commit comments