libusb: print usb info in ports

This commit is contained in:
Matthias Ringwald 2022-04-13 15:01:42 +02:00
parent f85342b49f
commit 24a31dc762
2 changed files with 36 additions and 0 deletions

View File

@ -91,8 +91,26 @@ static btstack_packet_callback_registration_t hci_event_callback_registration;
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
UNUSED(channel);
UNUSED(size);
uint8_t i;
uint8_t usb_path_len;
const uint8_t * usb_path;
if (packet_type != HCI_EVENT_PACKET) return;
switch (hci_event_packet_get_type(packet)){
case HCI_EVENT_TRANSPORT_USB_INFO:
usb_path_len = hci_event_transport_usb_info_get_path_len(packet);
usb_path = hci_event_transport_usb_info_get_path(packet);
// print device path
printf("USB device 0x%04x/0x%04x, path: ",
hci_event_transport_usb_info_get_vendor_id(packet),
hci_event_transport_usb_info_get_product_id(packet));
for (i=0;i<usb_path_len;i++){
if (i) printf("-");
printf("%02x", usb_path[i]);
}
printf("\n");
break;
case BTSTACK_EVENT_STATE:
switch(btstack_event_state_get_state(packet)){
case HCI_STATE_WORKING:

View File

@ -118,8 +118,26 @@ static void local_version_information_handler(uint8_t * packet){
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
UNUSED(channel);
UNUSED(size);
uint8_t i;
uint8_t usb_path_len;
const uint8_t * usb_path;
if (packet_type != HCI_EVENT_PACKET) return;
switch (hci_event_packet_get_type(packet)){
case HCI_EVENT_TRANSPORT_USB_INFO:
usb_path_len = hci_event_transport_usb_info_get_path_len(packet);
usb_path = hci_event_transport_usb_info_get_path(packet);
// print device path
printf("USB device 0x%04x/0x%04x, path: ",
hci_event_transport_usb_info_get_vendor_id(packet),
hci_event_transport_usb_info_get_product_id(packet));
for (i=0;i<usb_path_len;i++){
if (i) printf("-");
printf("%02x", usb_path[i]);
}
printf("\n");
break;
case BTSTACK_EVENT_STATE:
switch (btstack_event_state_get_state(packet)){
case HCI_STATE_WORKING: