mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-25 18:35:17 +00:00
libusb: pass libusb_device to scan_for_bt_endpoints
This commit is contained in:
parent
3d45f2d56b
commit
696b00c829
@ -157,7 +157,6 @@ static void (*packet_handler)(uint8_t packet_type, uint8_t *packet, uint16_t siz
|
||||
// libusb
|
||||
#ifndef HAVE_USB_VENDOR_ID_AND_PRODUCT_ID
|
||||
static struct libusb_device_descriptor desc;
|
||||
static libusb_device * dev;
|
||||
#endif
|
||||
static libusb_device_handle * handle;
|
||||
|
||||
@ -600,7 +599,7 @@ static int is_known_bt_device(uint16_t vendor_id, uint16_t product_id){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void scan_for_bt_endpoints(void) {
|
||||
static int scan_for_bt_endpoints(libusb_device *dev) {
|
||||
int r;
|
||||
|
||||
event_in_addr = 0;
|
||||
@ -612,6 +611,7 @@ static void scan_for_bt_endpoints(void) {
|
||||
// get endpoints from interface descriptor
|
||||
struct libusb_config_descriptor *config_descriptor;
|
||||
r = libusb_get_active_config_descriptor(dev, &config_descriptor);
|
||||
if (r < 0) return r;
|
||||
|
||||
int num_interfaces = config_descriptor->bNumInterfaces;
|
||||
log_info("active configuration has %u interfaces", num_interfaces);
|
||||
@ -661,13 +661,14 @@ static void scan_for_bt_endpoints(void) {
|
||||
}
|
||||
}
|
||||
libusb_free_config_descriptor(config_descriptor);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// returns index of found device or -1
|
||||
static int scan_for_bt_device(libusb_device **devs, int start_index) {
|
||||
int i;
|
||||
for (i = start_index; devs[i] ; i++){
|
||||
dev = devs[i];
|
||||
libusb_device * dev = devs[i];
|
||||
int r = libusb_get_device_descriptor(dev, &desc);
|
||||
if (r < 0) {
|
||||
log_error("failed to get device descriptor");
|
||||
@ -944,6 +945,8 @@ static int usb_open(void){
|
||||
// configure debug level
|
||||
libusb_set_debug(NULL, LIBUSB_LOG_LEVEL_WARNING);
|
||||
|
||||
libusb_device * dev = NULL;
|
||||
|
||||
#ifdef HAVE_USB_VENDOR_ID_AND_PRODUCT_ID
|
||||
|
||||
// Use a specified device
|
||||
@ -963,6 +966,9 @@ static int usb_open(void){
|
||||
return -1;
|
||||
}
|
||||
|
||||
dev = libusb_get_device(aHandle);
|
||||
scan_for_bt_endpoints(dev);
|
||||
|
||||
#else
|
||||
// Scan system for an appropriate devices
|
||||
libusb_device **devs;
|
||||
@ -975,8 +981,6 @@ static int usb_open(void){
|
||||
return -1;
|
||||
}
|
||||
|
||||
dev = NULL;
|
||||
|
||||
if (usb_path_len){
|
||||
int i;
|
||||
for (i=0;i<num_devices;i++){
|
||||
@ -1030,7 +1034,7 @@ static int usb_open(void){
|
||||
return -1;
|
||||
}
|
||||
|
||||
scan_for_bt_endpoints();
|
||||
scan_for_bt_endpoints(dev);
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user