esp-nimble-cpp  1.4.1
NimBLECharacteristicCallbacks Class Reference

Callbacks that can be associated with a BLE characteristic to inform of events. More...

Public Types

enum  Status
 An enum to provide the callback the status of the notification/indication, implemented for backward compatibility. More...
 

Public Member Functions

virtual void onRead (NimBLECharacteristic *pCharacteristic)
 Callback function to support a read request. More...
 
virtual void onRead (NimBLECharacteristic *pCharacteristic, ble_gap_conn_desc *desc)
 Callback function to support a read request. More...
 
virtual void onWrite (NimBLECharacteristic *pCharacteristic)
 Callback function to support a write request. More...
 
virtual void onWrite (NimBLECharacteristic *pCharacteristic, ble_gap_conn_desc *desc)
 Callback function to support a write request. More...
 
virtual void onNotify (NimBLECharacteristic *pCharacteristic)
 Callback function to support a Notify request. More...
 
virtual void onStatus (NimBLECharacteristic *pCharacteristic, Status s, int code)
 Callback function to support a Notify/Indicate Status report. More...
 
virtual void onSubscribe (NimBLECharacteristic *pCharacteristic, ble_gap_conn_desc *desc, uint16_t subValue)
 Callback function called when a client changes subscription status. More...
 

Detailed Description

Callbacks that can be associated with a BLE characteristic to inform of events.

When a server application creates a BLE characteristic, we may wish to be informed when there is either a read or write request to the characteristic's value. An application can register a sub-classed instance of this class and will be notified when such an event happens.

Member Enumeration Documentation

◆ Status

An enum to provide the callback the status of the notification/indication, implemented for backward compatibility.

Deprecated:
To be removed in the future as the NimBLE stack return code is also provided.

Member Function Documentation

◆ onNotify()

void NimBLECharacteristicCallbacks::onNotify ( NimBLECharacteristic pCharacteristic)
virtual

Callback function to support a Notify request.

Parameters
[in]pCharacteristicThe characteristic that is the source of the event.

◆ onRead() [1/2]

void NimBLECharacteristicCallbacks::onRead ( NimBLECharacteristic pCharacteristic)
virtual

Callback function to support a read request.

Parameters
[in]pCharacteristicThe characteristic that is the source of the event.

◆ onRead() [2/2]

void NimBLECharacteristicCallbacks::onRead ( NimBLECharacteristic pCharacteristic,
ble_gap_conn_desc *  desc 
)
virtual

Callback function to support a read request.

Parameters
[in]pCharacteristicThe characteristic that is the source of the event.
[in]descThe connection description struct that is associated with the peer that performed the read.

◆ onStatus()

void NimBLECharacteristicCallbacks::onStatus ( NimBLECharacteristic pCharacteristic,
Status  s,
int  code 
)
virtual

Callback function to support a Notify/Indicate Status report.

Parameters
[in]pCharacteristicThe characteristic that is the source of the event.
[in]sStatus of the notification/indication.
[in]codeAdditional return code from the NimBLE stack.

◆ onSubscribe()

void NimBLECharacteristicCallbacks::onSubscribe ( NimBLECharacteristic pCharacteristic,
ble_gap_conn_desc *  desc,
uint16_t  subValue 
)
virtual

Callback function called when a client changes subscription status.

Parameters
[in]pCharacteristicThe characteristic that is the source of the event.
[in]descThe connection description struct that is associated with the client.
[in]subValueThe subscription status:
  • 0 = Un-Subscribed
  • 1 = Notifications
  • 2 = Indications
  • 3 = Notifications and Indications

◆ onWrite() [1/2]

void NimBLECharacteristicCallbacks::onWrite ( NimBLECharacteristic pCharacteristic)
virtual

Callback function to support a write request.

Parameters
[in]pCharacteristicThe characteristic that is the source of the event.

◆ onWrite() [2/2]

void NimBLECharacteristicCallbacks::onWrite ( NimBLECharacteristic pCharacteristic,
ble_gap_conn_desc *  desc 
)
virtual

Callback function to support a write request.

Parameters
[in]pCharacteristicThe characteristic that is the source of the event.
[in]descThe connection description struct that is associated with the peer that performed the write.