add HAVE_PLATFORM_IPHONE_OS. remove USE_BLUETOOL and USE_POWERMANAGEMENT

This commit is contained in:
Matthias Ringwald 2016-01-21 21:13:31 +01:00
parent 8f1b6c7162
commit 423a3e4940
6 changed files with 26 additions and 59 deletions

View File

@ -87,16 +87,13 @@
#include "ble/sm.h" #include "ble/sm.h"
#endif #endif
#ifdef USE_BLUETOOL #ifdef HAVE_PLATFORM_IPHONE_OS
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#include "../port/ios/src/bt_control_iphone.h"
#include <notify.h> #include <notify.h>
#endif #include "../port/ios/src/bt_control_iphone.h"
#include "../port/ios/src/platform_iphone.h"
#ifdef USE_SPRINGBOARD
// support for "enforece wake device" in h4 - used by iOS power management // support for "enforece wake device" in h4 - used by iOS power management
extern void hci_transport_h4_iphone_set_enforce_wake_device(char *path); extern void hci_transport_h4_iphone_set_enforce_wake_device(char *path);
#include "../port/ios/src/platform_iphone.h"
#endif #endif
#ifndef BTSTACK_LOG_FILE #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"); log_info("BTSTACK_GET_VERSION");
hci_emit_btstack_version(); hci_emit_btstack_version();
break; break;
#ifdef USE_BLUETOOL #ifdef HAVE_PLATFORM_IPHONE_OS
case BTSTACK_SET_SYSTEM_BLUETOOTH_ENABLED: case BTSTACK_SET_SYSTEM_BLUETOOTH_ENABLED:
log_info("BTSTACK_SET_SYSTEM_BLUETOOTH_ENABLED %u", packet[3]); log_info("BTSTACK_SET_SYSTEM_BLUETOOTH_ENABLED %u", packet[3]);
iphone_system_bt_set_enabled(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){ static void daemon_sigint_handler(int param){
#ifdef USE_BLUETOOL #ifdef HAVE_PLATFORM_IPHONE_OS
// notify daemons // notify daemons
notify_post("ch.ringwald.btstack.stopped"); notify_post("ch.ringwald.btstack.stopped");
#endif #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); 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){ static void * btstack_run_loop_thread(void *context){
btstack_run_loop_execute(); btstack_run_loop_execute();
return NULL; return NULL;
@ -1949,17 +1946,13 @@ int main (int argc, char * const * argv){
hci_transport_config_uart.baudrate_main = 0; hci_transport_config_uart.baudrate_main = 0;
hci_transport_config_uart.flowcontrol = 1; hci_transport_config_uart.flowcontrol = 1;
hci_transport_config_uart.device_name = UART_DEVICE; 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(); 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 #endif
config = &hci_transport_config_uart; config = &hci_transport_config_uart;
#endif #endif
@ -1967,17 +1960,11 @@ int main (int argc, char * const * argv){
transport = hci_transport_usb_instance(); transport = hci_transport_usb_instance();
#endif #endif
#ifdef USE_BLUETOOL #ifdef HAVE_PLATFORM_IPHONE_OS
control = &bt_control_iphone; control = &bt_control_iphone;
#endif
#if defined(USE_BLUETOOL) && defined(USE_POWERMANAGEMENT)
if (bt_control_iphone_power_management_supported()){ if (bt_control_iphone_power_management_supported()){
hci_transport_h4_iphone_set_enforce_wake_device("/dev/btwake"); hci_transport_h4_iphone_set_enforce_wake_device("/dev/btwake");
} }
#endif
#ifdef USE_SPRINGBOARD
bluetooth_status_handler = platform_iphone_status_handler; bluetooth_status_handler = platform_iphone_status_handler;
platform_iphone_register_window_manager_restart(update_ui_status); platform_iphone_register_window_manager_restart(update_ui_status);
platform_iphone_register_preferences_changed(preferences_changed_callback); platform_iphone_register_preferences_changed(preferences_changed_callback);
@ -1997,7 +1984,7 @@ int main (int argc, char * const * argv){
// logging // logging
loggingEnabled = 0; loggingEnabled = 0;
int newLoggingEnabled = 1; int newLoggingEnabled = 1;
#ifdef USE_BLUETOOL #ifdef HAVE_PLATFORM_IPHONE_OS
// iPhone has toggle in Preferences.app // iPhone has toggle in Preferences.app
newLoggingEnabled = platform_iphone_logging_enabled(); newLoggingEnabled = platform_iphone_logging_enabled();
#endif #endif
@ -2010,10 +1997,11 @@ int main (int argc, char * const * argv){
// init HCI // init HCI
hci_init(transport, config, control, remote_device_db); 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 // 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); hci_ssp_set_enable(0);
#endif #endif
// init L2CAP // init L2CAP
l2cap_init(); l2cap_init();
l2cap_register_packet_handler(&l2cap_packet_handler); l2cap_register_packet_handler(&l2cap_packet_handler);
@ -2056,7 +2044,7 @@ int main (int argc, char * const * argv){
#endif #endif
socket_connection_register_packet_callback(&daemon_client_handler); socket_connection_register_packet_callback(&daemon_client_handler);
#ifdef USE_BLUETOOL #ifdef HAVE_PLATFORM_IPHONE_OS
// notify daemons // notify daemons
notify_post("ch.ringwald.btstack.started"); notify_post("ch.ringwald.btstack.started");

View File

@ -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(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-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_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_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(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") 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 # 64-bit compilation requires position independent code (PIC) for libraries
BTSTACK_LIB_LDFLAGS+=" -fpic" BTSTACK_LIB_LDFLAGS+=" -fpic"
AM_CONDITIONAL(USE_POWERMANAGEMENT, [test "x$USE_POWERMANAGEMENT" == "xyes"])
# summary # summary
echo "CC: $CC" echo "CC: $CC"
@ -111,7 +108,6 @@ else
echo "UART_SPEED: $UART_SPEED" echo "UART_SPEED: $UART_SPEED"
fi fi
echo "USE_POWERMANAGEMENT: $USE_POWERMANAGEMENT"
echo "REMOTE_DEVICE_DB: $REMOTE_DEVICE_DB" echo "REMOTE_DEVICE_DB: $REMOTE_DEVICE_DB"
echo "HAVE_SO_NOSIGPIPE: $HAVE_SO_NOSIGPIPE" echo "HAVE_SO_NOSIGPIPE: $HAVE_SO_NOSIGPIPE"
echo echo
@ -154,8 +150,6 @@ echo "#define HCI_ACL_PAYLOAD_SIZE 1021" >> btstack_config.h
echo >> btstack_config.h echo >> btstack_config.h
echo "// Daemon configuration" >> 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 if test "x$HCI_TRANSPORT" = xUSB; then
USB_SOURCES=hci_transport_h2_libusb.c USB_SOURCES=hci_transport_h2_libusb.c
echo "#define HAVE_TRANSPORT_USB" >> btstack_config.h echo "#define HAVE_TRANSPORT_USB" >> btstack_config.h
@ -165,12 +159,6 @@ else
echo "#define HAVE_TRANSPORT_H4" >> btstack_config.h echo "#define HAVE_TRANSPORT_H4" >> btstack_config.h
echo "#define UART_DEVICE \"$UART_DEVICE\"" >> btstack_config.h echo "#define UART_DEVICE \"$UART_DEVICE\"" >> btstack_config.h
echo "#define UART_SPEED $UART_SPEED" >> 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 fi
if test ! -z "$REMOTE_DEVICE_DB" ; then if test ! -z "$REMOTE_DEVICE_DB" ; then
echo "#define REMOTE_DEVICE_DB $REMOTE_DEVICE_DB" >> btstack_config.h echo "#define REMOTE_DEVICE_DB $REMOTE_DEVICE_DB" >> btstack_config.h

View File

@ -10,10 +10,6 @@
#define HAVE_TRANSPORT_H4 #define HAVE_TRANSPORT_H4
#define UART_DEVICE "/dev/tty.bluetooth" #define UART_DEVICE "/dev/tty.bluetooth"
#define UART_SPEED 921600 #define UART_SPEED 921600
#define USE_BLUETOOL
#define USE_POWERMANAGEMENT
#define USE_SPRINGBOARD
#define USE_LAUNCHD
#define ENABLE_SDP #define ENABLE_SDP
#define ENABLE_RFCOMM #define ENABLE_RFCOMM
#define REMOTE_DEVICE_DB remote_device_db_iphone #define REMOTE_DEVICE_DB remote_device_db_iphone
@ -27,4 +23,8 @@
#define HCI_ACL_PAYLOAD_SIZE 1021 #define HCI_ACL_PAYLOAD_SIZE 1021
#define ENABLE_SDP_DES_DUMP #define ENABLE_SDP_DES_DUMP
#define USE_SPRINGBOARD
#define USE_LAUNCHD
#define HAVE_PLATFORM_IPHONE_OS
#endif #endif

View File

@ -381,7 +381,6 @@ static int iphone_write_initscript (int output, int baudrate){
// close input // close input
close(input); close(input);
#ifdef USE_POWERMANAGEMENT
if (iphone_has_csr()) { if (iphone_has_csr()) {
/* CSR BT module: deactivated since it didn't work on iPhone 3G, 3.1.3 /* 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. 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, "bcm -s 0x01,0x00,0x00,0x01,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x01\n");
// iphone_write_string(output, "msleep 50\n"); // iphone_write_string(output, "msleep 50\n");
} }
#endif
return 0; return 0;
} }
@ -419,25 +417,21 @@ static void iphone_write_configscript(int fd, int baudrate){
iphone_csr_set_baud(fd, baudrate); iphone_csr_set_baud(fd, baudrate);
} }
iphone_write_string(fd, "csr -r\n"); iphone_write_string(fd, "csr -r\n");
#ifdef USE_POWERMANAGEMENT
/* CSR BT module: deactivated since untested, but it most likely won't work /* CSR BT module: deactivated since untested, but it most likely won't work
see comments in 3.x init sequence above */ see comments in 3.x init sequence above */
// iphone_write_string(fd, "msleep 50\n"); // iphone_write_string(fd, "msleep 50\n");
// iphone_write_string(fd, "csr -p 0x01ca=0x0031\n"); // iphone_write_string(fd, "csr -p 0x01ca=0x0031\n");
// iphone_write_string(fd, "msleep 50\n"); // iphone_write_string(fd, "msleep 50\n");
// iphone_write_string(fd, "csr -p 0x01c7=0x0001,0x01f4,0x0005,0x0020\n"); // iphone_write_string(fd, "csr -p 0x01c7=0x0001,0x01f4,0x0005,0x0020\n");
#endif
} else { } else {
iphone_bcm_set_bd_addr(fd); iphone_bcm_set_bd_addr(fd);
if (baudrate) { if (baudrate) {
iphone_bcm_set_baud(fd, baudrate); iphone_bcm_set_baud(fd, baudrate);
iphone_write_string(fd, "msleep 200\n"); 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) // 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, "bcm -s 0x01,0x00,0x00,0x01,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x01\n");
iphone_write_string(fd, "msleep 50\n"); iphone_write_string(fd, "msleep 50\n");
#endif
} }
if (os6x){ if (os6x){
@ -581,14 +575,12 @@ static int iphone_on (void *transport_config){
}; };
err = pclose(outputFile); err = pclose(outputFile);
#ifdef USE_POWERMANAGEMENT
power_management_active = bt_control_iphone_power_management_supported(); power_management_active = bt_control_iphone_power_management_supported();
// if baud == 0, we're using system default: set in transport config // if baud == 0, we're using system default: set in transport config
if (hci_transport_config_uart->baudrate_init == 0) { if (hci_transport_config_uart->baudrate_init == 0) {
hci_transport_config_uart->baudrate_init = transport_speed; 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 // if we sleep for about 3 seconds, we miss a strage packet... but we don't care
// sleep(3); // sleep(3);

View File

@ -6,7 +6,6 @@
#define HAVE_TRANSPORT_H4 #define HAVE_TRANSPORT_H4
#define UART_DEVICE "/dev/ttyS0" #define UART_DEVICE "/dev/ttyS0"
#define UART_SPEED 115200 #define UART_SPEED 115200
#define USE_POWERMANAGEMENT
#define ENABLE_SDP #define ENABLE_SDP
#define ENABLE_RFCOMM #define ENABLE_RFCOMM
#define ENABLE_BLE #define ENABLE_BLE

View File

@ -78,7 +78,7 @@
#define HCI_CONNECTION_TIMEOUT_MS 10000 #define HCI_CONNECTION_TIMEOUT_MS 10000
#ifdef USE_BLUETOOL #ifdef HAVE_PLATFORM_IPHONE_OS
#include "../port/ios/src/bt_control_iphone.h" #include "../port/ios/src/bt_control_iphone.h"
#endif #endif
@ -896,7 +896,7 @@ static void hci_initializing_run(void){
case HCI_INIT_SEND_RESET: case HCI_INIT_SEND_RESET:
hci_state_reset(); hci_state_reset();
#ifndef USE_BLUETOOL #ifndef HAVE_PLATFORM_IPHONE_OS
// prepare reset if command complete not received in 100ms // prepare reset if command complete not received in 100ms
btstack_run_loop_set_timer(&hci_stack->timeout, 100); btstack_run_loop_set_timer(&hci_stack->timeout, 100);
btstack_run_loop_set_timer_handler(&hci_stack->timeout, hci_initialization_timeout_handler); 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){ switch (power_mode){
case HCI_POWER_ON: case HCI_POWER_ON:
#if defined(USE_POWERMANAGEMENT) && defined(USE_BLUETOOL) #ifdef HAVE_PLATFORM_IPHONE_OS
// nothing to do, if H4 supports power management // nothing to do, if H4 supports power management
if (bt_control_iphone_power_management_enabled()){ if (bt_control_iphone_power_management_enabled()){
hci_stack->state = HCI_STATE_INITIALIZING; hci_stack->state = HCI_STATE_INITIALIZING;
@ -2195,7 +2195,7 @@ int hci_power_control(HCI_POWER_MODE power_mode){
switch (power_mode){ switch (power_mode){
case HCI_POWER_ON: case HCI_POWER_ON:
#if defined(USE_POWERMANAGEMENT) && defined(USE_BLUETOOL) #ifdef HAVE_PLATFORM_IPHONE_OS
// nothing to do, if H4 supports power management // nothing to do, if H4 supports power management
if (bt_control_iphone_power_management_enabled()){ if (bt_control_iphone_power_management_enabled()){
hci_stack->state = HCI_STATE_INITIALIZING; hci_stack->state = HCI_STATE_INITIALIZING;
@ -2653,7 +2653,7 @@ void hci_run(void){
// close all open connections // close all open connections
connection = (hci_connection_t *) hci_stack->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 // don't close connections, if H4 supports power management
if (bt_control_iphone_power_management_enabled()){ if (bt_control_iphone_power_management_enabled()){
connection = NULL; connection = NULL;
@ -2687,7 +2687,7 @@ void hci_run(void){
case HCI_FALLING_ASLEEP_COMPLETE: case HCI_FALLING_ASLEEP_COMPLETE:
log_info("HCI_STATE_HALTING, calling sleep"); 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 // don't actually go to sleep, if H4 supports power management
if (bt_control_iphone_power_management_enabled()){ if (bt_control_iphone_power_management_enabled()){
// SLEEP MODE reached // SLEEP MODE reached