app_ble_peripheral延长睡眠模式

3 posts / 0 new
Last post
Max44
Offline
Last seen:9 months 4 days ago
加入:2016-02-08 15:58
app_ble_peripheral延长睡眠模式

DA14580, Basic Development Kit, SDK 5.0.3

Help!!! I've been trying with no success to get the app_ble_peripheral example to go into extended sleep mode with Bluetooth operations suspended pending an external wakeup. I have successfully compiled and run the proximity reporter from SDK 3 and it does similar to what I would like: goes into deep sleep after 3 minutes of inactivity. I've tried to apply the same steps to the SDK 5 app_ble_peripheral example and it's not suspending BLE operations ..... or at least not solidly until an external event like the proximity reporter.

In a copy of the app_ble_peripheral example, I set up an app_easy_timer to launch the following steps after 60 seconds:

Stop advertising: app_easy_gap_advertise_stop();
Stop the advertising timer: app_easy_timer_cancel(app_adv_data_update_timer_used);
Set extended sleep: arch_set_extended_sleep();
Suspend Bluetooth operations: arch_ble_ext_wakeup_on();
Set up wakeup functions: wkupct_register_callback(app_button_press_cb);
wkupct_enable_irq(0x0200, 0x0200, 1, 0); // P1_1, active low for P1_1, 1 event, debouncing time = 0ms

I've tested in the debugger to verify the timer fires and gets me to go into sleep sequence above. Then I've undef CFG_DEVELOPMENT_DEBUG, compiled, programmed an EEPROM, reset and booted. It doesn't appear to be going into solid extended sleep mode. Bluetooth operations are still active, I can still scan and connect from a tablet. I'm still drawing significant power ..... nothing like the 10uA the proximity reporter went into in sleep mode.

I'd really like to get the app_ble_peripheral functioning this way as a basis to build on for further development. I've read through so many forum posts and documents relating to this that my eye's are bleary and I'm still not getting anywhere, so some helpful advice would be much appreciated.

Device:
MT_dialog
Offline
Last seen:2 months 3 days ago
Staff
加入:2015-06-08 11:34
Hi Max44,

Hi Max44,

Lets start with sleep mode, in order for the device in SDK5, to fall in sleep mode you have to set the app_default_sleep_mode to ARCH_EXT_SLEEP_ON since in all of those examples the sleep is set to ARCH_SLEEP_OFF (if you invoke the arch_set_extended_sleep() this enables the sleep mode dynamically). Just by doing that you will be sleeping between the advertising intervals (you cant use the debugger though to test this, when in sleep mode you can't debug through keil). The procedure that you ve mentioned above its ok. By stopping the advertising you stop the BLE activity and you cancel the timer, i suppose that your mistake is that you are issuing all the above commands sequentialy in the timer_handler. The proper way to do such a thing is wait for the timer to elapse and in the handler just stop the advertising and cancel the timer (issue the app_easy_gap_advertise_stop()), when the advertising stops, a handler will be triggered user_app_adv_undirect_complete() in that handler you should set to wakeup only from an external interruptarch_ble_ext_wakeup_on() register your wakeup callback and enable the interrupt, you dont have to invoke the arch_set_extended_sleep() since you are allready in sleep mode (when the device has no BLE activity will fall in low power state). Hope that helps.

Thanks MT_dialog

Max44
Offline
Last seen:9 months 4 days ago
加入:2016-02-08 15:58
Thanks MT! Your advice to

Thanks MT! Your advice to invoke the sleep with external wakeup in user_app_adv_undirect_complete() worked perfectly. I suspected from reading UM-B-006 that I needed some way to synchronize with the BLE events, I just didn't know how in the context of the SDK 5 example.

I'm even seeing a superb 2uA after disconnecting the boot EEPROM.

Mark this as done and answered. Thanks again for your usual expert good advice.

Max

Topic locked