From 423a3e4940a214acf01c2dfc1ebdae7a47c5eb31 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 21 Jan 2016 21:13:31 +0100 Subject: [PATCH] add HAVE_PLATFORM_IPHONE_OS. remove USE_BLUETOOL and USE_POWERMANAGEMENT --- platform/daemon/daemon.c | 44 ++++++++++++-------------------- port/daemon/configure.ac | 12 --------- port/ios/btstack_config.h | 8 +++--- port/ios/src/bt_control_iphone.m | 8 ------ port/mtk/btstack_config.h | 1 - src/hci.c | 12 ++++----- 6 files changed, 26 insertions(+), 59 deletions(-) diff --git a/platform/daemon/daemon.c b/platform/daemon/daemon.c index 685a38091..329deeeae 100644 --- a/platform/daemon/daemon.c +++ b/platform/daemon/daemon.c @@ -87,16 +87,13 @@ #include "ble/sm.h" #endif -#ifdef USE_BLUETOOL +#ifdef HAVE_PLATFORM_IPHONE_OS #include -#include "../port/ios/src/bt_control_iphone.h" #include -#endif - -#ifdef USE_SPRINGBOARD +#include "../port/ios/src/bt_control_iphone.h" +#include "../port/ios/src/platform_iphone.h" // support for "enforece wake device" in h4 - used by iOS power management extern void hci_transport_h4_iphone_set_enforce_wake_device(char *path); -#include "../port/ios/src/platform_iphone.h" #endif #ifndef BTSTACK_LOG_FILE @@ -919,7 +916,7 @@ static int btstack_command_handler(connection_t *connection, uint8_t *packet, ui log_info("BTSTACK_GET_VERSION"); hci_emit_btstack_version(); break; -#ifdef USE_BLUETOOL +#ifdef HAVE_PLATFORM_IPHONE_OS case BTSTACK_SET_SYSTEM_BLUETOOTH_ENABLED: log_info("BTSTACK_SET_SYSTEM_BLUETOOTH_ENABLED %u", packet[3]); iphone_system_bt_set_enabled(packet[3]); @@ -1666,7 +1663,7 @@ static void power_notification_callback(POWER_NOTIFICATION_t notification){ static void daemon_sigint_handler(int param){ -#ifdef USE_BLUETOOL +#ifdef HAVE_PLATFORM_IPHONE_OS // notify daemons notify_post("ch.ringwald.btstack.stopped"); #endif @@ -1760,7 +1757,7 @@ static void usage(const char * name) { printf("Without the --tcp option, BTstack daemon is listening on unix domain socket %s\n\n", BTSTACK_UNIX); } -#ifdef USE_BLUETOOL +#ifdef HAVE_PLATFORM_IPHONE_OS static void * btstack_run_loop_thread(void *context){ btstack_run_loop_execute(); return NULL; @@ -1949,17 +1946,13 @@ int main (int argc, char * const * argv){ hci_transport_config_uart.baudrate_main = 0; hci_transport_config_uart.flowcontrol = 1; hci_transport_config_uart.device_name = UART_DEVICE; -#if defined(USE_BLUETOOL) && defined(USE_POWERMANAGEMENT) - if (bt_control_iphone_power_management_supported()){ - // use default (max) UART baudrate over netgraph interface - hci_transport_config_uart.baudrate_init = 0; - transport = hci_transport_h4_instance(); - } else { - transport = hci_transport_h4_instance(); - } -#else transport = hci_transport_h4_instance(); + +#ifdef HAVE_PLATFORM_IPHONE_OS + // use default (max) UART baudrate over netgraph interface + hci_transport_config_uart.baudrate_init = 0; #endif + config = &hci_transport_config_uart; #endif @@ -1967,17 +1960,11 @@ int main (int argc, char * const * argv){ transport = hci_transport_usb_instance(); #endif -#ifdef USE_BLUETOOL +#ifdef HAVE_PLATFORM_IPHONE_OS control = &bt_control_iphone; -#endif - -#if defined(USE_BLUETOOL) && defined(USE_POWERMANAGEMENT) if (bt_control_iphone_power_management_supported()){ hci_transport_h4_iphone_set_enforce_wake_device("/dev/btwake"); } -#endif - -#ifdef USE_SPRINGBOARD bluetooth_status_handler = platform_iphone_status_handler; platform_iphone_register_window_manager_restart(update_ui_status); platform_iphone_register_preferences_changed(preferences_changed_callback); @@ -1997,7 +1984,7 @@ int main (int argc, char * const * argv){ // logging loggingEnabled = 0; int newLoggingEnabled = 1; -#ifdef USE_BLUETOOL +#ifdef HAVE_PLATFORM_IPHONE_OS // iPhone has toggle in Preferences.app newLoggingEnabled = platform_iphone_logging_enabled(); #endif @@ -2010,10 +1997,11 @@ int main (int argc, char * const * argv){ // init HCI hci_init(transport, config, control, remote_device_db); -#ifdef USE_BLUETOOL +#ifdef HAVE_PLATFORM_IPHONE_OS // iPhone doesn't use SSP yet as there's no UI for it yet and auto accept is not an option hci_ssp_set_enable(0); #endif + // init L2CAP l2cap_init(); l2cap_register_packet_handler(&l2cap_packet_handler); @@ -2056,7 +2044,7 @@ int main (int argc, char * const * argv){ #endif socket_connection_register_packet_callback(&daemon_client_handler); -#ifdef USE_BLUETOOL +#ifdef HAVE_PLATFORM_IPHONE_OS // notify daemons notify_post("ch.ringwald.btstack.started"); diff --git a/port/daemon/configure.ac b/port/daemon/configure.ac index 201585383..d05430ac0 100644 --- a/port/daemon/configure.ac +++ b/port/daemon/configure.ac @@ -9,7 +9,6 @@ AM_INIT_AUTOMAKE AC_ARG_WITH(hci-transport, [AS_HELP_STRING([--with-hci-transport=transportType], [Specify BT type to use: h4, usb])], HCI_TRANSPORT=$withval, HCI_TRANSPORT="h4") AC_ARG_WITH(uart-device, [AS_HELP_STRING([--with-uart-device=uartDevice], [Specify BT UART device to use])], UART_DEVICE=$withval, UART_DEVICE="DEFAULT") AC_ARG_WITH(uart-speed, [AS_HELP_STRING([--with-uart-speed=uartSpeed], [Specify BT UART speed to use])], UART_SPEED=$withval, UART_SPEED="115200") -AC_ARG_ENABLE(powermanagement, [AS_HELP_STRING([--disable-powermanagement],[Disable powermanagement])], USE_POWERMANAGEMENT=$enableval, USE_POWERMANAGEMENT="yes") AC_ARG_ENABLE(launchd, [AS_HELP_STRING([--enable-launchd],[Compiles BTdaemon for use by launchd])], USE_LAUNCHD=$enableval, USE_LAUNCHD="no") AC_ARG_WITH(vendor-id, [AS_HELP_STRING([--with-vendor-id=vendorID], [Specify USB BT Dongle vendorID])], USB_VENDOR_ID=$withval, USB_VENDOR_ID="0") AC_ARG_WITH(product-id, [AS_HELP_STRING([--with-product-id=productID], [Specify USB BT Dongle productID])], USB_PRODUCT_ID=$withval, USB_PRODUCT_ID="0") @@ -92,8 +91,6 @@ CFLAGS="$CFLAGS -Werror -Wall -Wpointer-arith" # 64-bit compilation requires position independent code (PIC) for libraries BTSTACK_LIB_LDFLAGS+=" -fpic" -AM_CONDITIONAL(USE_POWERMANAGEMENT, [test "x$USE_POWERMANAGEMENT" == "xyes"]) - # summary echo "CC: $CC" @@ -111,7 +108,6 @@ else echo "UART_SPEED: $UART_SPEED" fi -echo "USE_POWERMANAGEMENT: $USE_POWERMANAGEMENT" echo "REMOTE_DEVICE_DB: $REMOTE_DEVICE_DB" echo "HAVE_SO_NOSIGPIPE: $HAVE_SO_NOSIGPIPE" echo @@ -154,8 +150,6 @@ echo "#define HCI_ACL_PAYLOAD_SIZE 1021" >> btstack_config.h echo >> btstack_config.h echo "// Daemon configuration" >> btstack_config.h -# todo: USE_BLUETOOL -> HAVE_BLUETOOL -# todo: USE_POWERMANAGEMENT -> HAVE_POWERMANAGMENT / ENABLE_POWERMANAGEMENT if test "x$HCI_TRANSPORT" = xUSB; then USB_SOURCES=hci_transport_h2_libusb.c echo "#define HAVE_TRANSPORT_USB" >> btstack_config.h @@ -165,12 +159,6 @@ else echo "#define HAVE_TRANSPORT_H4" >> btstack_config.h echo "#define UART_DEVICE \"$UART_DEVICE\"" >> btstack_config.h echo "#define UART_SPEED $UART_SPEED" >> btstack_config.h - if test "x$USE_BLUETOOL" = xyes; then - echo "#define USE_BLUETOOL" >> btstack_config.h - fi - if test "x$USE_POWERMANAGEMENT" = xyes; then - echo "#define USE_POWERMANAGEMENT" >> btstack_config.h - fi fi if test ! -z "$REMOTE_DEVICE_DB" ; then echo "#define REMOTE_DEVICE_DB $REMOTE_DEVICE_DB" >> btstack_config.h diff --git a/port/ios/btstack_config.h b/port/ios/btstack_config.h index 0cb29f344..8f6ec3c76 100644 --- a/port/ios/btstack_config.h +++ b/port/ios/btstack_config.h @@ -10,10 +10,6 @@ #define HAVE_TRANSPORT_H4 #define UART_DEVICE "/dev/tty.bluetooth" #define UART_SPEED 921600 -#define USE_BLUETOOL -#define USE_POWERMANAGEMENT -#define USE_SPRINGBOARD -#define USE_LAUNCHD #define ENABLE_SDP #define ENABLE_RFCOMM #define REMOTE_DEVICE_DB remote_device_db_iphone @@ -27,4 +23,8 @@ #define HCI_ACL_PAYLOAD_SIZE 1021 #define ENABLE_SDP_DES_DUMP +#define USE_SPRINGBOARD +#define USE_LAUNCHD +#define HAVE_PLATFORM_IPHONE_OS + #endif \ No newline at end of file diff --git a/port/ios/src/bt_control_iphone.m b/port/ios/src/bt_control_iphone.m index 0b82359cc..b7c0d3b49 100644 --- a/port/ios/src/bt_control_iphone.m +++ b/port/ios/src/bt_control_iphone.m @@ -381,7 +381,6 @@ static int iphone_write_initscript (int output, int baudrate){ // close input close(input); -#ifdef USE_POWERMANAGEMENT if (iphone_has_csr()) { /* CSR BT module: deactivated since it didn't work on iPhone 3G, 3.1.3 the first few packets didn't get received when iPhone is sleeping. @@ -396,7 +395,6 @@ static int iphone_write_initscript (int output, int baudrate){ // iphone_write_string(output, "bcm -s 0x01,0x00,0x00,0x01,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x01\n"); // iphone_write_string(output, "msleep 50\n"); } -#endif return 0; } @@ -419,25 +417,21 @@ static void iphone_write_configscript(int fd, int baudrate){ iphone_csr_set_baud(fd, baudrate); } iphone_write_string(fd, "csr -r\n"); -#ifdef USE_POWERMANAGEMENT /* CSR BT module: deactivated since untested, but it most likely won't work see comments in 3.x init sequence above */ // iphone_write_string(fd, "msleep 50\n"); // iphone_write_string(fd, "csr -p 0x01ca=0x0031\n"); // iphone_write_string(fd, "msleep 50\n"); // iphone_write_string(fd, "csr -p 0x01c7=0x0001,0x01f4,0x0005,0x0020\n"); -#endif } else { iphone_bcm_set_bd_addr(fd); if (baudrate) { iphone_bcm_set_baud(fd, baudrate); iphone_write_string(fd, "msleep 200\n"); } -#ifdef USE_POWERMANAGEMENT // power management only active on 4.x with BCM (iPhone 3GS and higher, all iPads, iPod touch 3G and higher) iphone_write_string(fd, "bcm -s 0x01,0x00,0x00,0x01,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x01\n"); iphone_write_string(fd, "msleep 50\n"); -#endif } if (os6x){ @@ -581,14 +575,12 @@ static int iphone_on (void *transport_config){ }; err = pclose(outputFile); -#ifdef USE_POWERMANAGEMENT power_management_active = bt_control_iphone_power_management_supported(); // if baud == 0, we're using system default: set in transport config if (hci_transport_config_uart->baudrate_init == 0) { hci_transport_config_uart->baudrate_init = transport_speed; } -#endif // if we sleep for about 3 seconds, we miss a strage packet... but we don't care // sleep(3); diff --git a/port/mtk/btstack_config.h b/port/mtk/btstack_config.h index 4066e5b55..0ad08c362 100644 --- a/port/mtk/btstack_config.h +++ b/port/mtk/btstack_config.h @@ -6,7 +6,6 @@ #define HAVE_TRANSPORT_H4 #define UART_DEVICE "/dev/ttyS0" #define UART_SPEED 115200 -#define USE_POWERMANAGEMENT #define ENABLE_SDP #define ENABLE_RFCOMM #define ENABLE_BLE diff --git a/src/hci.c b/src/hci.c index 4d95eea80..93381275e 100644 --- a/src/hci.c +++ b/src/hci.c @@ -78,7 +78,7 @@ #define HCI_CONNECTION_TIMEOUT_MS 10000 -#ifdef USE_BLUETOOL +#ifdef HAVE_PLATFORM_IPHONE_OS #include "../port/ios/src/bt_control_iphone.h" #endif @@ -896,7 +896,7 @@ static void hci_initializing_run(void){ case HCI_INIT_SEND_RESET: hci_state_reset(); -#ifndef USE_BLUETOOL +#ifndef HAVE_PLATFORM_IPHONE_OS // prepare reset if command complete not received in 100ms btstack_run_loop_set_timer(&hci_stack->timeout, 100); btstack_run_loop_set_timer_handler(&hci_stack->timeout, hci_initialization_timeout_handler); @@ -2171,7 +2171,7 @@ int hci_power_control(HCI_POWER_MODE power_mode){ switch (power_mode){ case HCI_POWER_ON: -#if defined(USE_POWERMANAGEMENT) && defined(USE_BLUETOOL) +#ifdef HAVE_PLATFORM_IPHONE_OS // nothing to do, if H4 supports power management if (bt_control_iphone_power_management_enabled()){ hci_stack->state = HCI_STATE_INITIALIZING; @@ -2195,7 +2195,7 @@ int hci_power_control(HCI_POWER_MODE power_mode){ switch (power_mode){ case HCI_POWER_ON: -#if defined(USE_POWERMANAGEMENT) && defined(USE_BLUETOOL) +#ifdef HAVE_PLATFORM_IPHONE_OS // nothing to do, if H4 supports power management if (bt_control_iphone_power_management_enabled()){ hci_stack->state = HCI_STATE_INITIALIZING; @@ -2653,7 +2653,7 @@ void hci_run(void){ // close all open connections connection = (hci_connection_t *) hci_stack->connections; -#if defined(USE_POWERMANAGEMENT) && defined(USE_BLUETOOL) +#ifdef HAVE_PLATFORM_IPHONE_OS // don't close connections, if H4 supports power management if (bt_control_iphone_power_management_enabled()){ connection = NULL; @@ -2687,7 +2687,7 @@ void hci_run(void){ case HCI_FALLING_ASLEEP_COMPLETE: log_info("HCI_STATE_HALTING, calling sleep"); -#if defined(USE_POWERMANAGEMENT) && defined(USE_BLUETOOL) +#ifdef HAVE_PLATFORM_IPHONE_OS // don't actually go to sleep, if H4 supports power management if (bt_control_iphone_power_management_enabled()){ // SLEEP MODE reached