My Project
Public Member Functions | Static Public Attributes | Friends | List of all members
BLECharacteristic Class Reference

The model of a BLE Characteristic. More...

#include <BLECharacteristic.h>

Public Member Functions

 BLECharacteristic (BLEUUID uuid, uint32_t properties=0)
 Construct a characteristic. More...
 
virtual ~BLECharacteristic ()
 Destructor.
 
void addDescriptor (BLEDescriptor *pDescriptor)
 Associate a descriptor with this characteristic. More...
 
BLEDescriptorgetDescriptorByUUID (BLEUUID descriptorUUID)
 Return the BLE Descriptor for the given UUID if associated with this characteristic. More...
 
BLEUUID getUUID ()
 Get the UUID of the characteristic. More...
 
std::string getValue ()
 Retrieve the current value of the characteristic. More...
 
void indicate ()
 Send an indication. An indication is a transmission of up to the first 20 bytes of the characteristic value. An indication will block waiting a positive confirmation from the client. More...
 
void notify ()
 Send a notify. A notification is a transmission of up to the first 20 bytes of the characteristic value. An notification will not block; it is a fire and forget. More...
 
void setBroadcastProperty (bool value)
 Set the permission to broadcast. A characteristics has properties associated with it which define what it is capable of doing. One of these is the broadcast flag. More...
 
void setCallbacks (BLECharacteristicCallbacks *pCallbacks)
 Set the callback handlers for this characteristic. More...
 
void setIndicateProperty (bool value)
 Set the Indicate property value. More...
 
void setNotifyProperty (bool value)
 Set the Notify property value. More...
 
void setReadProperty (bool value)
 Set the Read property value. More...
 
void setValue (uint8_t *data, size_t size)
 Set the value of the characteristic. More...
 
void setValue (std::string value)
 Set the value of the characteristic from string data. We set the value of the characteristic from the bytes contained in the string. More...
 
void setWriteProperty (bool value)
 Set the Write property value. More...
 
void setWriteNoResponseProperty (bool value)
 Set the Write No Response property value. More...
 
std::string toString ()
 Return a string representation of the characteristic. More...
 

Static Public Attributes

static const uint32_t PROPERTY_READ = 1<<0
 
static const uint32_t PROPERTY_WRITE = 1<<1
 
static const uint32_t PROPERTY_NOTIFY = 1<<2
 
static const uint32_t PROPERTY_BROADCAST = 1<<3
 
static const uint32_t PROPERTY_INDICATE = 1<<4
 
static const uint32_t PROPERTY_WRITE_NR = 1<<5
 

Friends

class BLEServer
 
class BLEService
 
class BLEDescriptor
 
class BLECharacteristicMap
 

Detailed Description

The model of a BLE Characteristic.

A BLE Characteristic is an identified value container that manages a value. It is exposed by a BLE server and can be read and written to by a BLE client.

Constructor & Destructor Documentation

◆ BLECharacteristic()

BLECharacteristic::BLECharacteristic ( BLEUUID  uuid,
uint32_t  properties = 0 
)

Construct a characteristic.

Parameters
[in]uuid- UUID for the characteristic.
[in]properties- Properties for the characteristic.

Member Function Documentation

◆ addDescriptor()

void BLECharacteristic::addDescriptor ( BLEDescriptor pDescriptor)

Associate a descriptor with this characteristic.

Parameters
[in]pDescriptor
Returns
N/A.

◆ getDescriptorByUUID()

BLEDescriptor * BLECharacteristic::getDescriptorByUUID ( BLEUUID  descriptorUUID)

Return the BLE Descriptor for the given UUID if associated with this characteristic.

Parameters
[in]descriptorUUIDThe UUID of the descriptor that we wish to retrieve.
Returns
The BLE Descriptor. If no such descriptor is associated with the characteristic, nullptr is returned.

◆ getUUID()

BLEUUID BLECharacteristic::getUUID ( )

Get the UUID of the characteristic.

Returns
The UUID of the characteristic.

◆ getValue()

std::string BLECharacteristic::getValue ( )

Retrieve the current value of the characteristic.

Returns
A pointer to storage containing the current characteristic value.

◆ indicate()

void BLECharacteristic::indicate ( )

Send an indication. An indication is a transmission of up to the first 20 bytes of the characteristic value. An indication will block waiting a positive confirmation from the client.

Returns
N/A

◆ notify()

void BLECharacteristic::notify ( )

Send a notify. A notification is a transmission of up to the first 20 bytes of the characteristic value. An notification will not block; it is a fire and forget.

Returns
N/A.

◆ setBroadcastProperty()

void BLECharacteristic::setBroadcastProperty ( bool  value)

Set the permission to broadcast. A characteristics has properties associated with it which define what it is capable of doing. One of these is the broadcast flag.

Parameters
[in]valueThe flag value of the property.
Returns
N/A

◆ setCallbacks()

void BLECharacteristic::setCallbacks ( BLECharacteristicCallbacks pCallbacks)

Set the callback handlers for this characteristic.

Parameters
[in]pCallbacksAn instance of a callbacks structure used to define any callbacks for the characteristic.

◆ setIndicateProperty()

void BLECharacteristic::setIndicateProperty ( bool  value)

Set the Indicate property value.

Parameters
[in]valueSet to true if we are to allow indicate messages.

◆ setNotifyProperty()

void BLECharacteristic::setNotifyProperty ( bool  value)

Set the Notify property value.

Parameters
[in]valueSet to true if we are to allow notification messages.

◆ setReadProperty()

void BLECharacteristic::setReadProperty ( bool  value)

Set the Read property value.

Parameters
[in]valueSet to true if we are to allow reads.

◆ setValue() [1/2]

void BLECharacteristic::setValue ( uint8_t *  data,
size_t  length 
)

Set the value of the characteristic.

Parameters
[in]dataThe data to set for the characteristic.
[in]lengthThe length of the data in bytes.

◆ setValue() [2/2]

void BLECharacteristic::setValue ( std::string  value)

Set the value of the characteristic from string data. We set the value of the characteristic from the bytes contained in the string.

Parameters
[in]Setthe value of the characteristic.
Returns
N/A.

◆ setWriteNoResponseProperty()

void BLECharacteristic::setWriteNoResponseProperty ( bool  value)

Set the Write No Response property value.

Parameters
[in]valueSet to true if we are to allow writes with no response.

◆ setWriteProperty()

void BLECharacteristic::setWriteProperty ( bool  value)

Set the Write property value.

Parameters
[in]valueSet to true if we are to allow writes.

◆ toString()

std::string BLECharacteristic::toString ( )

Return a string representation of the characteristic.

Returns
A string representation of the characteristic.

The documentation for this class was generated from the following files: