<?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>Indicating advertisement with a timer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/21979/indicating-advertisement-with-a-timer</link><description>I have a custom design buildt on ble_app_uart peripheral example from SDK 12.2.0. I use a timer that I start from case BLE_ADV_FAST in on_adv_evt to send a message to a display instead of the bsp led indicator (i use no leds to save power) 
 This is</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 28 Feb 2019 09:13:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/21979/indicating-advertisement-with-a-timer" /><item><title>RE: Indicating advertisement with a timer</title><link>https://devzone.nordicsemi.com/thread/173407?ContentTypeID=1</link><pubDate>Thu, 28 Feb 2019 09:13:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da27e927-44e2-4acd-8765-0edf664a6183</guid><dc:creator>ps_anu</dc:creator><description>&lt;p&gt;how to set the flag insid the connected /disconnected event ,how to start advertise using timer&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Indicating advertisement with a timer</title><link>https://devzone.nordicsemi.com/thread/86249?ContentTypeID=1</link><pubDate>Fri, 26 May 2017 14:12:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:677ebe03-180a-4723-bd7c-8ed4e8c96dcd</guid><dc:creator>erltot</dc:creator><description>&lt;p&gt;Hi, great!&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll try it and let you know.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Indicating advertisement with a timer</title><link>https://devzone.nordicsemi.com/thread/86246?ContentTypeID=1</link><pubDate>Wed, 24 May 2017 11:45:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40089833-9c0d-42f6-b628-2c9e0dce2e01</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Erltot,&lt;/p&gt;
