<?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>Unclear how to stop and restart BLE SD</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/76393/unclear-how-to-stop-and-restart-ble-sd</link><description>I hope that someone can show a clear example of this. I surprised that it isn&amp;#39;t in the SDK examples. Basically, it is necessary to stop the BLE SD, in most low-power examples (if your device is to sleep correctly) then an example should show this clearly</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 16 Jun 2021 13:47:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/76393/unclear-how-to-stop-and-restart-ble-sd" /><item><title>RE: Unclear how to stop and restart BLE SD</title><link>https://devzone.nordicsemi.com/thread/315652?ContentTypeID=1</link><pubDate>Wed, 16 Jun 2021 13:47:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:550f34f5-1f85-457c-8c74-7b966c201037</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;There should not be any difference if you enter sleep with or without the Softdevice enabled. Are you trying to enter &lt;span&gt;&lt;a title="System ON mode" href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/power.html?cp=4_0_0_4_2_3#unique_647617312"&gt;System ON mode&lt;/a&gt;&lt;/span&gt; or &lt;span&gt;&lt;a title="System OFF mode" href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/power.html?cp=4_0_0_4_2_2#unique_1384365742"&gt;System OFF mode&lt;/a&gt;&lt;/span&gt;(aka deep sleep)?&lt;/p&gt;
&lt;p&gt;Our BLE peripheral examples in &amp;lt;sdk_root&amp;gt;\examples\ble_peripheral\ are already configured to enter System ON mode between Softdevice and Application events by calling the idle_state_handle() function from the main loop.&amp;nbsp; If you are looking to reduce the current to the minimum in system ON mode and don&amp;#39;t need BLE, then you just need to ensure the Softdevice isn&amp;#39;t performing any tasks by terminating any active connections and stop advertising/scanning. You should also make sure logging over UART is turned off (NRF_LOG_BACKEND_UART_ENABLED == 0) as the UART peripheral will have some impact on the idle current.&lt;/p&gt;
[quote user=""]But this returns&amp;nbsp;00&amp;gt; &amp;lt;error&amp;gt; app: SOFTDEVICE: INVALID MEMORY ACCESS in the RTT.&amp;nbsp;[/quote]
&lt;p&gt;&amp;nbsp;This assertion is raised by the Softdevice&amp;#39;s &lt;span&gt;&lt;a title="Memory isolation and runtime protection" href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/sd_mgr/mem_isolation_runtime_protection.html?cp=4_7_4_0_4_3"&gt;Memory isolation and runtime protection&lt;/a&gt;&lt;/span&gt; because you were accessing the RADIO registers while the Softdevice was enabled. But there is no need to disable the RADIO. The Softdevice does this internally after every BLE protocol event anyway (&lt;span class="item"&gt;&lt;a title="Bluetooth Low Energy power profiles" href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/ble_power_profiles/ble_power_profiles.html?cp=4_7_4_0_17"&gt;Bluetooth Low Energy power profiles&lt;/a&gt;&lt;/span&gt;). &lt;/p&gt;
[quote user=""]err_code = sd_ble_gap_adv_stop(m_conn_handle); // WHAT PARAMETERS TO PASS HERE????&lt;br /&gt; if (err_code != NRF_SUCCESS) {sprintf(outputString,&amp;quot;&amp;gt;&amp;gt;ble adv stop failed\r\n&amp;quot;);SEGGER_RTT_WriteString(0,outputString);}[/quote]
&lt;p&gt;You are supposed to pass the same advertising handle that was used when you called sd_ble_gap_adv_start() as this message sequence chart shows:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1623851083654v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;(&lt;span&gt;&lt;a title="sd_ble_gap_adv_stop" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v7.2.0/group___b_l_e___g_a_p___f_u_n_c_t_i_o_n_s.html?cp=4_7_4_1_2_1_3_5#ga732faeeb8489dcb34873d78e773957bc"&gt;sd_ble_gap_adv_stop&lt;/a&gt;&lt;/span&gt;)&lt;/p&gt;
&lt;p&gt;But it&amp;#39;s also ok to pass &amp;#39;0&amp;#39; here.&amp;nbsp; The current Softdevices do not support multiple advertising handles.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>