handle Gap::onRadioNotification()

This commit is contained in:
Rohit Grover 2015-06-18 20:41:43 +01:00
parent 183665a01b
commit db2de9114e
2 changed files with 42 additions and 28 deletions

View file

@ -1105,6 +1105,31 @@ public:
gap().addToDisconnectionCallChain(tptr, mptr);
}
/**
* Radio Notification is a feature that enables ACTIVE and INACTIVE
* (nACTIVE) signals from the stack that notify the application when the
* radio is in use. The signal is sent using software interrupt.
*
* The ACTIVE signal is sent before the Radio Event starts. The nACTIVE
* signal is sent at the end of the Radio Event. These signals can be used
* by the application programmer to synchronize application logic with radio
* activity. For example, the ACTIVE signal can be used to shut off external
* devices to manage peak current drawn during periods when the radio is on,
* or to trigger sensor data collection for transmission in the Radio Event.
*
* @param callback
* The application handler to be invoked in response to a radio
* ACTIVE/INACTIVE event.
*
* @note: This API is now *deprecated* and will be dropped in the future.
* You should use the parallel API from GattServer directly. A former call
* to ble.onRadioNotification(...) should be replaced with
* ble.gap().onRadioNotification(...).
*/
void onRadioNotification(Gap::RadioNotificationEventCallback_t callback) {
gap().onRadioNotification(callback);
}
/**
* Add a callback for the GATT event DATA_SENT (which is triggered when
* updates are sent out by GATT in the form of notifications).
@ -1159,24 +1184,6 @@ public:
void onUpdatesDisabled(GattServer::EventCallback_t callback);
void onConfirmationReceived(GattServer::EventCallback_t callback);
/**
* Radio Notification is a feature that enables ACTIVE and INACTIVE
* (nACTIVE) signals from the stack that notify the application when the
* radio is in use. The signal is sent using software interrupt.
*
* The ACTIVE signal is sent before the Radio Event starts. The nACTIVE
* signal is sent at the end of the Radio Event. These signals can be used
* by the application programmer to synchronize application logic with radio
* activity. For example, the ACTIVE signal can be used to shut off external
* devices to manage peak current drawn during periods when the radio is on,
* or to trigger sensor data collection for transmission in the Radio Event.
*
* @param callback
* The application handler to be invoked in response to a radio
* ACTIVE/INACTIVE event.
*/
void onRadioNotification(Gap::RadioNotificationEventCallback_t callback);
public:
BLE() : transport(createBLEInstance()) {
/* empty */
@ -1240,12 +1247,6 @@ BLE::onConfirmationReceived(GattServer::EventCallback_t callback)
transport->getGattServer().setOnConfirmationReceived(callback);
}
inline void
BLE::onRadioNotification(Gap::RadioNotificationEventCallback_t callback)
{
gap().setOnRadioNotification(callback);
}
inline ble_error_t
BLE::initializeSecurity(bool enableBonding,
bool requireMITM,

View file

@ -784,10 +784,23 @@ public:
/**
* Set the application callback for radio-notification events.
*
* Radio Notification is a feature that enables ACTIVE and INACTIVE
* (nACTIVE) signals from the stack that notify the application when the
* radio is in use. The signal is sent using software interrupt.
*
* The ACTIVE signal is sent before the Radio Event starts. The nACTIVE
* signal is sent at the end of the Radio Event. These signals can be used
* by the application programmer to synchronize application logic with radio
* activity. For example, the ACTIVE signal can be used to shut off external
* devices to manage peak current drawn during periods when the radio is on,
* or to trigger sensor data collection for transmission in the Radio Event.
*
* @param callback
* Handler to be executed in response to a radio notification event.
* The application handler to be invoked in response to a radio
* ACTIVE/INACTIVE event.
*/
virtual void setOnRadioNotification(RadioNotificationEventCallback_t callback) {onRadioNotification = callback;}
virtual void onRadioNotification(RadioNotificationEventCallback_t callback) {radioNotificationCallback = callback;}
/**
* To indicate that security procedure for link has started.
@ -828,7 +841,7 @@ protected:
timeoutCallback(NULL),
connectionCallback(NULL),
disconnectionCallback(NULL),
onRadioNotification(),
radioNotificationCallback(),
onSecuritySetupInitiated(),
onSecuritySetupCompleted(),
onLinkSecured(),
@ -927,7 +940,7 @@ protected:
TimeoutEventCallback_t timeoutCallback;
ConnectionEventCallback_t connectionCallback;
DisconnectionEventCallback_t disconnectionCallback;
RadioNotificationEventCallback_t onRadioNotification;
RadioNotificationEventCallback_t radioNotificationCallback;
SecuritySetupInitiatedCallback_t onSecuritySetupInitiated;
SecuritySetupCompletedCallback_t onSecuritySetupCompleted;
LinkSecuredCallback_t onLinkSecured;