20#warning "These services are deprecated and will be removed. Please see services.md for details about replacement services."
22#ifndef __BLE_LINK_LOSS_SERVICE_H__
23#define __BLE_LINK_LOSS_SERVICE_H__
27#include "ble/GattServer.h"
29#if BLE_FEATURE_GATT_SERVER
46 typedef void (* callback_t)(AlertLevel_t level);
58 alertLevelChar(
GattCharacteristic::UUID_ALERT_LEVEL_CHAR, reinterpret_cast<uint8_t *>(&alertLevel)) {
59 static bool serviceAdded =
false;
67 ble.gattServer().addService(linkLossService);
70 ble.gap().setEventHandler(
this);
78 callback = newCallback;
85 alertLevel = newLevel;
97 alertLevel = *
reinterpret_cast<const AlertLevel_t *
>(params->
data);
102 if (alertLevel != NO_ALERT) {
103 callback(alertLevel);
109 AlertLevel_t alertLevel;
Representation of a GattServer characteristic.
GattAttribute::Handle_t getValueHandle() const
Get the characteristic's value attribute handle in the ATT table.
Representation of a GattServer service.
@ UUID_LINK_LOSS_SERVICE
UUID of the Link Loss service.
This service defines behavior when a link is lost between two devices.
void onDisconnectionComplete(const ble::DisconnectionCompleteEvent &) override
Called when a connection has been disconnected.
void setAlertLevel(AlertLevel_t newLevel)
Update alertness level.
void setCallback(callback_t newCallback)
Update the callback.
LinkLossService(BLE &bleIn, callback_t callbackIn, AlertLevel_t levelIn=NO_ALERT)
virtual void onDataWritten(const GattWriteCallbackParams *params)
This callback allows receiving updates to the AlertLevel characteristic.
Helper class that represents a readable and writable GattCharacteristic.
Abstract away BLE-capable radio transceivers or SOCs.
Entry namespace for all BLE API definitions.
GATT Write event definition.
const uint8_t * data
Pointer to the data to write.
GattAttribute::Handle_t handle
Handle of the attribute to which the write operation applies.
Event produced when a disconnection is complete.
Definition of the general handler of Gap related events.