9 years 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:

  1. include "nrf_soc.h"
  2. 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:

Bluetooth Low Energy (a.k.a Bluetooth LE, BTLE, Bluetooth Smart)

1 Answer

9 years 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.

Accepted Answer

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 Wayne Keenan 07 Apr 2015

onRadioNotification() callback will be coming to BLE_API with the next release (hopefully next week).

posted by Rohit Grover 10 Apr 2015

Hi Rohit, is mbed's radio notification actually working on the nRF51822 stack? It looks like it's never called. If not, is there any method to detect when the CPU is about to be taken over by the stack?

posted by Szabolcs Székelyi 05 Dec 2016