diff --git a/platform/daemon/example/inquiry.c b/platform/daemon/example/inquiry.c index d60c4e79b..d5c7d562a 100644 --- a/platform/daemon/example/inquiry.c +++ b/platform/daemon/example/inquiry.c @@ -238,7 +238,11 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe int main (int argc, const char * argv[]){ // start stack +#ifdef _WIN32 btstack_run_loop_init(btstack_run_loop_posix_get_instance()); +#else + btstack_run_loop_init(btstack_run_loop_windows_get_instance()); +#endif int err = bt_open(); if (err) { printf("Failed to open connection to BTdaemon\n"); diff --git a/platform/daemon/example/l2cap_server.c b/platform/daemon/example/l2cap_server.c index 7de817273..dbe07c381 100644 --- a/platform/daemon/example/l2cap_server.c +++ b/platform/daemon/example/l2cap_server.c @@ -199,7 +199,11 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint } int main (int argc, const char * argv[]){ +#ifdef _WIN32 btstack_run_loop_init(btstack_run_loop_posix_get_instance()); +#else + btstack_run_loop_init(btstack_run_loop_windows_get_instance()); +#endif int err = bt_open(); if (err) { printf("Failed to open connection to BTdaemon\n"); diff --git a/platform/daemon/example/l2cap_throughput.c b/platform/daemon/example/l2cap_throughput.c index 11e503e2f..523186517 100644 --- a/platform/daemon/example/l2cap_throughput.c +++ b/platform/daemon/example/l2cap_throughput.c @@ -207,7 +207,11 @@ int main (int argc, const char * argv[]){ } } +#ifdef _WIN32 btstack_run_loop_init(btstack_run_loop_posix_get_instance()); +#else + btstack_run_loop_init(btstack_run_loop_windows_get_instance()); +#endif int err = bt_open(); if (err) { printf("Failed to open connection to BTdaemon\n"); diff --git a/platform/daemon/example/le_scan.c b/platform/daemon/example/le_scan.c index d0f02fa83..18740de62 100644 --- a/platform/daemon/example/le_scan.c +++ b/platform/daemon/example/le_scan.c @@ -81,7 +81,11 @@ int main (int argc, const char * argv[]){ printf("le_scan started\n"); printf("- connecting to BTstack Daemon\n"); // start stack +#ifdef _WIN32 btstack_run_loop_init(btstack_run_loop_posix_get_instance()); +#else + btstack_run_loop_init(btstack_run_loop_windows_get_instance()); +#endif int err = bt_open(); if (err) { printf("-> Failed to open connection to BTstack Daemon\n"); diff --git a/platform/daemon/example/rfcomm_cat.c b/platform/daemon/example/rfcomm_cat.c index 13fe8f75e..6dd89db03 100644 --- a/platform/daemon/example/rfcomm_cat.c +++ b/platform/daemon/example/rfcomm_cat.c @@ -165,7 +165,11 @@ int main (int argc, const char * argv[]){ arg++; } +#ifdef _WIN32 btstack_run_loop_init(btstack_run_loop_posix_get_instance()); +#else + btstack_run_loop_init(btstack_run_loop_windows_get_instance()); +#endif int err = bt_open(); if (err) { fprintf(stderr,"Failed to open connection to BTdaemon, err %d\n",err); diff --git a/platform/daemon/example/rfcomm_test.c b/platform/daemon/example/rfcomm_test.c index 62ff7695e..9456adfb3 100644 --- a/platform/daemon/example/rfcomm_test.c +++ b/platform/daemon/example/rfcomm_test.c @@ -177,7 +177,11 @@ int main (int argc, const char * argv[]){ create_test_data(); printf("created test data: \n%s\n", test_data); +#ifdef _WIN32 btstack_run_loop_init(btstack_run_loop_posix_get_instance()); +#else + btstack_run_loop_init(btstack_run_loop_windows_get_instance()); +#endif int err = bt_open(); if (err) { fprintf(stderr,"Failed to open connection to BTdaemon, err %d\n",err); diff --git a/platform/daemon/example/test.c b/platform/daemon/example/test.c index 1c2e879fd..c1cdaa715 100644 --- a/platform/daemon/example/test.c +++ b/platform/daemon/example/test.c @@ -102,7 +102,11 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint } int main (int argc, const char * argv[]){ +#ifdef _WIN32 btstack_run_loop_init(btstack_run_loop_posix_get_instance()); +#else + btstack_run_loop_init(btstack_run_loop_windows_get_instance()); +#endif int err = bt_open(); if (err) { printf("Failed to open connection to BTdaemon\n"); diff --git a/platform/daemon/src/daemon.c b/platform/daemon/src/daemon.c index 1cdae59f9..bd70b347d 100644 --- a/platform/daemon/src/daemon.c +++ b/platform/daemon/src/daemon.c @@ -54,12 +54,13 @@ #include #include #include -#include #ifdef _WIN32 #include "Winsock2.h" #endif +#include + #include "btstack.h" #include "btstack_client.h" #include "btstack_debug.h" @@ -67,7 +68,12 @@ #include "btstack_event.h" #include "btstack_linked_list.h" #include "btstack_run_loop.h" + +#ifdef _WIN32 +#include "btstack_run_loop_windows.h" +#else #include "btstack_run_loop_posix.h" +#endif #include "btstack_version.h" #include "classic/btstack_link_key_db.h" #include "classic/rfcomm.h" @@ -1992,9 +1998,13 @@ int main (int argc, char * const * argv){ hci_transport_config_uart.device_name = UART_DEVICE; #ifndef HAVE_PLATFORM_IPHONE_OS +#ifdef _WIN32 + uart_block_implementation = btstack_uart_block_windows_instance(); +#else uart_block_implementation = btstack_uart_block_posix_instance(); #endif - +#endif + #ifdef HAVE_PLATFORM_IPHONE_OS // use default (max) UART baudrate over netgraph interface hci_transport_config_uart.baudrate_init = 0; @@ -2026,8 +2036,12 @@ int main (int argc, char * const * argv){ btstack_device_name_db = BTSTACK_DEVICE_NAME_DB_INSTANCE(); #endif +#ifdef _WIN32 + btstack_run_loop_init(btstack_run_loop_windows_get_instance()); +#else btstack_run_loop_init(btstack_run_loop_posix_get_instance()); - +#endif + // init power management notifications if (control && control->register_for_power_notifications){ control->register_for_power_notifications(power_notification_callback);