<?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 the advertising</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/40328/restart-the-advertising</link><description>Dear Sir, 
 
 I want to do the following scenario. 
 
 Once I power the device it will start advertising. 
 
 Now the advertising duration is 2minutes. 
 
 I have written a routine based on timer. When it is called it should initiate the advertising again</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 29 Apr 2020 11:33:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/40328/restart-the-advertising" /><item><title>RE: Restart the advertising</title><link>https://devzone.nordicsemi.com/thread/247313?ContentTypeID=1</link><pubDate>Wed, 29 Apr 2020 11:33:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:112dd531-e8af-4d9c-96a9-dea3443fef64</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;It seems like you are having quite a few undeclared identifiers in your applications. Please make sure these are declared in your project and try again.&lt;/p&gt;
&lt;p&gt;This ticket is over 1 year old, so if you&amp;#39;re having trouble with this, I suggest creating a new ticket describing your issue in detail.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart the advertising</title><link>https://devzone.nordicsemi.com/thread/247251?ContentTypeID=1</link><pubDate>Wed, 29 Apr 2020 09:04:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d91e641-b25b-4321-b8b6-7afbaedc2704</guid><dc:creator>Manoj Hiwarkar</dc:creator><description>&lt;p&gt;if I write this&amp;nbsp;&lt;/p&gt;
&lt;p&gt;//Stop&lt;br /&gt;err_code = sd_ble_gap_adv_stop(m_adv_handle);&lt;br /&gt;APP_ERROR_CHECK(err_code);&lt;br /&gt;NRF_LOG_INFO(&amp;quot;Stopping advertising&amp;quot;);&lt;br /&gt; &lt;br /&gt;//Start &lt;br /&gt;err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);&lt;br /&gt;APP_ERROR_CHECK(err_code);&lt;br /&gt;NRF_LOG_INFO(&amp;quot;Starting advertising&amp;quot;);&lt;/p&gt;
&lt;p&gt;Then I am getting these errors:&lt;/p&gt;
&lt;p&gt;./../../main.c: In function &amp;#39;nus_data_handler&amp;#39;:&lt;br /&gt;../../../main.c:205:32: error: &amp;#39;m_adv_handle&amp;#39; undeclared (first use in this function); did you mean &amp;#39;m_conn_handle&amp;#39;?&lt;br /&gt; err_code = sd_ble_gap_adv_stop(m_adv_handle);&lt;br /&gt; ^~~~~~~~~~~~&lt;br /&gt; m_conn_handle&lt;br /&gt;../../../main.c:205:32: note: each undeclared identifier is reported only once for each function it appears in&lt;br /&gt;../../../main.c:205:12: error: too many arguments to function &amp;#39;sd_ble_gap_adv_stop&amp;#39;&lt;br /&gt; err_code = sd_ble_gap_adv_stop(m_adv_handle);&lt;br /&gt; ^~~~~~~~~~~~~~~~~~~&lt;br /&gt;In file included from ../../../../../../components/softdevice/s132/headers/ble_gap.h:49,&lt;br /&gt; from ../../../../../../components/softdevice/s132/headers/ble.h:52,&lt;br /&gt; from ../../../../../../components/ble/common/ble_advdata.h:55,&lt;br /&gt; from ../../../main.c:56:&lt;br /&gt;../../../../../../components/softdevice/s132/headers/ble_gap.h:1448:39: note: declared here&lt;br /&gt; SVCALL(SD_BLE_GAP_ADV_STOP, uint32_t, sd_ble_gap_adv_stop(void));&lt;br /&gt; ^~~~~~~~~~~~~~~~~~~&lt;br /&gt;../../../../../../components/softdevice/s132/headers/nrf_svc.h:64:22: note: in definition of macro &amp;#39;SVCALL&amp;#39;&lt;br /&gt; static return_type signature \&lt;br /&gt; ^~~~~~~~~&lt;br /&gt;../../../main.c:210:47: error: &amp;#39;APP_BLE_CONN_CFG_TAG&amp;#39; undeclared (first use in this function); did you mean &amp;#39;BLE_CONN_CFG_GAP&amp;#39;?&lt;br /&gt; err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart the advertising</title><link>https://devzone.nordicsemi.com/thread/157653?ContentTypeID=1</link><pubDate>Fri, 16 Nov 2018 08:32:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b19f61b9-a595-4f69-9729-44f2afe9643b</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve been out of office this week.&lt;/p&gt;
&lt;p&gt;Yes, you can use &lt;strong&gt;sd_ble_gap_adv_stop() &lt;/strong&gt;to stop the current instance of advertising, just call it and use your advertising handle as input in the function.&lt;/p&gt;
&lt;p&gt;And yes, you can start it again by using &lt;strong&gt;sd_ble_gap_adv_start()&lt;/strong&gt;, just call it and use your advertising hnadle as a input in the function.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;- Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart the advertising</title><link>https://devzone.nordicsemi.com/thread/156739?ContentTypeID=1</link><pubDate>Sat, 10 Nov 2018 04:01:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5ad9bab-0661-428f-b12c-882ee5307b50</guid><dc:creator>GK</dc:creator><description>&lt;p&gt;Hi ,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Suppose if we use &lt;strong&gt;ble_advertising_start&lt;/strong&gt;() to start the advertising.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Can I use &lt;strong&gt;sd_ble_gap_adv_stop()&lt;/strong&gt;. to stop the current instance of advertising?&lt;/p&gt;
&lt;p&gt;If yes, what should be the steps to be taken?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Can I use &lt;strong&gt;sd_ble_gap_adv_start&lt;/strong&gt;() to restrat the advertising again after stopping one instance of advertising?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;PLease share your ideas on the same.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;with regards,&lt;/p&gt;
&lt;p&gt;Geetha&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart the advertising</title><link>https://devzone.nordicsemi.com/thread/156674?ContentTypeID=1</link><pubDate>Fri, 09 Nov 2018 13:23:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fa190b1-d4b7-44ce-ac47-edff9739c1e5</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;ble_advertising_start()&lt;/strong&gt; is an API call to start advertising using the &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.2.0%2Flib_ble_advertising.html&amp;amp;cp=4_0_0_3_2_1"&gt;Advertising Module&lt;/a&gt;. At the bottom of the module, advertising is started by &lt;strong&gt;sd_ble_gap_adv_start()&lt;/strong&gt; (line 657 in &lt;strong&gt;ble_advertising.c&lt;/strong&gt;) If you don&amp;#39;t need to do some of the &amp;quot;extra things&amp;quot; you refer to before you start advertising, you don&amp;#39;t need to use &lt;strong&gt;ble_advertising_start()&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;If you only need to &lt;strong&gt;start &lt;/strong&gt;or &lt;strong&gt;stop &lt;/strong&gt;advertising you can safely use &lt;strong&gt;only sd_ble_gap_adv_start() and sd_ble_gap_adv_stop()&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;- Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart the advertising</title><link>https://devzone.nordicsemi.com/thread/156651?ContentTypeID=1</link><pubDate>Fri, 09 Nov 2018 12:04:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6ae6e8d-aad4-4d77-9ea4-2a2a47841bb0</guid><dc:creator>GK</dc:creator><description>&lt;p&gt;Hi Andeas,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you very much for your reply.&lt;/p&gt;
&lt;p&gt;That means I am not supposed to use the function &amp;quot;ble_advertising_start()&amp;quot; to start advertising?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;And instead of that should I use &amp;quot;sd_ble_gap_adv_start()&amp;quot; directly?&lt;/p&gt;
&lt;p&gt;Inside this function&amp;nbsp; &amp;quot;ble_advertising_start()&amp;quot; &amp;nbsp; it uses &amp;quot;sd_ble_gap_adv_start()&amp;quot; and some more things extra.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Please shed some light.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart the advertising</title><link>https://devzone.nordicsemi.com/thread/156649?ContentTypeID=1</link><pubDate>Fri, 09 Nov 2018 11:48:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab360baa-af8c-4590-9c01-4dd1b6abe01b</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="AndreasF"]Look at &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/39766/stop-and-start-bluetooth-advertising"&gt;this question&lt;/a&gt;, there is an attached &lt;strong&gt;.zip&lt;/strong&gt; file containing a modified beacon example, where start/stop advertising is implemented as a handle of pressing button 1 (in void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action))[/quote]
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Did you look at this? It&amp;#39;s pretty straight forward shown how to use the two API&amp;#39;s I posted in my previous reply.&lt;/p&gt;
&lt;p&gt;The handle is initialized in the top of&lt;strong&gt; main.c&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static uint8_t              m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; /**&amp;lt; Advertising handle used to identify an advertising set. */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And the pin handler starts and stops advertising.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    ret_code_t err_code;

    nrf_drv_gpiote_out_toggle(PIN_OUT);
   

    if(is_advertising){ 
        err_code = sd_ble_gap_adv_stop(m_adv_handle);
        APP_ERROR_CHECK(err_code);
        NRF_LOG_INFO(&amp;quot;Stopping advertising&amp;quot;);
        is_advertising = false;
    } else{
        err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);
        APP_ERROR_CHECK(err_code);
        NRF_LOG_INFO(&amp;quot;Starting advertising&amp;quot;);
        is_advertising = true;
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-40bb9439e60d45c3808973c7240e9576/pastedimage1541764055363v1.png" alt=" " /&gt; &lt;/p&gt;
&lt;p&gt;You have probably defined &amp;amp;m_advertising as your advertising handle.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;- Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart the advertising</title><link>https://devzone.nordicsemi.com/thread/156611?ContentTypeID=1</link><pubDate>Fri, 09 Nov 2018 09:25:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2141ff5f-40fd-4aa4-a0b9-14a171ed9588</guid><dc:creator>GK</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thank you very much for your response.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;My scenario is as follows.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am using 2 timers.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;First timer will wake up for each 5 mins and second one wake up after the first 1 minute.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So when I start the device , it advertises. And initial 1 minute I will do a connect-disconnect method to get the adddresses.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now once I disconnect the device it will start advertising since the function &amp;quot;ble_advertising_start()&amp;quot;&amp;nbsp; is getting called inside &amp;quot;on_disconnected()&amp;quot; function.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If I want to stop advertising from the main.c file&amp;nbsp; how can I do this?..&lt;/p&gt;
&lt;p&gt;how can I get the advertising handle?&lt;/p&gt;
&lt;p&gt;Which function I should call from the main function to stop the current advertising instance and to start a new one?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I tried your scenario, but it shows the same problem&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanking you&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart the advertising</title><link>https://devzone.nordicsemi.com/thread/156583?ContentTypeID=1</link><pubDate>Fri, 09 Nov 2018 06:59:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7d24853-f6aa-4f22-82f1-5ff55a3c1e0e</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;The error code is most likely because when you try to stop advertising, you&amp;#39;re not advertising. Look at &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/18277/proper-way-to-start-stop-advertising"&gt;this question&lt;/a&gt; for more information about &lt;strong&gt;NRF_ERROR_INVALID_STATE&lt;/strong&gt; and advertising.&lt;/p&gt;
&lt;p&gt;The proper way to start/stop would be:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;//Stop
err_code = sd_ble_gap_adv_stop(m_adv_handle);
APP_ERROR_CHECK(err_code);
NRF_LOG_INFO(&amp;quot;Stopping advertising&amp;quot;);
        
//Start        
err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);
APP_ERROR_CHECK(err_code);
NRF_LOG_INFO(&amp;quot;Starting advertising&amp;quot;);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Look at &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/39766/stop-and-start-bluetooth-advertising"&gt;this question&lt;/a&gt;, there is an attached &lt;strong&gt;.zip&lt;/strong&gt; file containing a modified beacon example, where start/stop advertising is implemented as a handle of pressing button 1 (in void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action))&lt;/p&gt;
&lt;p&gt;- Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>