mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-18 23:42:39 +00:00
libusb: parse -u 11:22:33 as USB path
This commit is contained in:
parent
aa662eec9c
commit
e13e7f54cb
@ -92,12 +92,36 @@ void hal_led_toggle(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define USB_MAX_PATH_LEN 7
|
||||||
int main(int argc, const char * argv[]){
|
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 ///
|
/// GET STARTED with BTstack ///
|
||||||
btstack_memory_init();
|
btstack_memory_init();
|
||||||
btstack_run_loop_init(btstack_run_loop_posix_get_instance());
|
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
|
// use logger: format HCI_DUMP_PACKETLOGGER, HCI_DUMP_BLUEZ or HCI_DUMP_STDOUT
|
||||||
hci_dump_open("/tmp/hci_dump.pklg", HCI_DUMP_PACKETLOGGER);
|
hci_dump_open("/tmp/hci_dump.pklg", HCI_DUMP_PACKETLOGGER);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user