Skip to content

Commit

Permalink
add API BLEDevice::shutdown() to purge the BLE stack of GATT and GAP …
Browse files Browse the repository at this point in the history
…state.

init() should be called before restoring state.

fixes #15.
  • Loading branch information
Rohit Grover committed Dec 3, 2014
1 parent ac3a548 commit 7e9f9a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/BLEDeviceInstanceBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class BLEDeviceInstanceBase
virtual Gap& getGap() = 0;
virtual GattServer& getGattServer() = 0;
virtual ble_error_t init(void) = 0;
virtual ble_error_t shutdown(void) = 0;
virtual ble_error_t reset(void) = 0;
virtual ble_error_t setTxPower(int8_t txPower) = 0;
virtual void waitForEvent(void) = 0;
Expand Down
12 changes: 12 additions & 0 deletions public/BLEDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class BLEDevice
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:
/**
Expand Down Expand Up @@ -364,6 +369,13 @@ BLEDevice::reset(void)
return transport->reset();
}

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)
{
Expand Down

0 comments on commit 7e9f9a0

Please sign in to comment.