NimBLE-Arduino 1.4.2
Loading...
Searching...
No Matches
NimBLERemoteService Class Reference

A model of a remote BLE service. More...

#include <NimBLERemoteService.h>

Public Member Functions

virtual ~NimBLERemoteService ()
 When deleting the service make sure we delete all characteristics and descriptors.
 
std::vector< NimBLERemoteCharacteristic * >::iterator begin ()
 Get iterator to the beginning of the vector of remote characteristic pointers. More...
 
std::vector< NimBLERemoteCharacteristic * >::iterator end ()
 Get iterator to the end of the vector of remote characteristic pointers. More...
 
NimBLERemoteCharacteristicgetCharacteristic (const char *uuid)
 Get the remote characteristic object for the characteristic UUID. More...
 
NimBLERemoteCharacteristicgetCharacteristic (const NimBLEUUID &uuid)
 Get the characteristic object for the UUID. More...
 
void deleteCharacteristics ()
 Delete the characteristics in the characteristics vector. More...
 
size_t deleteCharacteristic (const NimBLEUUID &uuid)
 Delete characteristic by UUID. More...
 
NimBLEClientgetClient (void)
 Get the client associated with this service. More...
 
NimBLEUUID getUUID (void)
 Get the service UUID.
 
std::string getValue (const NimBLEUUID &characteristicUuid)
 Read the value of a characteristic associated with this service. More...
 
bool setValue (const NimBLEUUID &characteristicUuid, const std::string &value)
 Set the value of a characteristic. More...
 
std::string toString (void)
 Create a string representation of this remote service. More...
 
std::vector< NimBLERemoteCharacteristic * > * getCharacteristics (bool refresh=false)
 Get a pointer to the vector of found characteristics. More...
 

Detailed Description

A model of a remote BLE service.

Member Function Documentation

◆ begin()

std::vector< NimBLERemoteCharacteristic * >::iterator NimBLERemoteService::begin ( )

Get iterator to the beginning of the vector of remote characteristic pointers.

Returns
An iterator to the beginning of the vector of remote characteristic pointers.

◆ deleteCharacteristic()

size_t NimBLERemoteService::deleteCharacteristic ( const NimBLEUUID uuid)

Delete characteristic by UUID.

Parameters
[in]uuidThe UUID of the characteristic to be removed from the local database.
Returns
Number of characteristics left.

◆ deleteCharacteristics()

void NimBLERemoteService::deleteCharacteristics ( )

Delete the characteristics in the characteristics vector.

We maintain a vector called m_characteristicsVector that contains pointers to BLERemoteCharacteristic object references. Since we allocated these in this class, we are also responsible for deleting them. This method does just that.

◆ end()

std::vector< NimBLERemoteCharacteristic * >::iterator NimBLERemoteService::end ( )

Get iterator to the end of the vector of remote characteristic pointers.

Returns
An iterator to the end of the vector of remote characteristic pointers.

◆ getCharacteristic() [1/2]

NimBLERemoteCharacteristic * NimBLERemoteService::getCharacteristic ( const char *  uuid)

Get the remote characteristic object for the characteristic UUID.

Parameters
[in]uuidRemote characteristic uuid.
Returns
A pointer to the remote characteristic object.

◆ getCharacteristic() [2/2]

NimBLERemoteCharacteristic * NimBLERemoteService::getCharacteristic ( const NimBLEUUID uuid)

Get the characteristic object for the UUID.

Parameters
[in]uuidCharacteristic uuid.
Returns
A pointer to the characteristic object, or nullptr if not found.

◆ getCharacteristics()

std::vector< NimBLERemoteCharacteristic * > * NimBLERemoteService::getCharacteristics ( bool  refresh = false)

Get a pointer to the vector of found characteristics.

Parameters
[in]refreshIf true the current characteristics vector will cleared and all characteristics for this service retrieved from the peripheral. If false the vector will be returned with the currently stored characteristics of this service.
Returns
A pointer to the vector of descriptors for this characteristic.

◆ getClient()

NimBLEClient * NimBLERemoteService::getClient ( void  )

Get the client associated with this service.

Returns
A reference to the client associated with this service.

◆ getValue()

std::string NimBLERemoteService::getValue ( const NimBLEUUID characteristicUuid)

Read the value of a characteristic associated with this service.

Parameters
[in]characteristicUuidThe characteristic to read.
Returns
a string containing the value or an empty string if not found or error.

◆ setValue()

bool NimBLERemoteService::setValue ( const NimBLEUUID characteristicUuid,
const std::string &  value 
)

Set the value of a characteristic.

Parameters
[in]characteristicUuidThe characteristic to set.
[in]valueThe value to set.
Returns
true on success, false if not found or error

◆ toString()

std::string NimBLERemoteService::toString ( void  )

Create a string representation of this remote service.

Returns
A string representation of this remote service.