- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Device PSoC4 CYBLE-224116-01
Hello,
I am trying to create an application where the user can put the BLE device to sleep for certain hours.
I have created a service which has two characteristics; 1. Sleep time and 2. SleepNowFlag.
The user enters the duration for which it wants the BLE device to sleep, and they write on to the SleepNowFlag when they want to put the BLE to sleep.
The firmware in the BLE device keeps checking the flag; and when the flag is set it puts itself to sleep.
Now i want the device to wakeup when the sleep time is over and start advertising. I thought of using the RTC Alarm Feature but am not able to figure out how.
Please Help!
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The WDT is able to run while the chip is in deep-sleep; That might be your best option, as I'm not sure the RTC will run while in deep-sleep mode.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please post your code so we can check it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The WDT is able to run while the chip is in deep-sleep; That might be your best option, as I'm not sure the RTC will run while in deep-sleep mode.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is a display of what works in sleep modes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks @bobgoar; Linking the documentation is helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Guys,
Thank you for your inputs. What i have done is instead of putting BLE to sleep, i have called the CyBle_Stop() to completely stop the Stack(Also i didn't want the BLE to wake up at connection intervals). I am using the RTC Alarm feature to wake up the BLE and restart the stack using CyBle_Start(). Kindly correct me or suggest me alternatives on how to go about this.
I want the ble to completely shut itself down for a user defined period(minutes or hours).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Based on previous interactions with the cypress employees, they mentioned that as long as the BLE radio is not advertising, scanning, or connected, then it should be inactive (no power consumption) when you put it into sleep mode. Then you just skip calling th cyble_processevents() and there will be no wakeups from the BLE chip arbitrarily. I ran into issues when I tried doing the method you are mentioning above; starting/stopping the cyble stack during runtime. Iirc, I ran into memory or stack errors when trying to run operations, and changing the chip to either reset and cyble_start() from the reset or just going to sleep with no activity ended up cleaning up the bugs/errors.
Edit: If you make sure the BLE is not connected, scanning, or advertising and then put the BLE stack to sleep, then just wakeup the BLE module when you want to use it. It should be the same effect as what you are attempting above. Also, it will reduce processing time spent initializing/clearing the BLE stack.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You mean to say; if after putting the device to sleep, i stop calling CyBle_ProcessEvents() then the device won't wake up at intervals?
and is there a function to wakeup the BLE from sleep/deep-sleep, because all the functions i read were to wake up individual components...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you put the BLE chip to sleep with no active advertisement, connection, or scanning commands (cyble_state is disconnected/idle), then when you put the chip to sleep, it won't wake up from a BLE interrupt.
CyBle_EnterLPM(CYBLE_BLESS_DEEPSLEEP); //Tries to put the BLE chip into deep-sleep
blessState = CyBle_GetBleSsState(); //Returns the current BLE state (whether it went into sleep, deep sleep, or is still active
if((blessState == CYBLE_BLESS_STATE_ECO_ON || //Not sure what exactly this event is, but the ECO is the External Crystal Oscillator, and the cypress example code had it as a valid deep-sleep state.
blessState == CYBLE_BLESS_STATE_DEEPSLEEP)) { //If BLE chip entered deep sleep mode
CySysPmDeepSleep(); /Put processor into deep sleep power mode
cyble_exitlpm() //Processor won't execute this instruction until an interrupt wakes up the chip; If you turned off all of the BLE activity before deep sleep, then the BLE chip won't wakeup the processor, only other peripherals you have defined to do so. This instruction wakes up the BLE chip in order for you to call BLE APIs
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks e.pratt;
I will try this out. But is it possible for the server(peripheral/slave) to initiate disconnection(I guess not; but if you have a workaround)?I don't see an api which is similar to CyBle_GapcConnectDevice() to initiate disconnection.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use the CyBle_GapDisconnect(handle) function to initiate disconnection from either side. The latest BLE stack component also includes the CyBle_GapDisconnectWithReason(handle, reason) function if you want a specific reason code, though this is most often not necessary.
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Jeff!! I will try it out.
Maxwin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey Jeff,
Could you please tell what this event means?
* <tr>
* <td>CYBLE_BLESS_STATE_ECO_ON</td>
* <td>BLE Sub System is in process of wakeup from Deep Sleep Mode and ECO(XTAL) is turned on.
* CPU can be put in Deep Sleep Mode.</td>
* </tr>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Maxwin,
That's not technically an event; it's a value returned from a query concerning the current operating state of the BLE stack, specifically concerning when it is or is not safe to enter various sleep modes. The best explanation available for this is in Section 2.3 of AN92584, which you can find here:
It's a very short-lived state where the ECO is stabilizing.
Jeff