|
ELEC-C7222
Libraries for ELEC C7222 Course Work
|
Builder for assembling a complete advertising payload. More...
#include <advertisement_data.hpp>

Public Member Functions | |
| AdvertisementDataBuilder () | |
| Create an empty builder. | |
| AdvertisementDataBuilder (const std::list< AdvertisementData > &ads) | |
| Create a builder from a list of AD structures. | |
| bool | Set (const std::list< AdvertisementData > &ads) |
| ReplaceOrAdd the payload with a list of AD structures. | |
| bool | Set (const uint8_t *data, size_t size) |
| ReplaceOrAdd the payload from a raw advertising buffer. | |
| bool | Pop () |
| Remove the last AD structure from the payload. | |
| bool | Push (const AdvertisementData &ad) |
| Add an AD structure to the payload. | |
| void | ReplaceOrAdd (const AdvertisementData &ad) |
| ReplaceOrAdd the AD structure with the same type. | |
| void | ReplaceOrAdd (AdvertisementData &&ad) |
| ReplaceOrAdd the AD structure with the same type (move). | |
| bool | Add (const std::list< AdvertisementData > &ads) |
| Add a list of AD structures to the payload. | |
| bool | Add (const AdvertisementData &ad) |
| Add an AD structure to the payload. | |
| const std::vector< uint8_t > & | data () const |
| Return the raw advertising payload bytes. | |
| const uint8_t * | bytes () const |
| Return a raw pointer to the advertising payload bytes. | |
| size_t | size () const |
| Return the total payload size in bytes. | |
| void | Clear () |
| Clear all stored AD structures. | |
| AdvertisementDataBuilder & | operator+= (const AdvertisementData &ad) |
| Add an AD structure and enforce uniqueness. | |
| AdvertisementDataBuilder | operator+ (const AdvertisementData &ad) |
| Return a builder with an additional AD structure. | |
| AdvertisementDataBuilder & | operator+= (const AdvertisementDataBuilder &adb) |
| Merge another builder into this one, enforcing uniqueness. | |
| AdvertisementDataBuilder | operator+ (const AdvertisementDataBuilder &adb) |
| Return a builder that is the merge of two builders. | |
| bool | operator== (const AdvertisementDataBuilder &other) const |
| Compare two builders by payload or list contents. | |
| bool | Validate () const |
| Validate the assembled payload. | |
| bool | Build () |
| Build the raw payload from stored AD structures. | |
| const std::list< AdvertisementData > & | advertisement_data_list () const |
| Decode the payload into a list of AD structures. | |
Static Public Member Functions | |
| static std::list< AdvertisementData > | DecodeBufferToAdvertisementDataList (const uint8_t *adv_data, size_t adv_data_size) |
| Decode a raw advertising payload buffer into a list of AD structures. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const AdvertisementDataBuilder &adb) |
| Stream the builder payload for logging/debugging. | |
Builder for assembling a complete advertising payload.
Use this class when you want to compose multiple AD structures into a single legacy advertising payload. The builder enforces the 31-byte limit on insert.
| c7222::AdvertisementDataBuilder::AdvertisementDataBuilder | ( | ) |
Create an empty builder.
|
explicit |
Create a builder from a list of AD structures.
The builder validates the resulting payload.
| ads | List of AD structures to add. |
| bool c7222::AdvertisementDataBuilder::Add | ( | const AdvertisementData & | ad | ) |
Add an AD structure to the payload.
Fails if the addition would exceed 31 bytes.
| ad | AD structure to add. |
| bool c7222::AdvertisementDataBuilder::Add | ( | const std::list< AdvertisementData > & | ads | ) |
Add a list of AD structures to the payload.
| ads | List of AD structures to add. |
|
inline |
Decode the payload into a list of AD structures.
| bool c7222::AdvertisementDataBuilder::Build | ( | ) |
Build the raw payload from stored AD structures.
Sorts by type, assembles the payload, and validates the result.

| const uint8_t * c7222::AdvertisementDataBuilder::bytes | ( | ) | const |
Return a raw pointer to the advertising payload bytes.
| void c7222::AdvertisementDataBuilder::Clear | ( | ) |
Clear all stored AD structures.
| const std::vector< uint8_t > & c7222::AdvertisementDataBuilder::data | ( | ) | const |
Return the raw advertising payload bytes.

|
static |
Decode a raw advertising payload buffer into a list of AD structures.
| adv_data | Pointer to raw advertising bytes. |
| adv_data_size | Total buffer size in bytes. |
| AdvertisementDataBuilder c7222::AdvertisementDataBuilder::operator+ | ( | const AdvertisementData & | ad | ) |
Return a builder with an additional AD structure.
| ad | AD structure to add. |
| AdvertisementDataBuilder c7222::AdvertisementDataBuilder::operator+ | ( | const AdvertisementDataBuilder & | adb | ) |
Return a builder that is the merge of two builders.
| adb | Builder to merge in. |
| AdvertisementDataBuilder & c7222::AdvertisementDataBuilder::operator+= | ( | const AdvertisementData & | ad | ) |
Add an AD structure and enforce uniqueness.
If an identical AD structure already exists, this asserts.
| ad | AD structure to add. |
| AdvertisementDataBuilder & c7222::AdvertisementDataBuilder::operator+= | ( | const AdvertisementDataBuilder & | adb | ) |
Merge another builder into this one, enforcing uniqueness.
| adb | Builder to merge in. |
| bool c7222::AdvertisementDataBuilder::operator== | ( | const AdvertisementDataBuilder & | other | ) | const |
Compare two builders by payload or list contents.
| bool c7222::AdvertisementDataBuilder::Pop | ( | ) |
Remove the last AD structure from the payload.
| bool c7222::AdvertisementDataBuilder::Push | ( | const AdvertisementData & | ad | ) |
Add an AD structure to the payload.
| ad | AD structure to add. |
| void c7222::AdvertisementDataBuilder::ReplaceOrAdd | ( | AdvertisementData && | ad | ) |
ReplaceOrAdd the AD structure with the same type (move).
| ad | AD structure to replace in the list (moved). |
| void c7222::AdvertisementDataBuilder::ReplaceOrAdd | ( | const AdvertisementData & | ad | ) |
ReplaceOrAdd the AD structure with the same type.
| ad | AD structure to replace in the list. |
| bool c7222::AdvertisementDataBuilder::Set | ( | const std::list< AdvertisementData > & | ads | ) |
ReplaceOrAdd the payload with a list of AD structures.
| ads | List of AD structures to set. |
| bool c7222::AdvertisementDataBuilder::Set | ( | const uint8_t * | data, |
| size_t | size | ||
| ) |
ReplaceOrAdd the payload from a raw advertising buffer.
| data | Raw advertising bytes. |
| size | Total buffer size in bytes. |
| size_t c7222::AdvertisementDataBuilder::size | ( | ) | const |
Return the total payload size in bytes.
| bool c7222::AdvertisementDataBuilder::Validate | ( | ) | const |
Validate the assembled payload.
|
friend |
Stream the builder payload for logging/debugging.