This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

how to run main loop parallel with nrf_ble_scan event

Hi Nordic Team,

I have one doubt which I can not able to understand.

Actually in my code I'm scanning some ble devices also in main infinite loop I'm reading some sensor data, my problem is when nrf device scan the other devices it goes to main loop after so long, I also run app_timer_start before main loop as I also counting the ticks, so in my code when there is no device to scan it goes to loop immediately and get the sensor data, but when I switch on the other devices and my devices scans these devices then it goes to main loop randomly like some time systick count is 30 sometimes it is beyond 200 so why it is happening like that. Is there any way so that it scan the devices as well as it also goes to the main loop.

Thanks in advance.

Any help will be highly appreciated.

Parents Reply Children
  • Hi Kenneth,

    I'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 BLE_GAP_EVT_ADV_REPORT case I have used for loop also to run buzzer for long time now I've reduced the for loop value and now it is going to main loop as well. 

    And get_System_ticks() I'm calling in BLE_GAP_EVT_ADV_REPORT, I'm not calling it in main file

    Now my code is working but still I've one doubt that why it was not going to main loop when there is for loop used in BLE_GAP_EVT_ADV_REPORT with more value as I've used for buzzer here, and when I reduced to less value, now it is going in main loop.

    Thanks.

  • Good that you found the problem. This looks like normal debugging and development, you just have to work through it.

    Kenneth

Related