I'm using SDK1.3 on a nRF52840 and running BLE on it. I'm using FreeRTOS under it and specifically non-preemptive scheduling. From time to time I do a scan using a filter of the names.
I've got a bug that acts more like a stack overrun (it isn't as far as I can tell) with some wild things happening when I have a LOT (like 40) of things that I'm searching for in the space. If I have only a few things I'm looking for in the space, things are working fine. I get callbacks from the SD that basically are giving me things like BLE_GAP_EVT_ADV_REPORT or (further downstream) NRF_BLE_SCAN_EVT_FILTER_MATCH which I'm catching and dealing with.
This is all coming back from a setup line:
NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
where ble_evt_handler() sorts out a bunch of stuff... Once we have the thing actually scanning it's sending back things through some other callbacks set up from the SDK calls.
So my question here is one of reentrancy and how these callbacks are actually working:
*) These are eventually being called by the soft device but I don't know in what context... Are these essentially ISR level calls being made from the SD so that they are preemptive (i,.e. if I'm in the callbacks too long I'm going to get overrun by another)?
*) Can I use semaphores inside those callbacks so that I can hold off calls that are happening too often?
*) Can these callbacks in fact be overlapped or does the SD itself wait till it all comes back to it before sending another one?
Just asking questions to clarify my understanding of context here so I can go figure out what I need to do to defend myself...