<?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>Calling sd_ble_gap_adv_stop() does not emit an on_adv_evt event</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/14110/calling-sd_ble_gap_adv_stop-does-not-emit-an-on_adv_evt-event</link><description>I&amp;#39;m a bit at a loss of how to voluntarily stop advertising: My related thread says I should call sd_ble_gap_adv_stop() , but when I do, no corresponding event is raised by the soft-device. This ultimately means that on_adv_evt() in main.c does not get</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 07 Dec 2016 08:09:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/14110/calling-sd_ble_gap_adv_stop-does-not-emit-an-on_adv_evt-event" /><item><title>RE: Calling sd_ble_gap_adv_stop() does not emit an on_adv_evt event</title><link>https://devzone.nordicsemi.com/thread/53936?ContentTypeID=1</link><pubDate>Wed, 07 Dec 2016 08:09:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:799c4fdd-712a-4791-9ec2-b81277e76578</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Yes, that is the only time sd_ble_gap_adv_stop() will return NRF_ERROR_INVALID_STATE. You shouldn&amp;#39;t get a BLE_GAP_EVT_TIMEOUT event (with timeout source BLE_GAP_TIMEOUT_SRC_ADVERTISING) if you have called sd_ble_gap_adv_stop().&lt;/p&gt;
&lt;p&gt;If things are still unclear, or you have more questions please add them separately as new question. This is getting very cluttered.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Calling sd_ble_gap_adv_stop() does not emit an on_adv_evt event</title><link>https://devzone.nordicsemi.com/thread/53929?ContentTypeID=1</link><pubDate>Tue, 06 Dec 2016 16:43:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf17fce1-fdd8-46b7-90b2-d1d57d49c839</guid><dc:creator>annapalu</dc:creator><description>&lt;p&gt;Thanks for the answer,&lt;/p&gt;
&lt;p&gt;the err_code is = NRF_ERROR_INVALID_STATE.  only when an advertising stop occurs when the device is not in advertising? because if it occurs in other case maybe it&amp;#39;s important don&amp;#39;t ignore it.&lt;/p&gt;
&lt;p&gt;the second question is the same, i use a gls example and i see that the advertising stop ( i don&amp;#39;t see the board on the phone) when timeout occurs. I use the ble example and callstack is:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;ble_stack_init();&lt;/li&gt;
&lt;li&gt;softdevice_ble_evt_handler_set(ble_evt_dispatch);&lt;/li&gt;
&lt;li&gt;ble_advertising_on_ble_evt(p_ble_evt);&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Case : BLE_GAP_EVT_TIMEOUT,&lt;/p&gt;
&lt;p&gt;starts the ble_advertising in slow mode and go in Idle mode.
My question is, is there a way to stop the timer to avoid that the BLE_GAP_EVT_TIMEOUT arrived after i stop the advertising with command sd_ble_gap_adv_stop();&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Calling sd_ble_gap_adv_stop() does not emit an on_adv_evt event</title><link>https://devzone.nordicsemi.com/thread/53935?ContentTypeID=1</link><pubDate>Tue, 06 Dec 2016 15:12:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b71b484c-a56f-42fe-87df-584376b07cc2</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;If you call sd_ble_gap_adv_stop() when you are not advertising it will return NRF_ERROR_INVALID_STATE. Will something like this work for you:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint32_t err_code = sd_ble_gap_adv_stop();
if(err_code == NRF_ERROR_INVALID_STATE)
{
    // Do nothing, timeout has occured
}
else
{
    APP_ERROR_CHECK(err_code);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It means that instead of examining the advertising module, and make the necessary modifications to it, you can just use the sd_* API directly, like sd_ble_gap_adv_start(), sd_ble_gap_adv_stop() and so on.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t understand your second question. If you have further questions I think you should add them separately.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Calling sd_ble_gap_adv_stop() does not emit an on_adv_evt event</title><link>https://devzone.nordicsemi.com/thread/53934?ContentTypeID=1</link><pubDate>Tue, 06 Dec 2016 14:48:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e4690342-9272-4c22-bb90-30f2c0169730</guid><dc:creator>annapalu</dc:creator><description>&lt;p&gt;it&amp;#39;s simple to menage adv_stop OR timeout but if i want use both, i have a problem that one i stopped it with sd_ble_ga_adv_stop(), after the timeout expired and try to stop again the advertising and give an error. So two question&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What&amp;#39;s means &amp;quot; it is easier the sd *API directly &amp;quot;&lt;/li&gt;
&lt;li&gt;How when the evt timeout arrived from softdevice the advertising is stopped, i don&amp;#39;t see that in the loop Fast_slow_idle the function is called.&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Calling sd_ble_gap_adv_stop() does not emit an on_adv_evt event</title><link>https://devzone.nordicsemi.com/thread/53933?ContentTypeID=1</link><pubDate>Tue, 06 Dec 2016 14:41:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0038bb5d-46a1-469c-b7c5-c74978af3aca</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;I don&amp;#39;t know what is better, I don&amp;#39;t know what your application is. If you only want to start one type of advertising and stop it either with sd_ble_gap_adv_stop() or on timeout this is very simple to implement. Have you tried?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Calling sd_ble_gap_adv_stop() does not emit an on_adv_evt event</title><link>https://devzone.nordicsemi.com/thread/53932?ContentTypeID=1</link><pubDate>Tue, 06 Dec 2016 14:07:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55b0df15-411f-444f-a847-9be2cfc6b4c8</guid><dc:creator>annapalu</dc:creator><description>&lt;p&gt;So do you think, that is better use only the command sd_ble_gap_adv_stop? Is there not a method to stopped the timeout to avoid that a new advertising_stop is called? thanks, Anna&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Calling sd_ble_gap_adv_stop() does not emit an on_adv_evt event</title><link>https://devzone.nordicsemi.com/thread/53931?ContentTypeID=1</link><pubDate>Tue, 06 Dec 2016 13:49:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2fdda1d-7690-4ca8-9a39-c57c6d51c5a5</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;@annapalu Then you will have to modify the Advertising Module. Maybe it is easier to use the sd_* API directly?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Calling sd_ble_gap_adv_stop() does not emit an on_adv_evt event</title><link>https://devzone.nordicsemi.com/thread/53930?ContentTypeID=1</link><pubDate>Tue, 06 Dec 2016 13:22:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65fb974e-0334-431e-86a9-fc4ca2fdb672</guid><dc:creator>annapalu</dc:creator><description>&lt;p&gt;Hi Petter,&lt;/p&gt;
&lt;p&gt;if i want use both manually stop advertising and timeout stop advertising, how can i menage it?
Because if i stopped manually the advertising, after start the timeout that send a IDLE_EVT_ADV and give an error ( obviously)  because it is stopped preciously.
thanks,
Anna&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Calling sd_ble_gap_adv_stop() does not emit an on_adv_evt event</title><link>https://devzone.nordicsemi.com/thread/53928?ContentTypeID=1</link><pubDate>Fri, 27 May 2016 13:54:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b51d7bba-50c6-48fe-aa59-dbd2c587367c</guid><dc:creator>Boaz</dc:creator><description>&lt;p&gt;Good answer! Its easy to forget that I can opt to not to use the advertising module at all. Cheers :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Calling sd_ble_gap_adv_stop() does not emit an on_adv_evt event</title><link>https://devzone.nordicsemi.com/thread/53927?ContentTypeID=1</link><pubDate>Thu, 26 May 2016 14:47:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7fdf4707-497f-49ee-8cfa-268f720c8550</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;The Advertising Module can be used for many typical &amp;quot;Connectable Advertising&amp;quot; scenarios, but if you want other functionality you are free to modify it, or not use it at all.&lt;/p&gt;
&lt;p&gt;You can set the advertising data with ble_advdata_set(), and then call sd_ble_gap_adv_start() with the parameters you like. Maybe you want to advertise forever, and always stop it manually with sd_ble_gap_adv_stop()?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>