BLE LinkLossService: use new EventHandler API to handle disconnection

pull/12730/head
Lingkai Dong 2020-04-01 11:46:47 +01:00
parent eba5821fd8
commit 7ce73d414e
1 changed files with 4 additions and 3 deletions

View File

@ -27,7 +27,8 @@
* Service: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.link_loss.xml
* Alertness Level Char: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.alert_level.xml
*/
class LinkLossService {
class LinkLossService : public ble::Gap::EventHandler
{
public:
enum AlertLevel_t {
NO_ALERT = 0,
@ -59,7 +60,7 @@ public:
ble.gattServer().addService(linkLossService);
serviceAdded = true;
ble.gap().onDisconnection(this, &LinkLossService::onDisconnectionFilter);
ble.gap().setEventHandler(this);
ble.gattServer().onDataWritten(this, &LinkLossService::onDataWritten);
}
@ -90,7 +91,7 @@ protected:
}
}
void onDisconnectionFilter(const Gap::DisconnectionCallbackParams_t *params) {
virtual void onDisconnectionComplete(const ble::DisconnectionCompleteEvent &) {
if (alertLevel != NO_ALERT) {
callback(alertLevel);
}