From b429b9b75714084ef3569f18c41d5f49eea2d846 Mon Sep 17 00:00:00 2001 From: "matthias.ringwald" Date: Tue, 11 Jan 2011 21:38:56 +0000 Subject: [PATCH] don't release UART during SLEEP - fixes problem with BTServer trying to do power management --- TODO.txt | 15 ++++++------- src/hci.c | 63 +++++++++++++++++++++++++++++-------------------------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/TODO.txt b/TODO.txt index 3bdecda8d..436325a9d 100644 --- a/TODO.txt +++ b/TODO.txt @@ -16,22 +16,19 @@ - automate scan enable management: hci_set_discoverable(bool) sets inquiry scan, page scan is always active NEXT: -- check apps for sleep mode/reactivated compatibility - see what happens on ACTIVATED event - - BTstackManager - - WiiMote example - - Keyboard - - Mouse - - WeBe++ +- check apps for sleep/wake mode compatibility - see what happens on ACTIVATED event + - update WiiMote example to use BTstackManager - BTstackManager & new remote_db - don't keep device info - - don't hanle link keys - + - don't handle link keys + - react to remote_name_cached event + - create Retina status bar icons - bugs: - verify: if (hic?) disconnect fails, l2cap channels are never discarded - + - verify: TestBTstackManager can do an inquiry, with 0 or more devices in the list - get rid of BTInquireViewController - update WiiMoteExample to use BTstackManager - Update/rewrite BTstack Keyboard diff --git a/src/hci.c b/src/hci.c index 59407d93c..6bb99a0a7 100644 --- a/src/hci.c +++ b/src/hci.c @@ -585,34 +585,6 @@ static int hci_power_control_on(){ return 0; } -static int hci_power_control_wake(){ - - log_dbg("hci_power_control_wake"); - - // wake on - int err = 0; - if (hci_stack.control && hci_stack.control->wake){ - err = (*hci_stack.control->wake)(hci_stack.config); - } - if (err){ - log_err( "WAKE_ON failed\n"); - hci_emit_hci_open_failed(); - return err; - } - - // open low-level device - err = hci_stack.hci_transport->open(hci_stack.config); - if (err){ - log_err( "HCI_INIT failed, turning Bluetooth off again\n"); - if (hci_stack.control && hci_stack.control->off){ - (*hci_stack.control->off)(hci_stack.config); - } - hci_emit_hci_open_failed(); - return err; - } - return 0; -} - static void hci_power_control_off(){ // close low-level device @@ -626,19 +598,50 @@ static void hci_power_control_off(){ } static void hci_power_control_sleep(){ - + log_dbg("hci_power_control_sleep"); - + +#if 0 + // don't close serial port during sleep + // close low-level device hci_stack.hci_transport->close(hci_stack.config); +#endif // sleep mode if (hci_stack.control && hci_stack.control->sleep){ (*hci_stack.control->sleep)(hci_stack.config); } + hci_stack.state = HCI_STATE_SLEEPING; } +static int hci_power_control_wake(){ + + log_dbg("hci_power_control_wake"); + + // wake on + if (hci_stack.control && hci_stack.control->wake){ + (*hci_stack.control->wake)(hci_stack.config); + } + +#if 0 + // open low-level device + int err = hci_stack.hci_transport->open(hci_stack.config); + if (err){ + log_err( "HCI_INIT failed, turning Bluetooth off again\n"); + if (hci_stack.control && hci_stack.control->off){ + (*hci_stack.control->off)(hci_stack.config); + } + hci_emit_hci_open_failed(); + return err; + } +#endif + + return 0; +} + + int hci_power_control(HCI_POWER_MODE power_mode){ log_dbg("hci_power_control: %u\n", power_mode);