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.
7 years, 12 months ago.
NRF_52 DK notification events don't fire on the master, when peripheral data changes.
I have two NRF52_DK boards and one is configured to be peripheral and the other as the central. The peripheral supports both read and notification mechanisms to read data. However from the central I am able to read from the peripheral, but the central don't receive notifications when data is updated by the peripheral BLE device.
Is there anything additional I have to implement in order to support for notifications, other than subscribing to the notification event in the central and enabling notifications in the peripheral.
I receive notifications when I connect to the peripheral from my IPhone.
Thanks, Yogesh
Question relating to:
1 Answer
7 years, 11 months ago.
Most probably HRS client (central ) doesn't enabled notification. It should dose that on HRS discover completed event. How you had assembled HRS central app? - did you used service implementation from mbed-os? I see lack of implementation of the enabling notification on central side in mbed :(.
Hi Andrez,
I have a custom BLE service running on my peripheral and a custom central application which registers to listen to the Notification events. I know the notifications are firing from my peripheral applications, because on my IPhone I can see the notifications show up with the right data. However on my master even though I have subscribed to the event the event never fires, so I have to do an explicit read every few seconds.
Here is the piece of code that subscribes to the event on BLE Init complete.
OnBleInitComplete
void BleMaster::OnBleInitComplete(BLE::InitializationCompleteCallbackContext *params) { BLE& ble = params->ble; ble_error_t error = params->error; if (error != BLE_ERROR_NONE) { OnBleInitError(ble, error); return; } /* Ensure that it is the default instance of BLE */ if (ble.getInstanceID() != BLE::DEFAULT_INSTANCE) { return; } ble.gap().onDisconnection(this, &BleMaster::OnBleDisconnection); ble.gap().onConnection(this, &BleMaster::OnBleConnection); ble.gattClient().onDataRead(&BleMaster::OnSensorRead); //subscribing to notifications. ble.gattClient().onHVX(&BleMaster::OnSensorDataChanged); }
Thanks, Yogesh
posted by 02 Jan 2017You need to enable notification from central side. See code of HRS central collector form nRF5 SDk v11 http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v11.0.0%2Fble_sdk_app_hrc.html&cp=4_0_3_4_2_0_0, start point is man.c line 651 f. ble_hrs_c_hrm_notif_enable(...
posted by 03 Jan 2017Thanks Andrzej for your response. I went thru' the code, and Isn't the below piece of code supposed to have done what is being done in the heart rate client example. I was thinking the mbed BLE API abstracts the need to directly use the softdevice api's to enable notifications based on the platform the BLE API is built on top of, in this case being NRF52_DK?
//subscribing to notifications. ble.gattClient().onHVX(&BleMaster::OnSensorDataChanged);
Thanks, Yogesh
posted by 04 Jan 2017