From e13e7f54cb7fcc107fc16ac2493ba2eade391a5d Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Sat, 9 Jul 2016 16:26:41 +0200 Subject: [PATCH] libusb: parse -u 11:22:33 as USB path --- port/libusb/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/port/libusb/main.c b/port/libusb/main.c index 6e17e6f6b..a6822f733 100644 --- a/port/libusb/main.c +++ b/port/libusb/main.c @@ -92,12 +92,36 @@ void hal_led_toggle(void){ } +#define USB_MAX_PATH_LEN 7 int main(int argc, const char * argv[]){ + uint8_t usb_path[USB_MAX_PATH_LEN]; + int usb_path_len = 0; + if (argc >= 3 && strcmp(argv[1], "-u") == 0){ + // parse command line options for "-u 11:22:33" + const char * port_str = argv[2]; + printf("Specified USB Path: "); + while (1){ + char * delimiter; + int port = strtol(port_str, &delimiter, 16); + usb_path[usb_path_len] = port; + usb_path_len++; + printf("%02x ", port); + if (!delimiter) break; + if (*delimiter != ':') break; + port_str = delimiter+1; + } + printf("\n"); + } + /// GET STARTED with BTstack /// btstack_memory_init(); btstack_run_loop_init(btstack_run_loop_posix_get_instance()); + if (usb_path_len){ + hci_transport_usb_set_path(usb_path_len, usb_path); + } + // use logger: format HCI_DUMP_PACKETLOGGER, HCI_DUMP_BLUEZ or HCI_DUMP_STDOUT hci_dump_open("/tmp/hci_dump.pklg", HCI_DUMP_PACKETLOGGER);