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

The model of a BLE value. More...

#include <BLEValue.hpp>

Public Member Functions

void addPart (std::string part)
 Add a message part to the accumulation. The accumulation is a growing set of data that is added to until a commit or cancel. More...
 
void addPart (uint8_t *pData, size_t length)
 Add a message part to the accumulation. The accumulation is a growing set of data that is added to until a commit or cancel. More...
 
void cancel ()
 Cancel the current accumulation.
 
void commit ()
 Commit the current accumulation. When writing a value, we may find that we write it in "parts" meaning that the writes come in in pieces of the overall message. After the last part has been received, we may perform a commit which means that we now have the complete message and commit the change as a unit.
 
uint8_t * getData ()
 Get a pointer to the data. More...
 
size_t getLength ()
 Get the length of the data in bytes. More...
 
uint16_t getReadOffset ()
 Get the read offset. More...
 
std::string getValue ()
 Get the current value.
 
void setReadOffset (uint16_t readOffset)
 Set the read offset. More...
 
void setValue (std::string value)
 Set the current value.
 
void setValue (uint8_t *pData, size_t length)
 Set the current value. More...
 

Detailed Description

The model of a BLE value.

Member Function Documentation

◆ addPart() [1/2]

void BLEValue::addPart ( std::string  part)

Add a message part to the accumulation. The accumulation is a growing set of data that is added to until a commit or cancel.

Parameters
[in]partA message part being added.
44  {
45  _debug_print_d(TAG, ">> addPart: length", part.length());
46  m_accumulation += part;
47 } // addPart

◆ addPart() [2/2]

void BLEValue::addPart ( uint8_t *  pData,
size_t  length 
)

Add a message part to the accumulation. The accumulation is a growing set of data that is added to until a commit or cancel.

Parameters
[in]pDataA message part being added.
[in]lengthThe number of bytes being added.
56  {
57  _debug_print_u(TAG, ">> addPart: length", length);
58  m_accumulation += std::string((char*) pData, length);
59 } // addPart

◆ getData()

uint8_t * BLEValue::getData ( )

Get a pointer to the data.

Returns
A pointer to the data.
92  {
93  return (uint8_t*) m_value.data();
94 }

◆ getLength()

size_t BLEValue::getLength ( )

Get the length of the data in bytes.

Returns
The length of the data in bytes.
101  {
102  return m_value.length();
103 } // getLength

◆ getReadOffset()

uint16_t BLEValue::getReadOffset ( )

Get the read offset.

Returns
The read offset into the read.
110  {
111  return m_readOffset;
112 } // getReadOffset

◆ setReadOffset()

void BLEValue::setReadOffset ( uint16_t  readOffset)

Set the read offset.

Parameters
[in]readOffsetThe offset into the read.
127  {
128  m_readOffset = readOffset;
129 } // setReadOffset

◆ setValue()

void BLEValue::setValue ( uint8_t *  pData,
size_t  length 
)

Set the current value.

Parameters
[in]pDataThe data for the current value.
[in]Thelength of the new current value.
145  {
146  m_value = std::string((char*) pData, length);
147 } // setValue

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