<?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>Bluetooth callback is not called occasionally in multi-threaded application</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/94922/bluetooth-callback-is-not-called-occasionally-in-multi-threaded-application</link><description>Hi team, 
 I am using nRFConnect SDK v2.2.0, and developing multi-threaded application which has BLE and ethernet. 
 I had three thread, each has the same priority of 7. 
 The first one is BLE central thread, and starting scan and connect, send/receive</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 19 Dec 2022 16:17:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/94922/bluetooth-callback-is-not-called-occasionally-in-multi-threaded-application" /><item><title>RE: Bluetooth callback is not called occasionally in multi-threaded application</title><link>https://devzone.nordicsemi.com/thread/401332?ContentTypeID=1</link><pubDate>Mon, 19 Dec 2022 16:17:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37abda3c-f699-4ca7-a265-daffac61f4a8</guid><dc:creator>choehyunho</dc:creator><description>&lt;p&gt;Understood.&lt;/p&gt;
&lt;p&gt;I may need to review&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/others/app_event_manager.html#application-event-manager"&gt;Application Event Manager&lt;/a&gt;&amp;nbsp;module to integrate various system components with BLE.&lt;/p&gt;
&lt;p&gt;Thanks for your support.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth callback is not called occasionally in multi-threaded application</title><link>https://devzone.nordicsemi.com/thread/401187?ContentTypeID=1</link><pubDate>Mon, 19 Dec 2022 08:26:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6313633f-f6aa-4d5b-b9ce-14720f6b6829</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="choehyunho"]Should I avoid triggering BLE in system workqueue?[/quote]
&lt;p&gt;The BLE stack also uses system workqueue so it might be possible that we are seeing some kind of race condition here. Even though it is not disallowed to use system queues to trigger BLe activity in system queue, to have a predictable behavior, I strongly susggest that you define your own thread and its own priority for the workqueue you are using.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth callback is not called occasionally in multi-threaded application</title><link>https://devzone.nordicsemi.com/thread/401134?ContentTypeID=1</link><pubDate>Sat, 17 Dec 2022 11:42:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20c8ca36-addf-43ab-adfc-b5eddaacc7bb</guid><dc:creator>choehyunho</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;Thanks for your reply.&lt;/p&gt;
&lt;p&gt;I have tested more about this issue, and it seems to be related to thread priority.&lt;/p&gt;
&lt;p&gt;When I send signal from k_work, the above symptom is happening very frequently.&lt;/p&gt;
&lt;p&gt;But if I send signal from MQTT thread itself (priority 7), the problem no longer happens.&lt;/p&gt;
&lt;p&gt;Although, my urgent problem was solved, still I want to clarify default NCS thread priority and related settings.&lt;/p&gt;
&lt;p&gt;I reviewed some zephyr configurations, and most BLE thread has priority 6~8.&lt;/p&gt;
&lt;p&gt;And the default priority for system workqueue is -1.&lt;/p&gt;
&lt;p&gt;Is all these may cause problems?&lt;/p&gt;
&lt;p&gt;Should I avoid triggering BLE in system workqueue?&lt;/p&gt;
&lt;p&gt;I want to know what is the best practice about priority configuration in NCS.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth callback is not called occasionally in multi-threaded application</title><link>https://devzone.nordicsemi.com/thread/401046?ContentTypeID=1</link><pubDate>Fri, 16 Dec 2022 12:25:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b1889b8-4a18-483c-86bd-ca85cda4b10f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;Unfortunately, I did not manage to look at this today. I will try to provide you more info on Monday. Thanks for your patience.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>