<?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>how to run main loop parallel with nrf_ble_scan event</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/74677/how-to-run-main-loop-parallel-with-nrf_ble_scan-event</link><description>Hi Nordic Team, 
 I have one doubt which I can not able to understand. 
 Actually in my code I&amp;#39;m scanning some ble devices also in main infinite loop I&amp;#39;m reading some sensor data, my problem is when nrf device scan the other devices it goes to main loop</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 06 May 2021 09:17:21 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/74677/how-to-run-main-loop-parallel-with-nrf_ble_scan-event" /><item><title>RE: how to run main loop parallel with nrf_ble_scan event</title><link>https://devzone.nordicsemi.com/thread/308488?ContentTypeID=1</link><pubDate>Thu, 06 May 2021 09:17:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:835d439c-7f1d-4d34-ad5b-2e2114b297d5</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Good that you found the problem. This looks like normal debugging and development, you just have to work through it.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to run main loop parallel with nrf_ble_scan event</title><link>https://devzone.nordicsemi.com/thread/308456?ContentTypeID=1</link><pubDate>Thu, 06 May 2021 07:39:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77a70acd-7eaf-4a5c-9aa0-06e5242fd721</guid><dc:creator>PAWAN JOSHI</dc:creator><description>&lt;p&gt;Hi Kenneth,&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve resolved the issue now it is going to main loop as well, actually I was using buzzer as well and in nrf_ble_scan.c file in&amp;nbsp;&lt;span&gt;BLE_GAP_EVT_ADV_REPORT case I have used for loop also to run buzzer for long time now I&amp;#39;ve reduced the for loop value and now it is going to main loop as well.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;And&amp;nbsp;get_System_ticks() I&amp;#39;m calling in&amp;nbsp;BLE_GAP_EVT_ADV_REPORT, I&amp;#39;m not calling it in main&amp;nbsp;file&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Now my code is working but still I&amp;#39;ve one doubt that why it was not going to main loop when there is for loop used in&amp;nbsp;BLE_GAP_EVT_ADV_REPORT with more value as I&amp;#39;ve used for buzzer here, and when I reduced to less value, now it is going in main loop.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to run main loop parallel with nrf_ble_scan event</title><link>https://devzone.nordicsemi.com/thread/308317?ContentTypeID=1</link><pubDate>Wed, 05 May 2021 09:44:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7119b299-0b6e-45ff-a7eb-d8dcea508115</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I can find you have several while() and do-while() loops that may be problematic. Have you done any debugging into which may be delaying return to main()-loop?&lt;/p&gt;
&lt;p&gt;I can&amp;#39;t really find that where in you application you are reading or output system_ticks? I can find the function&amp;nbsp;get_System_ticks(), but it&amp;#39;s not used anywhere?&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to run main loop parallel with nrf_ble_scan event</title><link>https://devzone.nordicsemi.com/thread/308297?ContentTypeID=1</link><pubDate>Wed, 05 May 2021 08:13:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a364aea7-45db-45f5-906d-20c6e3042d8b</guid><dc:creator>PAWAN JOSHI</dc:creator><description>&lt;p&gt;I&amp;#39;ve debug it several times and it&amp;#39;s not delay it&amp;#39;s timer interrupt through which I&amp;#39;m getting systick.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here I&amp;#39;m uploading my main.c file for your refernece please let me know where I&amp;#39;m doing wrong. as I told I&amp;#39;m reading rtc data from main loop, when there is no other ble device ON it goes to loop and gives the RTC data but when any nrf52840 device is on then serving loop is happening randomly or even after so long it only goes to scan the device.&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/1738.main.c"&gt;devzone.nordicsemi.com/.../1738.main.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to run main loop parallel with nrf_ble_scan event</title><link>https://devzone.nordicsemi.com/thread/308185?ContentTypeID=1</link><pubDate>Tue, 04 May 2021 12:54:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09d60c29-aaf5-471f-a2f0-27a6d6013cfe</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I think you will just have to debug this further. I don&amp;#39;t have any explanation to why you have a 30-200second delay sometimes no, it just doesn&amp;#39;t make sense, sorry.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Maybe take a new look at the central examples.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to run main loop parallel with nrf_ble_scan event</title><link>https://devzone.nordicsemi.com/thread/308124?ContentTypeID=1</link><pubDate>Tue, 04 May 2021 09:54:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98603f55-47c7-4268-901c-f366c5dfcf53</guid><dc:creator>PAWAN JOSHI</dc:creator><description>&lt;p&gt;I&amp;#39;m running app_timer_start with Notification interval of 1000(1 sec), so my systick increments every 1 seconds, by observing the systic only I see that at what seconds it is going to main loop. There are already gpio are working like when it scan those device then leds glow like that.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to run main loop parallel with nrf_ble_scan event</title><link>https://devzone.nordicsemi.com/thread/308082?ContentTypeID=1</link><pubDate>Tue, 04 May 2021 08:08:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c724e8f0-1510-4a74-af38-ef056a2c9b05</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;The only explanation I have is that the handling of&amp;nbsp;&lt;span&gt;BLE_GAP_EVT_ADV_REPORT&amp;nbsp;takes long time? Maybe try to add some gpio toggling to try to find what may be taking time?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But how long is a systick here?&amp;nbsp;Is it ~30us?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kenneth&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to run main loop parallel with nrf_ble_scan event</title><link>https://devzone.nordicsemi.com/thread/308056?ContentTypeID=1</link><pubDate>Tue, 04 May 2021 06:06:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:114a7982-a128-41c8-a02b-d0483da59c8e</guid><dc:creator>PAWAN JOSHI</dc:creator><description>&lt;p&gt;Hi Kenneth,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for the reply, now as you have told about handling&amp;nbsp;&lt;span&gt;BLE_GAP_EVT_ADV_REPORT event, so there only I&amp;#39;m scanning 4 devices I&amp;#39;ve also mentioned there addresses so I don&amp;#39;t think It&amp;#39;s not handling properly.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Now for SCAN_INTERVAL and&amp;nbsp;SCAN_WINDOW I think you are talking about&amp;nbsp;NRF_BLE_SCAN_SCAN_INTERVAL and&amp;nbsp;NRF_BLE_SCAN_SCAN_WINDOW so these values were defined 160 and 80 respectively so as per your suggestion now I changed it to 0x05 but still it&amp;#39;s not going to my main loop to read sensor data. As soon as I just switch off the others ble devices which my current device is scanning it immediately&amp;nbsp;goes to my main loop, so definitely something is stopping or delaying it to going to my main loop.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So I&amp;#39;m still not getting where I&amp;#39;m doing wrong.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to run main loop parallel with nrf_ble_scan event</title><link>https://devzone.nordicsemi.com/thread/307892?ContentTypeID=1</link><pubDate>Mon, 03 May 2021 11:40:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a153fa5-e251-434d-9585-8e2cee41ff99</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I don&amp;#39;t see any reason why this should occur. Looks like you need to look into how you handle the&amp;nbsp;BLE_GAP_EVT_ADV_REPORT events.&lt;/p&gt;
&lt;p&gt;You can try to reduce&amp;nbsp;SCAN_INTERVAL and&amp;nbsp;SCAN_WINDOW both to 0x5 to see if that have any impact on the issue you experience.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>