Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 7 months ago.
How to detect when the radio on the nrf51822 is (in)active - linking issue / API usage.
I need to execute a critical section of code on a nrf51822 when a BLE connection is active.
Non-IRQ strategies to achieve this (as application IRQ's have a lower priority than the radio, as I understand it) is to detect when the radio is not being used by using one of 2 methods:
1. registering a handler to be told when the radio has become inactive or 2. registering a handler with a 'distance' (really time) parameter to be notified of x milli-secs /before/ the radio will become active.
I'm currently attempting method 2...
I've found this example code: https://devzone.nordicsemi.com/question/15121/radio-notification-only-after-ble-radio/
After adding that and the following includes my application compiles:
- include "nrf_soc.h"
- include "ble_radio_notification.h"
However, linking fails:
Error: Undefined symbol ble_radio_notification_init(unsigned char, unsigned char, void(*)(bool)) (referred from main.cpp.NRF51822_OTA.o).
Is there anything I can do to get it to link?
On other approaches (e.g. method 1 and/or hooking into the existing mbed nrf51822 BLE API stack) I've been thru the nrf51822 and BLE_API libs, and landed up at : nRF51GattServer::hwCallback but I don't think this is going to get the low level softdevice radio events.
Does anyone have any pointers please?
Thanks Wayne
Question relating to:
1 Answer
9 years, 7 months ago.
You would need to include the following from the NordicSDK components/ble/ble_radio_notification/ble_radio_notification.[hc] into your project. Note, if you're building against mbed-src, you'll need to get your sources from v7.1 of the Nordic SDK.
brilliant, thank you Rohit.
For those that may follow...
I am using mbed-src.
I imported just the .c into my project and renamed it .cpp (wouldn't compile otherwise), the .h is already in the lib deps.
I altered the priority in radio_notification_init() from NRF_APP_PRIORITY_LOW to NRF_APP_PRIORITY_HIGH
I had no joy using any 'distance' settings other than NRF_RADIO_NOTIFICATION_DISTANCE_NONE
That worked for me(tm)
thanks again, all the best, Wayne.
posted by 07 Apr 2015