From aa662eec9c854957c74da591cb76def2fc9255a4 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Sat, 9 Jul 2016 16:10:45 +0200 Subject: [PATCH] libusb: allows to specify USB dongle with hci_transport_usb_set_path --- port/libusb/hci_transport_h2_libusb.c | 131 +++++++++++++++++--------- src/hci_transport.h | 4 + 2 files changed, 90 insertions(+), 45 deletions(-) diff --git a/port/libusb/hci_transport_h2_libusb.c b/port/libusb/hci_transport_h2_libusb.c index ed378dae0..ab0f8243c 100644 --- a/port/libusb/hci_transport_h2_libusb.c +++ b/port/libusb/hci_transport_h2_libusb.c @@ -101,6 +101,9 @@ #define SCO_RING_BUFFER_COUNT (8) #define SCO_RING_BUFFER_SIZE (SCO_RING_BUFFER_COUNT * SCO_PACKET_SIZE) +// seems to be the max depth for USB 3 +#define USB_MAX_PATH_LEN 7 + // prototypes static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size); static int usb_close(void); @@ -185,6 +188,10 @@ static int acl_out_addr; static int sco_in_addr; static int sco_out_addr; +// device path +static int usb_path_len; +static uint8_t usb_path[USB_MAX_PATH_LEN]; + #ifdef ENABLE_SCO_OVER_HCI static void sco_ring_init(void){ @@ -196,6 +203,14 @@ static int sco_ring_have_space(void){ } #endif +void hci_transport_usb_set_path(int len, uint8_t * port_numbers){ + if (len > USB_MAX_PATH_LEN || !port_numbers){ + log_error("hci_transport_usb_set_path: len or port numbers invalid"); + return; + } + usb_path_len = len; + memcpy(usb_path, port_numbers, len); +} // static void queue_transfer(struct libusb_transfer *transfer){ @@ -570,14 +585,12 @@ static int scan_for_bt_device(libusb_device **devs, int start_index) { } #endif -// seems to be the max depth for USB 3 -#define MAX_PATH_DEPTH 7 static int prepare_device(libusb_device_handle * aHandle){ // print device path - uint8_t port_numbers[MAX_PATH_DEPTH]; + uint8_t port_numbers[USB_MAX_PATH_LEN]; libusb_device * device = libusb_get_device(aHandle); - int path_len = libusb_get_port_numbers(device, port_numbers, MAX_PATH_DEPTH); + int path_len = libusb_get_port_numbers(device, port_numbers, USB_MAX_PATH_LEN); printf("USB Path: "); int i; for (i=0;i