NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
NimBLECharacteristicCallbacks Class Reference

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

#include <NimBLECharacteristic.h>

Public Member Functions

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

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 Function Documentation

◆ onRead()

void NimBLECharacteristicCallbacks::onRead ( NimBLECharacteristic pCharacteristic,
NimBLEConnInfo connInfo 
)
virtual

Callback function to support a read request.

Parameters
[in]pCharacteristicThe characteristic that is the source of the event.
[in]connInfoA reference to a NimBLEConnInfo instance containing the peer info.

◆ onStatus()

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

Callback function to support a Notify/Indicate Status report.

Parameters
[in]pCharacteristicThe characteristic that is the source of the event.
[in]codeStatus return code from the NimBLE stack.

The status code for success is 0 for notifications and BLE_HS_EDONE for indications, any other value is an error.

◆ onSubscribe()

void NimBLECharacteristicCallbacks::onSubscribe ( NimBLECharacteristic pCharacteristic,
NimBLEConnInfo connInfo,
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]connInfoA reference to a NimBLEConnInfo instance containing the peer info.
[in]subValueThe subscription status:
  • 0 = Un-Subscribed
  • 1 = Notifications
  • 2 = Indications
  • 3 = Notifications and Indications

◆ onWrite()

void NimBLECharacteristicCallbacks::onWrite ( NimBLECharacteristic pCharacteristic,
NimBLEConnInfo connInfo 
)
virtual

Callback function to support a write request.

Parameters
[in]pCharacteristicThe characteristic that is the source of the event.
[in]connInfoA reference to a NimBLEConnInfo instance containing the peer info.