esp-nimble-cpp 2.0.2
|
The model of a BLE service. More...
#include <NimBLEService.h>
Inherits NimBLELocalAttribute.
Public Member Functions | |
NimBLEService (const char *uuid) | |
Construct an instance of the NimBLEService. | |
NimBLEService (const NimBLEUUID &uuid) | |
Construct an instance of the BLEService. | |
~NimBLEService () | |
Destructor, make sure we release the resources allocated for the service. | |
NimBLEServer * | getServer () const |
Get the BLE server associated with this service. | |
std::string | toString () const |
Return a string representation of this service. A service is defined by: | |
void | dump () const |
Dump details of this BLE GATT service. | |
bool | isStarted () const |
Checks if the service has been started. | |
bool | start () |
Builds the database of characteristics/descriptors for the service and registers it with the NimBLE stack. | |
NimBLECharacteristic * | createCharacteristic (const char *uuid, uint32_t properties=NIMBLE_PROPERTY::READ|NIMBLE_PROPERTY::WRITE, uint16_t max_len=BLE_ATT_ATTR_MAX_LEN) |
Create a new BLE Characteristic associated with this service. | |
NimBLECharacteristic * | createCharacteristic (const NimBLEUUID &uuid, uint32_t properties=NIMBLE_PROPERTY::READ|NIMBLE_PROPERTY::WRITE, uint16_t max_len=BLE_ATT_ATTR_MAX_LEN) |
Create a new BLE Characteristic associated with this service. | |
void | addCharacteristic (NimBLECharacteristic *pCharacteristic) |
Add a characteristic to the service. | |
void | removeCharacteristic (NimBLECharacteristic *pCharacteristic, bool deleteChr=false) |
Remove a characteristic from the service. | |
NimBLECharacteristic * | getCharacteristic (const char *uuid, uint16_t instanceId=0) const |
Get a pointer to the characteristic object with the specified UUID. | |
NimBLECharacteristic * | getCharacteristic (const NimBLEUUID &uuid, uint16_t instanceId=0) const |
Get a pointer to the characteristic object with the specified UUID. | |
NimBLECharacteristic * | getCharacteristicByHandle (uint16_t handle) const |
Get a pointer to the characteristic object with the specified handle. | |
const std::vector< NimBLECharacteristic * > & | getCharacteristics () const |
std::vector< NimBLECharacteristic * > | getCharacteristics (const char *uuid) const |
std::vector< NimBLECharacteristic * > | getCharacteristics (const NimBLEUUID &uuid) const |
Public Member Functions inherited from NimBLELocalAttribute | |
uint8_t | getRemoved () const |
Get the removed flag. | |
Public Member Functions inherited from NimBLEAttribute | |
const NimBLEUUID & | getUUID () const |
Get the UUID of the attribute. | |
uint16_t | getHandle () const |
Get the handle of the attribute. | |
Additional Inherited Members | |
Protected Member Functions inherited from NimBLELocalAttribute | |
NimBLELocalAttribute (const NimBLEUUID &uuid, uint16_t handle) | |
Construct a local attribute. | |
~NimBLELocalAttribute ()=default | |
Destroy the local attribute. | |
void | setRemoved (uint8_t removed) |
Set the removed flag. | |
Protected Member Functions inherited from NimBLEAttribute | |
NimBLEAttribute (const NimBLEUUID &uuid, uint16_t handle) | |
Construct a new NimBLEAttribute object. | |
~NimBLEAttribute ()=default | |
Destroy the NimBLEAttribute object. | |
The model of a BLE service.
NimBLEService::NimBLEService | ( | const char * | uuid | ) |
Construct an instance of the NimBLEService.
[in] | uuid | The UUID of the service. |
NimBLEService::NimBLEService | ( | const NimBLEUUID & | uuid | ) |
Construct an instance of the BLEService.
[in] | uuid | The UUID of the service. |
void NimBLEService::addCharacteristic | ( | NimBLECharacteristic * | pChar | ) |
Add a characteristic to the service.
[in] | pChar | A pointer to the characteristic instance to add to the service. |
NimBLECharacteristic * NimBLEService::createCharacteristic | ( | const char * | uuid, |
uint32_t | properties = NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::WRITE , |
||
uint16_t | max_len = BLE_ATT_ATTR_MAX_LEN |
||
) |
Create a new BLE Characteristic associated with this service.
[in] | uuid | - The UUID of the characteristic. |
[in] | properties | - The properties of the characteristic. |
[in] | max_len | - The maximum length in bytes that the characteristic value can hold. |
NimBLECharacteristic * NimBLEService::createCharacteristic | ( | const NimBLEUUID & | uuid, |
uint32_t | properties = NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::WRITE , |
||
uint16_t | max_len = BLE_ATT_ATTR_MAX_LEN |
||
) |
Create a new BLE Characteristic associated with this service.
[in] | uuid | - The UUID of the characteristic. |
[in] | properties | - The properties of the characteristic. |
[in] | max_len | - The maximum length in bytes that the characteristic value can hold. |
NimBLECharacteristic * NimBLEService::getCharacteristic | ( | const char * | uuid, |
uint16_t | idx = 0 |
||
) | const |
Get a pointer to the characteristic object with the specified UUID.
[in] | uuid | The UUID of the characteristic. |
idx | The index of the characteristic to return (used when multiple characteristics have the same UUID). |
NimBLECharacteristic * NimBLEService::getCharacteristic | ( | const NimBLEUUID & | uuid, |
uint16_t | idx = 0 |
||
) | const |
Get a pointer to the characteristic object with the specified UUID.
[in] | uuid | The UUID of the characteristic. |
idx | The index of the characteristic to return (used when multiple characteristics have the same UUID). |
NimBLECharacteristic * NimBLEService::getCharacteristicByHandle | ( | uint16_t | handle | ) | const |
Get a pointer to the characteristic object with the specified handle.
handle | The handle of the characteristic. |
const std::vector< NimBLECharacteristic * > & NimBLEService::getCharacteristics | ( | ) | const |
std::vector< NimBLECharacteristic * > NimBLEService::getCharacteristics | ( | const char * | uuid | ) | const |
std::vector< NimBLECharacteristic * > NimBLEService::getCharacteristics | ( | const NimBLEUUID & | uuid | ) | const |
NimBLEServer * NimBLEService::getServer | ( | ) | const |
Get the BLE server associated with this service.
bool NimBLEService::isStarted | ( | ) | const |
Checks if the service has been started.
void NimBLEService::removeCharacteristic | ( | NimBLECharacteristic * | pChar, |
bool | deleteChr = false |
||
) |
Remove a characteristic from the service.
[in] | pChar | A pointer to the characteristic instance to remove from the service. |
[in] | deleteChr | If true it will delete the characteristic instance and free it's resources. |
bool NimBLEService::start | ( | ) |
Builds the database of characteristics/descriptors for the service and registers it with the NimBLE stack.
std::string NimBLEService::toString | ( | ) | const |
Return a string representation of this service. A service is defined by: