xref: /btstack/port/windows-h4/main.c (revision 27ff675be7aa3e1e0ae9e68c256fc30005e5c641)
14e630824SMatthias Ringwald #include <stdint.h>
24e630824SMatthias Ringwald #include <stdio.h>
34e630824SMatthias Ringwald #include <stdlib.h>
44e630824SMatthias Ringwald #include <string.h>
54e630824SMatthias Ringwald #include <signal.h>
64e630824SMatthias Ringwald 
74e630824SMatthias Ringwald #include "btstack_config.h"
84e630824SMatthias Ringwald 
94e630824SMatthias Ringwald #include "btstack_debug.h"
104e630824SMatthias Ringwald #include "btstack_event.h"
114e630824SMatthias Ringwald #include "btstack_memory.h"
124e630824SMatthias Ringwald #include "btstack_run_loop.h"
134e630824SMatthias Ringwald #include "btstack_run_loop_windows.h"
144e630824SMatthias Ringwald #include "hci.h"
154e630824SMatthias Ringwald #include "hci_dump.h"
164e630824SMatthias Ringwald #include "hal_led.h"
174e630824SMatthias Ringwald // #include "btstack_link_key_db_fs.h"
184e630824SMatthias Ringwald // #include "stdin_support.h"
194e630824SMatthias Ringwald 
20*27ff675bSMatthias Ringwald int btstack_main(int argc, const char * argv[]);
21*27ff675bSMatthias Ringwald 
224e630824SMatthias Ringwald static int led_state = 0;
234e630824SMatthias Ringwald void hal_led_toggle(void){
244e630824SMatthias Ringwald     led_state = 1 - led_state;
254e630824SMatthias Ringwald     printf("LED State %u\n", led_state);
264e630824SMatthias Ringwald }
274e630824SMatthias Ringwald 
28*27ff675bSMatthias Ringwald static void sigint_handler(int param){
29*27ff675bSMatthias Ringwald 
30*27ff675bSMatthias Ringwald #ifndef _WIN32
31*27ff675bSMatthias Ringwald     // reset anyway
32*27ff675bSMatthias Ringwald     btstack_stdin_reset();
33*27ff675bSMatthias Ringwald #endif
34*27ff675bSMatthias Ringwald     log_info(" <= SIGINT received, shutting down..\n");
35*27ff675bSMatthias Ringwald     // hci_power_control(HCI_POWER_OFF);
36*27ff675bSMatthias Ringwald     // hci_close();
37*27ff675bSMatthias Ringwald     log_info("Good bye, see you.\n");
38*27ff675bSMatthias Ringwald     exit(0);
39*27ff675bSMatthias Ringwald }
40*27ff675bSMatthias Ringwald 
41*27ff675bSMatthias Ringwald int main(int argc, const char * argv[]){
424e630824SMatthias Ringwald 	printf("BTstack on windows booting up\n");
434e630824SMatthias Ringwald 
444e630824SMatthias Ringwald 	/// GET STARTED with BTstack ///
454e630824SMatthias Ringwald 	btstack_memory_init();
464e630824SMatthias Ringwald     btstack_run_loop_init(btstack_run_loop_windows_get_instance());
474e630824SMatthias Ringwald 
48*27ff675bSMatthias Ringwald     // handle CTRL-c
49*27ff675bSMatthias Ringwald     signal(SIGINT, sigint_handler);
50*27ff675bSMatthias Ringwald 
51*27ff675bSMatthias Ringwald     // setup app
52*27ff675bSMatthias Ringwald     btstack_main(argc, argv);
53*27ff675bSMatthias Ringwald 
54*27ff675bSMatthias Ringwald     // go
55*27ff675bSMatthias Ringwald     btstack_run_loop_execute();
56*27ff675bSMatthias Ringwald 
574e630824SMatthias Ringwald 	return 0;
584e630824SMatthias Ringwald }
59