react on logging toggle on iOS

This commit is contained in:
matthias.ringwald 2012-02-07 22:22:00 +00:00
parent 9ae0c3466a
commit b8a8478375

View File

@ -117,6 +117,8 @@ static int global_enable = 0;
static remote_device_db_t const * remote_device_db = NULL; static remote_device_db_t const * remote_device_db = NULL;
static int rfcomm_channel_generator = 1; static int rfcomm_channel_generator = 1;
static int loggingEnabled;
static void dummy_bluetooth_status_handler(BLUETOOTH_STATE state){ static void dummy_bluetooth_status_handler(BLUETOOTH_STATE state){
log_info("Bluetooth status: %u\n", state); log_info("Bluetooth status: %u\n", state);
}; };
@ -381,6 +383,18 @@ static int daemon_client_handler(connection_t *connection, uint16_t packet_type,
return err; return err;
} }
static void daemon_set_logging_enabled(int enabled){
if (enabled && !loggingEnabled){
// use logger: format HCI_DUMP_PACKETLOGGER, HCI_DUMP_BLUEZ or HCI_DUMP_STDOUT
hci_dump_open("/tmp/hci_dump.pklg", HCI_DUMP_PACKETLOGGER);
}
if (!enabled && loggingEnabled){
hci_dump_close();
}
loggingEnabled = enabled;
}
// local cache used to manage UI status // local cache used to manage UI status
static HCI_STATE hci_state = HCI_STATE_OFF; static HCI_STATE hci_state = HCI_STATE_OFF;
static int num_connections = 0; static int num_connections = 0;
@ -400,12 +414,12 @@ static void preferences_changed_callback(void){
#ifdef USE_BLUETOOL #ifdef USE_BLUETOOL
int logging = platform_iphone_logging_enabled(); int logging = platform_iphone_logging_enabled();
log_info("Logging enabled: %u\n", logging); log_info("Logging enabled: %u\n", logging);
daemon_set_logging_enabled(logging);
#endif #endif
} }
static void deamon_status_event_handler(uint8_t *packet, uint16_t size){ static void deamon_status_event_handler(uint8_t *packet, uint16_t size){
uint8_t update_status = 0; uint8_t update_status = 0;
// handle state event // handle state event
@ -701,10 +715,15 @@ int main (int argc, char * const * argv){
control->register_for_power_notifications(power_notification_callback); control->register_for_power_notifications(power_notification_callback);
} }
// use logger: format HCI_DUMP_PACKETLOGGER, HCI_DUMP_BLUEZ or HCI_DUMP_STDOUT // logging
hci_dump_open("/tmp/hci_dump.pklg", HCI_DUMP_PACKETLOGGER); loggingEnabled = 0;
hci_dump_set_max_packets(1000); int newLoggingEnabled = 1;
#ifdef USE_BLUETOOL
// iPhone has toggle in Preferences.app
newLoggingEnabled = platform_iphone_logging_enabled();
#endif
daemon_set_logging_enabled(newLoggingEnabled);
// init HCI // init HCI
hci_init(transport, &config, control, remote_device_db); hci_init(transport, &config, control, remote_device_db);