&lt;p&gt;It was a bug in app_timer in SDK v12. It seems to be fixed in SDK v13. Could you try to test using SDK v13 ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Indicating advertisement with a timer</title><link>https://devzone.nordicsemi.com/thread/86245?ContentTypeID=1</link><pubDate>Tue, 23 May 2017 08:53:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16ee492a-4008-4f8b-9b57-ab76a68091b7</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Erltot,&lt;/p&gt;
&lt;p&gt;Just an update, it&amp;#39;s most likely a but with the app timer. We are still investigating it. It must be an issue of starting and stopping the app timer inside an interrupt handler.
There are some is a quick workaround to only start/stop a flag (variable) inside the Connected / Disconnected event and then in your main loop  in main() you actually start/stop the timer accordingly to the flag. Using app scheduler with the app timer should also fix the issue.&lt;/p&gt;
&lt;p&gt;I will keep you updated when we find the root cause.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Indicating advertisement with a timer</title><link>https://devzone.nordicsemi.com/thread/86244?ContentTypeID=1</link><pubDate>Tue, 23 May 2017 08:27:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1e81523-48d3-4bb4-b06f-79df722cae9d</guid><dc:creator>erltot</dc:creator><description>&lt;p&gt;Great! Yes, that was a minor mistake when building the simplified version. The flag is cleared in the actual appliaction. Awesome, I look forward to it. If you see something else that is funny please let me know, I am still learning :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Indicating advertisement with a timer</title><link>https://devzone.nordicsemi.com/thread/86243?ContentTypeID=1</link><pubDate>Fri, 19 May 2017 16:17:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5ac8e0b-8db0-49e6-9f1e-9c74153670cb</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Erltot,&lt;/p&gt;
&lt;p&gt;I had a look at your code , seems that you don&amp;#39;t clear ble_connected when you receive DISCONNECTED event ?&lt;/p&gt;
&lt;p&gt;However, I did see the issue as you described. The timer didn&amp;#39;t start right away after disconnection but delayed a little bit. I will do more investigation and get back to you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Indicating advertisement with a timer</title><link>https://devzone.nordicsemi.com/thread/86242?ContentTypeID=1</link><pubDate>Fri, 19 May 2017 12:21:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ff5cc86-636f-4090-a653-16d028ce719d</guid><dc:creator>erltot</dc:creator><description>&lt;p&gt;Try this: &lt;a href="https://ufile.io/exupu"&gt;https://ufile.io/exupu&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Indicating advertisement with a timer</title><link>https://devzone.nordicsemi.com/thread/86241?ContentTypeID=1</link><pubDate>Fri, 19 May 2017 11:09:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9eafd62-a43e-4143-928e-595610097a77</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Could you please try to create a small simplified version of your application that can reproduce the issue and update here so that I can test here ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Indicating advertisement with a timer</title><link>https://devzone.nordicsemi.com/thread/86240?ContentTypeID=1</link><pubDate>Fri, 19 May 2017 10:29:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b80b017b-3bec-4c98-ba28-df20433fdf59</guid><dc:creator>erltot</dc:creator><description>&lt;p&gt;Exact same effect occur upon disconnect when I start the timer from&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;static void on_ble_evt(ble_evt_t * p_ble_evt)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;switch (p_ble_evt-&amp;gt;header.evt_id)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;pre&gt;&lt;code&gt;  case BLE_GAP_EVT_DISCONNECTED:
&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;Could there be some constraints of simulateous timers running that I have missed?&lt;/p&gt;
&lt;p&gt;Edit: Formatting the code is a pain, I hope you understand&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Indicating advertisement with a timer</title><link>https://devzone.nordicsemi.com/thread/86250?ContentTypeID=1</link><pubDate>Thu, 18 May 2017 13:40:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef02ecfd-97e6-4e82-a57e-d18583e78477</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;I would suggest to start your m_advertisement_indicator timer outside of BLE_ADV_EVT_FAST.
Try to start it when you start advertising in main.c and when you disconnect. I don&amp;#39;t think softdevice would block it. It can delay it for a few ms but not blocking it and have the &amp;quot;rubberband effect&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Indicating advertisement with a timer</title><link>https://devzone.nordicsemi.com/thread/86239?ContentTypeID=1</link><pubDate>Thu, 18 May 2017 08:02:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97f50710-3c1c-451d-9b69-531443a55da6</guid><dc:creator>erltot</dc:creator><description>&lt;p&gt;I use repeated mode, which i call once before the big while&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;err_code = app_timer_create(&amp;amp;m_advertisement_indicator, APP_TIMER_MODE_REPEATED, advertisement_indicator);&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;APP_ERROR_CHECK(err_code);&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I start the timer for the first time in on_adv_evt switch shown above, and I stop it in the p_ble_evt switc in the BLE_GAP_EVT_CONNECTED case:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;err_code = app_timer_stop(m_advertisement_indicator);&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;APP_ERROR_CHECK(err_code);&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Sorry, I can&amp;#39;t attach the full code&lt;/p&gt;
&lt;p&gt;I added a print to RTT in the advertisement_indicator event and noticed it seems to be a rubberband effekt going on, after a while the timer starts but the prints all came simultanously.. Could it be the soft device blocking the event from running, and when it finally runs it executes several times?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Indicating advertisement with a timer</title><link>https://devzone.nordicsemi.com/thread/86247?ContentTypeID=1</link><pubDate>Tue, 16 May 2017 14:43:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:468f7142-beeb-4312-b77e-34368bbf9d2c</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Seems like app_timer_start() called but the timer is not really started ?
Have you set the timer with APP_TIMER_MODE_SINGLE_SHOT mode ?
Please attach your full code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Indicating advertisement with a timer</title><link>https://devzone.nordicsemi.com/thread/86251?ContentTypeID=1</link><pubDate>Tue, 16 May 2017 12:44:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2c09b6c-5280-4829-b7f5-ea67bf74ab37</guid><dc:creator>erltot</dc:creator><description>&lt;p&gt;In the breakpoint I get in ble_advertising_start() is BLE_ADV_MODE_DIRECTED as you suggested.&lt;/p&gt;
&lt;p&gt;I tried adding both (not at the same time)&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;case BLE_ADV_MODE_DIRECTED:&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;case BLE_ADV_EVT_DIRECTED:&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;just above the other case in my on_adv_evt, it didn&amp;#39;t do much...&lt;/p&gt;
&lt;p&gt;When I checked the ble_adv_evt in the event when I disconnect it shows BLE_ADV_EVT_FAST..
I don&amp;#39;t understand why does the other parts under the case for BLE_ADV_EVT_FAST get executed and not the timer?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Indicating advertisement with a timer</title><link>https://devzone.nordicsemi.com/thread/86248?ContentTypeID=1</link><pubDate>Mon, 15 May 2017 14:18:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:194ec5e4-d2a9-4866-955d-d1e26747d09b</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Erltot: Please add a break point inside ble_advertising_start() and check which advertising mode is entered after the device disconnect. on_disconnected() will be called after the connection is Disconnected.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Indicating advertisement with a timer</title><link>https://devzone.nordicsemi.com/thread/86238?ContentTypeID=1</link><pubDate>Fri, 12 May 2017 10:56:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:01d5b7f0-db37-4039-9812-02fe3bcb5578</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Erltot,&lt;/p&gt;
&lt;p&gt;Which example and SDK are you testing on ?&lt;/p&gt;
&lt;p&gt;Note that when we disconnected from the central, we may start with ADV_MODE_DIRECTED instead of BLE_ADV_MODE_FAST. That&amp;#39;s why you may not receive the timeout from the timer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>