Improve readability with getHandle inline
Fork of BLE_API by
Diff: public/BLEDevice.h
- Revision:
- 257:6be2b4b0cd71
- Parent:
- 246:aa639ef2f290
--- a/public/BLEDevice.h Tue Dec 02 02:51:52 2014 +0000 +++ b/public/BLEDevice.h Mon Jan 12 14:49:53 2015 -0800 @@ -36,6 +36,11 @@ ble_error_t init(); ble_error_t reset(void); + /** + * Purge the BLE stack of GATT and GAP state. init() must be called afterwards to re-instate services and GAP state. + */ + ble_error_t shutdown(void); + /* GAP specific APIs */ public: /** @@ -211,6 +216,14 @@ void onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback); /** + * Append to a chain of callbacks to be invoked upon disconnection; these + * callbacks receive no context and are therefore different from the + * onDisconnection callback. + */ + template<typename T> + void addToDisconnectionCallChain(T *tptr, void (T::*mptr)(void)); + + /** * Setup a callback for the GATT event DATA_SENT. */ void onDataSent(GattServer::ServerEventCallbackWithCount_t callback); @@ -365,6 +378,13 @@ } inline ble_error_t +BLEDevice::shutdown(void) +{ + clearAdvertisingPayload(); + return transport->shutdown(); +} + +inline ble_error_t BLEDevice::setAddress(Gap::addr_type_t type, const Gap::address_t address) { return transport->getGap().setAddress(type, address); @@ -498,6 +518,12 @@ transport->getGap().setOnDisconnection(disconnectionCallback); } +template<typename T> +inline void +BLEDevice::addToDisconnectionCallChain(T *tptr, void (T::*mptr)(void)) { + transport->getGap().addToDisconnectionCallChain(tptr, mptr); +} + inline void BLEDevice::onDataSent(GattServer::ServerEventCallbackWithCount_t callback) {