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

alternatives: runtime initialization of the context pointer in NRF_SDH_BLE_OBSERVER()

NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, pContext );


evidently I register here a callback "ble_evt_handler" to the softdevice for ble events. additionally, i expect the callback "ble_evt_handler"
to provide me back the context provider that i set here.

However, "pContext", in my case, is a dynamic-location that of-course is available only during the run-time. As is already documented,
the above macro-call is initialized only at the link-time; with the consequence that the "ble_evt_handler" always returns a "null"
"pContext" pointer in my case.


It doesn't help that in my linker descriptor file, i locate the above section to the RAM region i.e.,
  .sdh_ble_observers :
  {
    PROVIDE(__start_sdh_ble_observers = .);
    KEEP(*(SORT(.sdh_ble_observers*)))
    PROVIDE(__stop_sdh_ble_observers = .);
  } > RAM

} INSERT AFTER .data;


Is there an official (or for that matter an non-official) workaround for this? (apart from using global/static variables) 
I would really appreciate some suggestions.

Related