main.c (6486d2780715619957fb8a2dafcdc878856ef6af) main.c (98451c7b102094e15e0a72ca2f7098d91aed2017)
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 110 unchanged lines hidden (view full) ---

119#define USB_MAX_PATH_LEN 7
120int main(int argc, const char * argv[]){
121
122 // Prevent stdout buffering
123 setvbuf(stdout, NULL, _IONBF, 0);
124
125 printf("BTstack/windows-winusb booting up\n");
126
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 110 unchanged lines hidden (view full) ---

119#define USB_MAX_PATH_LEN 7
120int main(int argc, const char * argv[]){
121
122 // Prevent stdout buffering
123 setvbuf(stdout, NULL, _IONBF, 0);
124
125 printf("BTstack/windows-winusb booting up\n");
126
127#if 0
128 int usb_path_len = 0;
129 uint8_t usb_path[USB_MAX_PATH_LEN];
130 if (argc >= 3 && strcmp(argv[1], "-u") == 0){
131 // parse command line options for "-u 11:22:33"
132 const char * port_str = argv[2];
133 printf("Specified USB Path: ");
134 while (1){
135 char * delimiter;
136 int port = strtol(port_str, &delimiter, 16);
137 usb_path[usb_path_len] = port;
138 usb_path_len++;
139 printf("%02x ", port);
140 if (!delimiter) break;
141 if (*delimiter != ':' && *delimiter != '-') break;
142 port_str = delimiter+1;
143 }
144 printf("\n");
145 }
146#endif
147
148 /// GET STARTED with BTstack ///
149 btstack_memory_init();
150 btstack_run_loop_init(btstack_run_loop_windows_get_instance());
151
127 /// GET STARTED with BTstack ///
128 btstack_memory_init();
129 btstack_run_loop_init(btstack_run_loop_windows_get_instance());
130
152 // if (usb_path_len){
153 // hci_transport_usb_set_path(usb_path_len, usb_path);
154 // }
155
156 // use logger: format HCI_DUMP_PACKETLOGGER, HCI_DUMP_BLUEZ or HCI_DUMP_STDOUT
157
158#if 1
159 char pklg_path[100];
160 strcpy(pklg_path, "hci_dump");
131 char pklg_path[100];
132 strcpy(pklg_path, "hci_dump");
161#if 0
162 if (usb_path_len){
163 strcat(pklg_path, "_");
164 strcat(pklg_path, argv[2]);
165 }
166#endif
167 strcat(pklg_path, ".pklg");
168 printf("Packet Log: %s\n", pklg_path);
133 strcat(pklg_path, ".pklg");
134 printf("Packet Log: %s\n", pklg_path);
169 hci_dump_open(pklg_path, HCI_DUMP_PACKETLOGGER);
170#else
171 hci_dump_open(NULL, HCI_DUMP_STDOUT);
172#endif
135 // hci_dump_open(pklg_path, HCI_DUMP_PACKETLOGGER);
173
174 // init HCI
175 hci_init(hci_transport_usb_instance(), NULL);
176
177 // inform about BTstack state
178 hci_event_callback_registration.callback = &packet_handler;
179 hci_add_event_handler(&hci_event_callback_registration);
180
181 // handle CTRL-c
182 signal(SIGINT, sigint_handler);
183
184 // setup app
185 btstack_main(argc, argv);
186
187 // go
188 btstack_run_loop_execute();
189
190 return 0;
191}
136
137 // init HCI
138 hci_init(hci_transport_usb_instance(), NULL);
139
140 // inform about BTstack state
141 hci_event_callback_registration.callback = &packet_handler;
142 hci_add_event_handler(&hci_event_callback_registration);
143
144 // handle CTRL-c
145 signal(SIGINT, sigint_handler);
146
147 // setup app
148 btstack_main(argc, argv);
149
150 // go
151 btstack_run_loop_execute();
152
153 return 0;
154}