Lightly modified version of the BLE stack, that doesn't bring up a DFUService by default... as we have our own.
Fork of BLE_API by
Revision 341:8a104d9d80c1, committed 2015-04-15
- Comitter:
- rgrover1
- Date:
- Wed Apr 15 09:05:11 2015 +0100
- Parent:
- 340:c7684a5bc2e1
- Child:
- 342:152bd9c825d6
- Child:
- 403:f24e0ea73138
- Commit message:
- Synchronized with git rev 8b631fc0
Author: Rohit Grover
Release 0.3.2
=============
Enhancements
~~~~~~~~~~~~
* Add new API: onRadioNotification(). 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 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.
* merge contents of several .cpp files under common/* into .h files under public/*.
e.g. GattService, GapAdvertisingData, UUID.
* Add a note to the documentation for setAdvertisingInterval() to warn users
about the new units for 'interval'.
* get rid of a few deprecated APIs: setAdvertisingData() and startAdvertising().
Bugfixes
~~~~~~~~
none.
Changed in this revision
public/BLEDevice.h | Show annotated file Show diff for this revision Revisions of this file |
public/Gap.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/public/BLEDevice.h Wed Apr 15 09:05:11 2015 +0100 +++ b/public/BLEDevice.h Wed Apr 15 09:05:11 2015 +0100 @@ -301,6 +301,24 @@ 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); + + /** * Add a service declaration to the local server ATT table. Also add the * characteristics contained within. */ @@ -650,6 +668,12 @@ transport->getGattServer().setOnConfirmationReceived(callback); } +inline void +BLEDevice::onRadioNotification(Gap::RadioNotificationEventCallback_t callback) +{ + transport->getGap().setOnRadioNotification(callback); +} + inline ble_error_t BLEDevice::addService(GattService &service) {
--- a/public/Gap.h Wed Apr 15 09:05:11 2015 +0100 +++ b/public/Gap.h Wed Apr 15 09:05:11 2015 +0100 @@ -79,6 +79,7 @@ typedef void (*EventCallback_t)(void); typedef void (*ConnectionEventCallback_t)(Handle_t, addr_type_t peerAddrType, const address_t peerAddr, const ConnectionParams_t *); typedef void (*DisconnectionEventCallback_t)(Handle_t, DisconnectionReason_t); + typedef void (*RadioNotificationEventCallback_t) (bool radio_active); /* gets passed true for ACTIVE; false for INACTIVE. */ friend class BLEDevice; private: @@ -114,6 +115,13 @@ void setOnDisconnection(DisconnectionEventCallback_t callback) {onDisconnection = callback;} /** + * Set the application callback for radio-notification events. + * @param callback + * Handler to be executed in resonse to a radio notification event. + */ + virtual void setOnRadioNotification(RadioNotificationEventCallback_t callback) {onRadioNotification = callback;} + + /** * Append to a chain of callbacks to be invoked upon disconnection; these * callbacks receive no context and are therefore different from the * onDisconnection callback. @@ -135,7 +143,7 @@ protected: /* Default constructor. */ - Gap() : state(), onTimeout(NULL), onConnection(NULL), onDisconnection(NULL), disconnectionCallChain() { + Gap() : state(), onTimeout(NULL), onConnection(NULL), onDisconnection(NULL), onRadioNotification(), disconnectionCallChain() { /* empty */ } @@ -175,6 +183,7 @@ EventCallback_t onTimeout; ConnectionEventCallback_t onConnection; DisconnectionEventCallback_t onDisconnection; + RadioNotificationEventCallback_t onRadioNotification; CallChain disconnectionCallChain; private: