daemon: use windows run loop and uart block

This commit is contained in:
Matthias Ringwald 2018-08-14 22:56:39 +02:00
parent 092bd57e49
commit b9dcd1cc6b
8 changed files with 45 additions and 3 deletions

View File

@ -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[]){ int main (int argc, const char * argv[]){
// start stack // start stack
#ifdef _WIN32
btstack_run_loop_init(btstack_run_loop_posix_get_instance()); 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(); int err = bt_open();
if (err) { if (err) {
printf("Failed to open connection to BTdaemon\n"); printf("Failed to open connection to BTdaemon\n");

View File

@ -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[]){ int main (int argc, const char * argv[]){
#ifdef _WIN32
btstack_run_loop_init(btstack_run_loop_posix_get_instance()); 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(); int err = bt_open();
if (err) { if (err) {
printf("Failed to open connection to BTdaemon\n"); printf("Failed to open connection to BTdaemon\n");

View File

@ -207,7 +207,11 @@ int main (int argc, const char * argv[]){
} }
} }
#ifdef _WIN32
btstack_run_loop_init(btstack_run_loop_posix_get_instance()); 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(); int err = bt_open();
if (err) { if (err) {
printf("Failed to open connection to BTdaemon\n"); printf("Failed to open connection to BTdaemon\n");

View File

@ -81,7 +81,11 @@ int main (int argc, const char * argv[]){
printf("le_scan started\n"); printf("le_scan started\n");
printf("- connecting to BTstack Daemon\n"); printf("- connecting to BTstack Daemon\n");
// start stack // start stack
#ifdef _WIN32
btstack_run_loop_init(btstack_run_loop_posix_get_instance()); 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(); int err = bt_open();
if (err) { if (err) {
printf("-> Failed to open connection to BTstack Daemon\n"); printf("-> Failed to open connection to BTstack Daemon\n");

View File

@ -165,7 +165,11 @@ int main (int argc, const char * argv[]){
arg++; arg++;
} }
#ifdef _WIN32
btstack_run_loop_init(btstack_run_loop_posix_get_instance()); 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(); int err = bt_open();
if (err) { if (err) {
fprintf(stderr,"Failed to open connection to BTdaemon, err %d\n",err); fprintf(stderr,"Failed to open connection to BTdaemon, err %d\n",err);

View File

@ -177,7 +177,11 @@ int main (int argc, const char * argv[]){
create_test_data(); create_test_data();
printf("created test data: \n%s\n", test_data); printf("created test data: \n%s\n", test_data);
#ifdef _WIN32
btstack_run_loop_init(btstack_run_loop_posix_get_instance()); 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(); int err = bt_open();
if (err) { if (err) {
fprintf(stderr,"Failed to open connection to BTdaemon, err %d\n",err); fprintf(stderr,"Failed to open connection to BTdaemon, err %d\n",err);

View File

@ -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[]){ int main (int argc, const char * argv[]){
#ifdef _WIN32
btstack_run_loop_init(btstack_run_loop_posix_get_instance()); 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(); int err = bt_open();
if (err) { if (err) {
printf("Failed to open connection to BTdaemon\n"); printf("Failed to open connection to BTdaemon\n");

View File

@ -54,12 +54,13 @@
#include <stdlib.h> #include <stdlib.h>
#include <strings.h> #include <strings.h>
#include <unistd.h> #include <unistd.h>
#include <getopt.h>
#ifdef _WIN32 #ifdef _WIN32
#include "Winsock2.h" #include "Winsock2.h"
#endif #endif
#include <getopt.h>
#include "btstack.h" #include "btstack.h"
#include "btstack_client.h" #include "btstack_client.h"
#include "btstack_debug.h" #include "btstack_debug.h"
@ -67,7 +68,12 @@
#include "btstack_event.h" #include "btstack_event.h"
#include "btstack_linked_list.h" #include "btstack_linked_list.h"
#include "btstack_run_loop.h" #include "btstack_run_loop.h"
#ifdef _WIN32
#include "btstack_run_loop_windows.h"
#else
#include "btstack_run_loop_posix.h" #include "btstack_run_loop_posix.h"
#endif
#include "btstack_version.h" #include "btstack_version.h"
#include "classic/btstack_link_key_db.h" #include "classic/btstack_link_key_db.h"
#include "classic/rfcomm.h" #include "classic/rfcomm.h"
@ -1992,9 +1998,13 @@ int main (int argc, char * const * argv){
hci_transport_config_uart.device_name = UART_DEVICE; hci_transport_config_uart.device_name = UART_DEVICE;
#ifndef HAVE_PLATFORM_IPHONE_OS #ifndef HAVE_PLATFORM_IPHONE_OS
#ifdef _WIN32
uart_block_implementation = btstack_uart_block_windows_instance();
#else
uart_block_implementation = btstack_uart_block_posix_instance(); uart_block_implementation = btstack_uart_block_posix_instance();
#endif #endif
#endif
#ifdef HAVE_PLATFORM_IPHONE_OS #ifdef HAVE_PLATFORM_IPHONE_OS
// use default (max) UART baudrate over netgraph interface // use default (max) UART baudrate over netgraph interface
hci_transport_config_uart.baudrate_init = 0; 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(); btstack_device_name_db = BTSTACK_DEVICE_NAME_DB_INSTANCE();
#endif #endif
#ifdef _WIN32
btstack_run_loop_init(btstack_run_loop_windows_get_instance());
#else
btstack_run_loop_init(btstack_run_loop_posix_get_instance()); btstack_run_loop_init(btstack_run_loop_posix_get_instance());
#endif
// init power management notifications // init power management notifications
if (control && control->register_for_power_notifications){ if (control && control->register_for_power_notifications){
control->register_for_power_notifications(power_notification_callback); control->register_for_power_notifications(power_notification_callback);