<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Sleep Immediately after Beacon Advertisement</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/23928/sleep-immediately-after-beacon-advertisement</link><description>I&amp;#39;m using the following code to make the beacon sleep: 
 static void on_ble_evt(ble_evt_t * p_ble_evt)
{
 uint32_t err_code;
 switch (p_ble_evt-&amp;gt;header.evt_id)
 {
 case BLE_GAP_EVT_CONNECTED:
 {
 break;
 }
 case BLE_GAP_EVT_TIMEOUT:
 {
 if</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 31 Jul 2017 13:50:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/23928/sleep-immediately-after-beacon-advertisement" /><item><title>RE: Sleep Immediately after Beacon Advertisement</title><link>https://devzone.nordicsemi.com/thread/94203?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 13:50:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:103c031b-9c14-40de-a069-a00e53293585</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;(2/2)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Then just reserve some time and get your hands dirty by trying some nRF5x examples down to API level. &lt;a href="https://devzone.nordicsemi.com/tutorials/"&gt;All 4 tutorials in &amp;quot;Bluetooth low energy&amp;quot; section of Tutorials page on this forum&lt;/a&gt; are going deep and are showing many details about BLE so one could get into it quickly.&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep Immediately after Beacon Advertisement</title><link>https://devzone.nordicsemi.com/thread/94202?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 13:47:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40470579-cf31-4bff-b499-4ff9891425ab</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Yes, you will need to do some more debugging and make sure HW is correct (probably trying some basic loop scenarios with special FWs and measure that characteristic) and then check SW (you probably run some busy-loop or similar heavy activity somewhere and it&amp;#39;s most probably triggered by your code...) The guide from Nordic I&amp;#39;ve linked in one previous answer up this thread is answering many details, I have nothing to add to it.&lt;/p&gt;
&lt;p&gt;When it comes to general BLE knowledge I can recommend two sources:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/Szarp/WolfsHeart/blob/master/Documents/Low%20Energy%20Training.pdf"&gt;original BLE training presentation from BT SIG&lt;/a&gt; (it&amp;#39;s from 2010 so you need to understand that it covers only 4.0/4.1 but most of new features added in 4.2 and 5.0 are just expanding not changing the basic principles). I use it as quick reference till today.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;(1/2)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep Immediately after Beacon Advertisement</title><link>https://devzone.nordicsemi.com/thread/94201?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 13:39:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09266e51-c3cd-4798-9a1d-d0b437b1f7a6</guid><dc:creator>Kenny</dc:creator><description>&lt;p&gt;Oh man, I did not know that! Can you share what awesome resources you have read to learn about the finer details of BLE? Also, this means that my mystery isn&amp;#39;t solved yet.. I don&amp;#39;t think the CPU spinning in a while (true) {} will take 20 mA, would it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep Immediately after Beacon Advertisement</title><link>https://devzone.nordicsemi.com/thread/94214?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 13:06:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c261c59f-d91f-48b7-bdb0-29c7eae25171</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Oh no, you can be sure that by calling thse SD function you would cause radio to be turned ON all the time (and Rx wouldn&amp;#39;t make any sense!). That&amp;#39;s not how BLE works, the &amp;quot;low energy&amp;quot; is achieved exactly by that trick of time synchronized Tx/Rx events and long times of complete &amp;quot;silence&amp;quot; when MCU is in deep power saving mode unless it does something else then serving BLE radio. You can turn Rx for continuous time but that&amp;#39;s only in GAP Central/Observer role where you scan for advertisements. The connection Rx window happens exactly 150us after each connectable ADV_xxx packet and it doesn&amp;#39;t need to be longer then few microseconds (if there is nothing detected) so no, SD is not listening for incoming CONNECT_REQ all the time;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep Immediately after Beacon Advertisement</title><link>https://devzone.nordicsemi.com/thread/94213?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 12:59:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:44e19d80-9950-4a76-99c7-f0975f2f6166</guid><dc:creator>Kenny</dc:creator><description>&lt;p&gt;Hmm.. my suspicion is that &lt;code&gt;sd_ble_gap_adv_start()&lt;/code&gt; actually sets the radio into RX on because it will wait for a device to connect (but joke&amp;#39;s on them since beacons are unconnectable). So, that&amp;#39;s why it draws 20 mA for the time when the radio is ON (measured with a scope.. and verified my other claims with a scope too). You don&amp;#39;t buy this explanation, do you?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep Immediately after Beacon Advertisement</title><link>https://devzone.nordicsemi.com/thread/94208?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 12:48:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:969902eb-76bf-4714-8a43-b5c0239a9407</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Glad to help, marking the right answer will help others;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep Immediately after Beacon Advertisement</title><link>https://devzone.nordicsemi.com/thread/94207?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 12:47:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c77e5d6-7e7c-4af4-8ef0-0ffb60d9e920</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Are you sure those are long-term averaged values? In short time of Tx and Rx activity radio can cause PCB to consume dozens of mA as spike values (even that might be good point for redesign if you are having custom HW) but not long-term. That would indicate either wrong measurement method or something terribly wrong in  your HW&amp;amp;FW set-up. Note &lt;a href="https://devzone.nordicsemi.com/blogs/1040/the-power-profiler-kit/"&gt;how usual power consumption curve looks like with Nordic Power Profiling Kit (PPK) on nRF52 DK&lt;/a&gt; (simple advertising by using exactly the same function as you do).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep Immediately after Beacon Advertisement</title><link>https://devzone.nordicsemi.com/thread/94206?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 12:41:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:255fb768-87c3-4b8d-bb32-c56246396f88</guid><dc:creator>Kenny</dc:creator><description>&lt;p&gt;Super weird, because if I call &lt;code&gt;sd_app_evt_wait()&lt;/code&gt; before &lt;code&gt;sd_ble_gap_adv_stop()&lt;/code&gt;, then it consumes 20 mA. But if I call the two functions in the opposite order, I get a sleep current of a few uA. Definitely going to give &lt;code&gt;radio_notification&lt;/code&gt; a shot. Thanks for the super quick responses! You&amp;#39;ve been a huge help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep Immediately after Beacon Advertisement</title><link>https://devzone.nordicsemi.com/thread/94205?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 12:36:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c306147d-d020-4503-bc4b-19c26edac02b</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;(3/3)&lt;/p&gt;
&lt;p&gt;Also note that you cannot run &lt;code&gt;sd_ble_gap_adv_stop&lt;/code&gt; directly in &lt;code&gt;radio_notification&lt;/code&gt; handler, you can only make a flag and schedule it for later. Or to be precise you can stop the adv. there but it might have consequences with wrong triggers of &lt;code&gt;radio_notification&lt;/code&gt; handler afterwards...&lt;/p&gt;
&lt;p&gt;(and last note: I really believe that your hope in saving power by turning adv, off is too high: yes, it will make a difference but not more than dozens of %, you won&amp;#39;t suddenly drop to microAmp region, that&amp;#39;s possible only in true POWER OFF...)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep Immediately after Beacon Advertisement</title><link>https://devzone.nordicsemi.com/thread/94215?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 12:34:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db19ad6d-3436-4b7a-84c4-01a041f323a6</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;(2/3)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If there is no other SoftDevice radio activity happening then use &lt;code&gt;radio_notification&lt;/code&gt; handler, it will wake you up exactly before and after every adv. event (typically burst of 3 Tx packets and optionally some Rx and more Tx windows if the advertisement is connectable/scannable).&lt;/li&gt;
&lt;li&gt;If there is more radio activity or if you don&amp;#39;t like &lt;code&gt;radio_notification&lt;/code&gt; method then you can only run your separate RTC timer in APP code and act accordingly (note that advertising has mandatory jitter from BT SIG specification so each adv. interval isn&amp;#39;t the same, only in average it should be at adv. interval period, so you need to run timer with some delay to be sure that particular event happened and be able to accept still some small chance that few intervals will be too short or too long and they will run out of your timer window...)&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep Immediately after Beacon Advertisement</title><link>https://devzone.nordicsemi.com/thread/94204?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 12:31:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb9cff47-6726-4950-9101-484221be8620</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Not really. Radio as such (the specific part of nRF5x SoC which does 2.4GHz radio Tx/Rx) is most of the time OFF. The call sd_ble_gap_adv_start is just function call from Soft Device (stack) API and you can be sure that stack isn&amp;#39;t stupid to power radio all the time, it just runs RTC timer to wake it put for the shortest time necessary. So yes, by turning the advertisement off will safe some power but it will be only very little for these few missing Tx/Rx bursts of radio (typically up to 1.5ms per whole adv. interval, see charts in Soft Device specification) and the power to run RTC timer. If you want to count single adv. events then you have two options:&lt;/p&gt;
&lt;p&gt;(1/3)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep Immediately after Beacon Advertisement</title><link>https://devzone.nordicsemi.com/thread/94212?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 12:23:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce94e521-036a-4ccd-b1a9-8b18cc9c90aa</guid><dc:creator>Kenny</dc:creator><description>&lt;p&gt;Actually, what you&amp;#39;re saying is exactly what I&amp;#39;m trying to do but I guess my description is awful. The chip is not in the lowest power mode because the radio is on from a &lt;code&gt;sd_ble_gap_adv_start()&lt;/code&gt; call and needs to be turned off with a &lt;code&gt;sd_ble_gap_adv_stop()&lt;/code&gt; call. So, I guess my question actually translates to how do I know when the advertisement is complete and that I can call &lt;code&gt;sd_ble_gap_adv_stop()&lt;/code&gt;? Is there some event that I should watch out for?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep Immediately after Beacon Advertisement</title><link>https://devzone.nordicsemi.com/thread/94211?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 11:57:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:33068bf7-f77e-46d3-8504-961dd479a476</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;You probably want to read &lt;a href="https://devzone.nordicsemi.com/question/5186/how-to-minimize-current-consumption-for-ble-application-on-nrf51822/"&gt;this ultimate guide how to optimize nRF5x power consumption&lt;/a&gt; (written for nRF51 but very much applicable also for nRF52).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep Immediately after Beacon Advertisement</title><link>https://devzone.nordicsemi.com/thread/94210?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 11:56:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e33e965-f8c1-43c3-bac2-31eb3f61bbc9</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;I&amp;#39;m afraid that&amp;#39;s misunderstanding of how low-power modes and Nordic BLE stack (Soft Devices) work. Normally chip &lt;strong&gt;IS&lt;/strong&gt; in the lowest power mode (SLEEP) all the time between radio events. So if you want to run any kind of time-dependent logic there is usually not much to be done except shutting down all HW peripheral blocks enabled in your custom APP code. If you want to go to POWER OFF (where basically whole chip is turned off and the only wake-up is GPIO or similar event which will cause situation similar to RESET) then simply call &lt;code&gt;sd_power_system_off()&lt;/code&gt; (or equivalent with SD disabled) but note that all activities will stop not only advertisement.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep Immediately after Beacon Advertisement</title><link>https://devzone.nordicsemi.com/thread/94209?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 11:29:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c91b36e-95eb-45e0-b04a-5598d9415377</guid><dc:creator>Kenny</dc:creator><description>&lt;p&gt;Hmm.. I guess my main question here is where is the best place to call sd_ble_gap_adv_stop()? If I don&amp;#39;t call it, the radio remains ON and the nrf51 sucks a lot of power. Is the best way to just simply start advertising, add a 20 ms delay and then call sd_ble_gap_adv_stop()? Does my comment make sense?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep Immediately after Beacon Advertisement</title><link>https://devzone.nordicsemi.com/thread/94200?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 08:20:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a989734-14ff-41de-adb2-fa1c29150980</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;What do you mean by &amp;quot;sleep&amp;quot;? I assume that nRF5x chip is going to POWER ON SLEEP (wait for event/interrupt) always when nothing is running on MCU so even between adv. events. If you mean POWER OFF state then sure you can do it but no BLE activity can be running during that time, you need to manage wake-up by some external GPIO interrupt line (button or some RTC capable chip if you expect to wake-up periodically).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>