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

NRF52 BLE scan - Add and Clear the list-of-scanned-ble-variable at the same time

Hi all,

I follow advice here "devzone.nordicsemi.com/.../nrf52832-ble-scan" to do the ble scan, I have question that there is a function to store scanned ble to the list (device_to_list_add) and another function to clear this list (scan_device_info_clear).

Is there a case that these 2 functions are called and modify the list scanned ble varable the same time, because they are called by different sources (scan_evt_handler event triggers device_to_list_add, and adv_list_timer_handle timer trigger scan_device_info_clear)

Thank you.

Parents Reply
  • Hi Jared, sorry for unclear question. I forgot included the sample code for my question.

    To make it clearer, I followed example code here "devzone.nordicsemi.com/.../nrf52832-ble-scan".

    There is a variable named m_device that holds the scanned results. m_device is modified in 2 places (by scan_device_info_clear() (this function is trigger by timer event) and device_to_list_add() (this fucntion is triggered by scan_ble event)). My question is that: is there a case when m_device is modified at the same time by 2 previous functions? How to prevent it if there is a conflict?

    Hope my question is clear now.

    Thank you

Children
Related