<?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>Assertion failed error during bt_scan_stop</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/106475/assertion-failed-error-during-bt_scan_stop</link><description>I currently have a device that can listen and broadcast (not at the same time) and I am trying to incorporate timers to it. During the callback of a timer I call bt_scan_stop, as can be seen below (inside of stop_scanning()). Doing this however gives</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 11 Dec 2023 14:09:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/106475/assertion-failed-error-during-bt_scan_stop" /><item><title>RE: Assertion failed error during bt_scan_stop</title><link>https://devzone.nordicsemi.com/thread/459722?ContentTypeID=1</link><pubDate>Mon, 11 Dec 2023 14:09:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a58863c-797c-4565-9b00-19976bcb5992</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;That is a good question. Apart from stopping the scanner, you normally do not do anything with your scanner in your application until you received something in the scanner. Receiving something already implies that the scanner has started. So atleast with the scanner role, you should not see this in other scan procedures.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;With regards to other procedures, cannot give you a general answers. If there is a callback mechanism for letting the application know that any BLE procedure is complete, then the application should use it as a cue to start another procedure if necessary,&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assertion failed error during bt_scan_stop</title><link>https://devzone.nordicsemi.com/thread/459713?ContentTypeID=1</link><pubDate>Mon, 11 Dec 2023 13:53:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:356206f8-68a0-4b47-879b-b4af2f647eeb</guid><dc:creator>TLiem</dc:creator><description>&lt;p&gt;I was able to verify that by stopping the scanner in my callback function stopped the scanner successfully. Thank you very much for that! I have similar problems with the next steps which is starting the broadcast, and maybe eventually stopping as well, but maybe I can solve it on my own.&lt;br /&gt;&lt;br /&gt;I did have some questions regarding your answer though. You stated that I started the procedure of stopping before the scan_params were set, however I am able to scan for devices until I get the same error. Meaning that it can happen in other situations as well, unless I misunderstood your answer in that case I am sorry.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assertion failed error during bt_scan_stop</title><link>https://devzone.nordicsemi.com/thread/459698?ContentTypeID=1</link><pubDate>Mon, 11 Dec 2023 12:59:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ef5a3be-6f47-489e-a9ac-dd57517c6bcd</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Thanks for the project TLiem,&lt;/p&gt;
&lt;p&gt;I reproduced the issue and&amp;nbsp;I have added some logs in the hci_core.c and see the below&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting nRF Connect SDK v2.5.0 ***
Starting Tag
k_sem_give done wiith opcode 0x0c03
k_sem_take success with opcode 0x0c03
k_sem_give done wiith opcode 0x1003
k_sem_take success with opcode 0x1003
k_sem_give done wiith opcode 0x1001
k_sem_take success with opcode 0x1001
k_sem_give done wiith opcode 0x1002
k_sem_take success with opcode 0x1002
k_sem_give done wiith opcode 0x2003
k_sem_take success with opcode 0x2003
k_sem_give done wiith opcode 0x201c
k_sem_take success with opcode 0x201c
k_sem_give done wiith opcode 0x2001
k_sem_take success with opcode 0x2001
k_sem_give done wiith opcode 0x0c01
k_sem_take success with opcode 0x0c01
k_sem_give done wiith opcode 0xfc01
k_sem_take success with opcode 0xfc01
k_sem_give done wiith opcode 0xfc02
k_sem_take success with opcode 0xfc02
k_sem_give done wiith opcode 0x1009
k_sem_take success with opcode 0x1009
k_sem_give done wiith opcode 0xfc09
k_sem_take success with opcode 0xfc09
k_sem_give done wiith opcode 0x2005
k_sem_take success with opcode 0x2005
k_sem_give done wiith opcode 0x2005
k_sem_take success with opcode 0x2005
k_sem_take success with opcode 0x200b
k_sem_give done wiith opcode 0x200c
k_sem_take success with opcode 0x200c
Started scanning...
Scanning Timer Interval
Stopped scanning timer&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;As you can see the semaphore &lt;strong&gt;sync_sem&amp;nbsp;&lt;/strong&gt;was taken in the&amp;nbsp;bt_hci_cmd_send_sync for opcode 0x200b (BT_HCI_OP_LE_SET_SCAN_PARAM) but was not released and you started another procedure of stoppiing the scanning before the scan_params for the scanner is set.&lt;/p&gt;
&lt;p&gt;That means that you are trying to stop the scanner before you properly started the scanner.&lt;/p&gt;
&lt;p&gt;The best thing is to stop the scanner in the scanner callback functions &lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/libraries/bluetooth_services/scan.html"&gt;BT_SCAN_CB_INIT&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assertion failed error during bt_scan_stop</title><link>https://devzone.nordicsemi.com/thread/459673?ContentTypeID=1</link><pubDate>Mon, 11 Dec 2023 11:39:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1d7cd5e-2910-46f1-8522-439878c0ef42</guid><dc:creator>TLiem</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/1778.prg.zip"&gt;devzone.nordicsemi.com/.../1778.prg.zip&lt;/a&gt;I am also running v2.5.0. I do not think the problem is the k_sleep as I initially had it without and tested it using k_sleep to see if the problem would disappear, actually left it inside of the code.&lt;br /&gt;&lt;br /&gt;I attached my current program to this reply&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assertion failed error during bt_scan_stop</title><link>https://devzone.nordicsemi.com/thread/459670?ContentTypeID=1</link><pubDate>Mon, 11 Dec 2023 11:29:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84fe1c18-c978-4099-9824-bee28051e1a3</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Which SDK are you testing this on?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is it possible that this is caused by the k_sleep in the timer callback?&lt;/p&gt;
&lt;p&gt;I am not able to reproduce this in the NCSv2.5.0 with your code snippet. If you have tested this with the latest SDK version then, can you please attach your minimalistic project for me to test?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assertion failed error during bt_scan_stop</title><link>https://devzone.nordicsemi.com/thread/459666?ContentTypeID=1</link><pubDate>Mon, 11 Dec 2023 11:01:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b091070f-280f-491e-812c-31023d461d87</guid><dc:creator>TLiem</dc:creator><description>&lt;p&gt;I did a bit more testing and I removed stop_scanning(), afterwards I get the same issue when trying to use bt_le_adv_start. No, timers should be running during these actions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>