Hi,
I am working on a project wherein. the device is in extended sleep mode by default. The device needs to wake up and advertise custom data on receiving an interrupt on a particular GPIO (PORT X, PIN Y) which is connected to an accelerometer device. Please suggest the steps that are required to configure the GPIO for receiving interrupts and waking up the device.
Thanks
Device:
Hi,
Also, I would like to ask another query. The default state of the device is extended sleep mode. At an interval of 2 minutes, the device wakes up after getting app easy timer interrupt, advertises data and then goes to sleep. I would also like to wake the device up after getting an interrupt on any GPIO as stated in the previous query(accelerometer interrupt) and advertise data. But if I am invoking the arch_ble_ext_wakeup_on (), the device will wake up only after receiving external interrupt. But I need both these events to wake the device up. Please suggest the method by which this could be done.
Thanks
Hi wisilica,
There is the ble_app_sleepmode example in the SDK that demonstrates how the device can wake up from a particular port/pin. So if i assume that the device upon booting up wont advertising but it will wait for a wake up interrupt, then you should set up the waking up interrupt in either the .app_on_set_dev_config_complete or in the .app_on_db_init_complete (depends if you are using a database in your device or not). You can check the functions in order to set up the wake up interrupt in the ble_app_sleepmode project in the user_sleepmode.c file in the user_app_adv_undirect_complete() function. Also dont forget to properly configure the GPIOs properly in the periph_init() function.
Regarding your second query, when the device gets an external interrupt it wakes up, checks if there is any pending event and then it immidiatelly falls back to sleep (since there is nothing to do). So as soon as the device gets the interrupt and as soon as it is handled (as the ble_app_sleepmode handles the interrupt) then you should have the data that you read from the sensor. Since you have the data from the sensor you can place those data in the advertising structure and start the advertising procedure. You dont have to invoke the arch_ble_ext_wakeup_on() in order for the device to wake up via external interrupt, but even if you do you will still be able to use the timer in order to wake up.
Thanks MT_dialog