<?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>Restart advertisement timeout before its actual timeout (Restart whenever there is a button press)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/48461/restart-advertisement-timeout-before-its-actual-timeout-restart-whenever-there-is-a-button-press</link><description>Hello, 
 
 I am using nRF52832, SDK_15.3.0, S132 SoftDevice and Segger for flashing the image. I am using ‘ble_app_blinky’. 
 
 In my application, I am starting BLE advertisement only when button is pressed. Also advertisement will timeout after 3 minutes</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 12 Jun 2019 13:21:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/48461/restart-advertisement-timeout-before-its-actual-timeout-restart-whenever-there-is-a-button-press" /><item><title>RE: Restart advertisement timeout before its actual timeout (Restart whenever there is a button press)</title><link>https://devzone.nordicsemi.com/thread/192406?ContentTypeID=1</link><pubDate>Wed, 12 Jun 2019 13:21:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd0e3acd-edc6-4c90-957c-ef386f343c69</guid><dc:creator>beemavishnu</dc:creator><description>&lt;p&gt;Thank you for your inputs&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart advertisement timeout before its actual timeout (Restart whenever there is a button press)</title><link>https://devzone.nordicsemi.com/thread/192378?ContentTypeID=1</link><pubDate>Wed, 12 Jun 2019 12:47:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19ec40cc-417d-4c38-ad4c-fd9870bb2c7a</guid><dc:creator>awneil</dc:creator><description>[quote userid="78085" url="~/f/nordic-q-a/48461/restart-advertisement-timeout-before-its-actual-timeout-restart-whenever-there-is-a-button-press/192371"]Can I blindly call stop advertisement functionality even though advertisement did not started at all[/quote]
&lt;p&gt;Yes.&lt;/p&gt;
&lt;p&gt;If your device is not advertising when you&amp;nbsp;&lt;span&gt;call sd_ble_gap_adv_stop, it will return&amp;nbsp;NRF_ERROR_INVALID_STATE - but that is harmless. So you just need to handle&amp;nbsp;that case as an &amp;quot;OK&amp;quot; result.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Note that if you use the &amp;#39;Go To Declaration&amp;#39; feature of your IDE there will be comments there which describe the possible return&amp;nbsp;codes, and what causes them.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart advertisement timeout before its actual timeout (Restart whenever there is a button press)</title><link>https://devzone.nordicsemi.com/thread/192371?ContentTypeID=1</link><pubDate>Wed, 12 Jun 2019 12:39:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5cbb2b43-05f8-4f51-aab5-730eb89082b2</guid><dc:creator>beemavishnu</dc:creator><description>&lt;p&gt;Hi Einar,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Can I blindly call stop advertisement functionality even though advertisement did not started at all. Below is the code I tested and its seems working. Can you please cross check and let me know your inputs.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
void start_Advertisement(void)
{
    advertising_stop();
    advertising_start();
}


void advertising_start(void)
{
    ret_code_t err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);
    
    APP_ERROR_CHECK(err_code);
}

void advertising_stop(void)
{
    ret_code_t err_code = sd_ble_gap_adv_stop(m_adv_handle);
    
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards&lt;/p&gt;
&lt;p&gt;Vishnu Beema&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart advertisement timeout before its actual timeout (Restart whenever there is a button press)</title><link>https://devzone.nordicsemi.com/thread/192358?ContentTypeID=1</link><pubDate>Wed, 12 Jun 2019 12:17:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf3b9df2-8d0c-493d-ae70-f9314f0ff640</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You will always get&amp;nbsp;NRF_ERROR_INVALID_STATE returned if you try to start advertising when it is already active. A better way to do this is probably to stop and then re-start advertising.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>