SDK  23.9.2
For IoT System Software Development
Public Member Functions | List of all members
BLEDescriptor Class Reference

A model of a BLE descriptor. More...

#include <BLEDescriptor.hpp>

Inheritance diagram for BLEDescriptor:
BLE2902 BLE2904

Public Member Functions

 BLEDescriptor (const char *uuid, uint16_t max_len=100)
 BLEDescriptor constructor.
 
 BLEDescriptor (BLEUUID uuid, uint16_t max_len=100)
 BLEDescriptor constructor.
 
virtual ~BLEDescriptor ()
 BLEDescriptor destructor.
 
uint16_t getHandle ()
 Get the BLE handle for this descriptor. More...
 
size_t getLength ()
 Get the length of the value of this descriptor. More...
 
BLEUUID getUUID ()
 Get the UUID of the descriptor.
 
uint8_t * getValue ()
 Get the value of this descriptor. More...
 
void handleGATTServerEvent (void *info)
 
void setAccessPermissions (ble_gatt_perm_t perm)
 
void setCallbacks (BLEDescriptorCallbacks *pCallbacks)
 Set the callback handlers for this descriptor. More...
 
void setValue (uint8_t *data, size_t size)
 Set the value of the descriptor. More...
 
void setValue (std::string value)
 Set the value of the descriptor. More...
 
std::string toString ()
 Return a string representation of the descriptor. More...
 

Detailed Description

A model of a BLE descriptor.

Member Function Documentation

◆ getHandle()

uint16_t BLEDescriptor::getHandle ( )

Get the BLE handle for this descriptor.

Returns
The handle for this descriptor.
70  {
71  return m_handle;
72 } // getHandle

◆ getLength()

size_t BLEDescriptor::getLength ( )

Get the length of the value of this descriptor.

Returns
The length (in bytes) of the value of this descriptor.
79  {
80  return m_value.attr_len;
81 } // getLength

◆ getValue()

uint8_t * BLEDescriptor::getValue ( )

Get the value of this descriptor.

Returns
A pointer to the value of this descriptor.
97  {
98  return m_value.attr_value;
99 } // getValue

◆ setCallbacks()

void BLEDescriptor::setCallbacks ( BLEDescriptorCallbacks pCallback)

Set the callback handlers for this descriptor.

Parameters
[in]pCallbacksAn instance of a callback structure used to define any callbacks for the descriptor.
106  {
107  _debug_print_p(TAG, ">> setCallbacks", pCallback);
108  m_pCallback = pCallback;
109  _debug_print(TAG, "<< setCallbacks");
110 } // setCallbacks

◆ setValue() [1/2]

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

Set the value of the descriptor.

Parameters
[in]valueThe value of the descriptor in string form.
147  {
148  setValue((uint8_t*) value.data(), value.length());
149 } // setValue

◆ setValue() [2/2]

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

Set the value of the descriptor.

Parameters
[in]dataThe data to set for the descriptor.
[in]lengthThe length of the data in bytes.
131  {
132  if (length > BLE_GATT_MAX_ATTR_LEN) {
133  void *logCtx __attribute__((unused)) = nullptr;
134  _debug_print_d(TAG, "Size too large", length, &logCtx);
135  _debug_print_d(TAG, ", must be no bigger than", BLE_GATT_MAX_ATTR_LEN, &logCtx);
136  return;
137  }
138  m_value.attr_len = length;
139  memcpy(m_value.attr_value, data, length);
140 } // setValue

◆ toString()

std::string BLEDescriptor::toString ( )

Return a string representation of the descriptor.

Returns
A string representation of the descriptor.
159  {
160  std::stringstream stringstream;
161  stringstream << std::hex << std::setfill('0');
162  stringstream << "UUID: " << m_bleUUID.toString() + ", handle: 0x" << std::setw(2) << m_handle;
163  return stringstream.str();
164 } // toString

The documentation for this class was generated from the following files:
BLEUUID::toString
std::string toString()
Get a string representation of the UUID.
Definition: BLEUUID.cpp:317
BLEDescriptor::setValue
void setValue(uint8_t *data, size_t size)
Set the value of the descriptor.
Definition: BLEDescriptor.cpp:131