|
Open Model Railroad Network (OpenMRN)
|
Object helper to define an advertisement. More...
#include <Advertisement.hxx>
Public Types | |
| enum | Field { DATA , SCAN_DATA } |
| Data fields that make up an advertisement. More... | |
| enum class | Flags : uint8_t { LE_LIMITED_DISC_MODE = 0x01 , LE_GENERAL_DISC_MODE = 0x02 , BR_EDR_NOT_SUPPORTED = 0x04 , LE_BR_EDR_CONTROLLER = 0x08 , LE_BR_EDR_HOST = 0x10 , LE_ONLY_LIMITED_DISC_MODE = 0x05 , LE_ONLY_GENERAL_DISC_MODE = 0x06 } |
| Flag values. More... | |
Public Member Functions | |
| Advertisement (bool extended=false) | |
| Constructor. | |
| Advertisement (size_t data_reserve, size_t scan_data_reserve) | |
| Constructor which reserves data and scan data space. | |
| Advertisement (size_t data_reserve, size_t dummy, bool extended) | |
| Constructor which reserves data space. | |
| std::basic_string< uint8_t > | concat_service_data_128 (const uint8_t uuid[16], const void *buf, size_t size) |
| Concatenate a 128-bit (16-byte) UUID with provided data. | |
| std::basic_string< uint8_t > | concat_service_data_128 (const uint8_t uuid[16], std::basic_string< uint8_t > &buf) |
| Concatenate a 128-bit (16-byte) UUID with provided data. | |
| int | prepend (Field field, Defs::AdvType type, const void *buf, size_t size, bool clip=false) |
| Add to the beginning of the advertisement. | |
| int | prepend (Field field, Defs::AdvType type, std::basic_string< uint8_t > &buf, bool clip=false) |
| Add to the beginning of the advertisement. | |
| int | prepend_name (Field field, std::string &name) |
| Add name to the beginning of the advertisement. | |
| int | append (Field field, Defs::AdvType type, const void *buf, size_t size, bool clip=false) |
| Add to the end of the advertisement. | |
| int | append (Field field, Defs::AdvType type, std::basic_string< uint8_t > &buf, bool clip=false) |
| Add to the end of the advertisement. | |
| int | append_name (Field field, std::string &name) |
| Add name to the end of the advertisement. | |
| int | update (Field field, Defs::AdvType type, const void *buf, size_t size, unsigned instance=1, bool exact_size=true, bool clip=false) |
| Update existing advertisement. | |
| int | update (Field field, Defs::AdvType type, std::basic_string< uint8_t > &buf, unsigned instance=1, bool exact_size=true, bool clip=false) |
| Update existing advertisement. | |
| bool | is_extended () |
| Test if extended advertisement or not. | |
| uint8_t * | get_data () |
| Get the advertisement data. | |
| size_t | get_data_size () |
| Get the advertisement data size in bytes. | |
| uint8_t * | get_scan_data () |
| Get the advertisement data. | |
| size_t | get_scan_data_size () |
| Get the advertisement data size in bytes. | |
Static Public Attributes | |
| static constexpr size_t | MAX_DATA_PAYLOAD_SIZE = 31 |
| Maximum payload size of data. | |
| static constexpr size_t | MAX_SCAN_DATA_PAYLOAD_SIZE = 31 |
| Maximum payload size of scan data. | |
| static constexpr size_t | MAX_EXT_DATA_PAYLOAD_SIZE = 254 |
| Maximum payload size of extended data. | |
Private Attributes | |
| std::basic_string< uint8_t > | data_ |
| advertising data, also used for extended advertising | |
| std::basic_string< uint8_t > | scanData_ |
| bool | extended_ |
| true extended advertisement, else false | |
Object helper to define an advertisement.
Definition at line 38 of file Advertisement.hxx.
Data fields that make up an advertisement.
| Enumerator | |
|---|---|
| DATA | main data |
| SCAN_DATA | scan data |
Definition at line 51 of file Advertisement.hxx.
|
strong |
Flag values.
Definition at line 58 of file Advertisement.hxx.
|
inline |
Constructor.
| extended | true if an extended advertisement, else false |
Definition at line 71 of file Advertisement.hxx.
|
inline |
Constructor which reserves data and scan data space.
This cannot be and extended advertisement because it is assumed to have scan data.
| data_reserve | size in bytes to reserve for the data |
| scan_data_reserve | size in bytes to reserve for the scan data |
Definition at line 80 of file Advertisement.hxx.
|
inline |
Constructor which reserves data space.
| data_reserve | size in bytes to reserve for the data |
| dummy | not used, present to remove ambiguity |
| extended | true if an extended advertisement, else false |
Definition at line 99 of file Advertisement.hxx.
| int ble::Advertisement::append | ( | Field | field, |
| Defs::AdvType | type, | ||
| const void * | buf, | ||
| size_t | size, | ||
| bool | clip = false |
||
| ) |
Add to the end of the advertisement.
| field | field to place the data into |
| type | type of data to add |
| buf | data to add |
| size | size of data in bytes |
| clip | if the data does not all fit, clip the end of it off |
Definition at line 85 of file Advertisement.cxx.
|
inline |
Add to the end of the advertisement.
| field | field to place the data into |
| type | type of data to add |
| buf | data to add |
| clip | if the data does not all fit, clip the end of it off |
Definition at line 184 of file Advertisement.hxx.
|
inline |
Add name to the end of the advertisement.
Will use type NAME_COMPLETE if it fits. Will use NAME_SHORT if it does not fit.
| field | field to place the data into |
| name | name to add |
Definition at line 195 of file Advertisement.hxx.
| std::basic_string< uint8_t > ble::Advertisement::concat_service_data_128 | ( | const uint8_t | uuid[16], |
| const void * | buf, | ||
| size_t | size | ||
| ) |
Concatenate a 128-bit (16-byte) UUID with provided data.
| uuid | 128-bit UUID |
| data | data to concatenate |
| size | size of data in bytes to concatenate |
Definition at line 36 of file Advertisement.cxx.
|
inline |
Concatenate a 128-bit (16-byte) UUID with provided data.
| uuid | 128-bit UUID |
| data | data to concatenate |
Definition at line 123 of file Advertisement.hxx.
|
inline |
Get the advertisement data.
Definition at line 246 of file Advertisement.hxx.
|
inline |
Get the advertisement data size in bytes.
Definition at line 253 of file Advertisement.hxx.
|
inline |
Get the advertisement data.
Definition at line 260 of file Advertisement.hxx.
|
inline |
Get the advertisement data size in bytes.
Definition at line 268 of file Advertisement.hxx.
|
inline |
Test if extended advertisement or not.
Definition at line 239 of file Advertisement.hxx.
| int ble::Advertisement::prepend | ( | Field | field, |
| Defs::AdvType | type, | ||
| const void * | buf, | ||
| size_t | size, | ||
| bool | clip = false |
||
| ) |
Add to the beginning of the advertisement.
| f | field to place the advertisement into |
| type | type of data to add |
| buf | data to add |
| size | size of data in bytes |
| clip | if the data does not all fit, clip the end of it off |
Definition at line 48 of file Advertisement.cxx.
|
inline |
Add to the beginning of the advertisement.
| field | field to place the data into |
| type | type of data to add |
| buf | data to add |
| clip | if the data does not all fit, clip the end of it off |
Definition at line 145 of file Advertisement.hxx.
|
inline |
Add name to the beginning of the advertisement.
Will use type NAME_COMPLETE if it fits. Will use NAME_SHORT if it does not fit.
| field | field to place the data into |
| name | name to add |
Definition at line 156 of file Advertisement.hxx.
| int ble::Advertisement::update | ( | Field | field, |
| Defs::AdvType | type, | ||
| const void * | buf, | ||
| size_t | size, | ||
| unsigned | instance = 1, |
||
| bool | exact_size = true, |
||
| bool | clip = false |
||
| ) |
Update existing advertisement.
| field | field to place the data into |
| type | type of data to update |
| buf | data to update |
| size | size of data in bytes |
| instance | the instance occurance to update |
| exact_size | the new data size must match the old data size |
| clip | if the data does not all fit, clip the end of it off |
Definition at line 122 of file Advertisement.cxx.
|
inline |
Update existing advertisement.
| field | field to place the data into |
| type | type of data to update |
| buf | data to update |
| size | size of data in bytes |
| instance | the instance occurance to update |
| exact_size | the new data size must match the old data size |
| clip | if the data does not all fit, clip the end of it off |
Definition at line 229 of file Advertisement.hxx.
|
private |
advertising data, also used for extended advertising
advertising scan data
Definition at line 287 of file Advertisement.hxx.
|
private |
true extended advertisement, else false
Definition at line 292 of file Advertisement.hxx.
|
staticconstexpr |
Maximum payload size of data.
Definition at line 42 of file Advertisement.hxx.
|
staticconstexpr |
Maximum payload size of extended data.
Definition at line 48 of file Advertisement.hxx.
|
staticconstexpr |
Maximum payload size of scan data.
Definition at line 45 of file Advertisement.hxx.
|
private |
Definition at line 290 of file Advertisement.hxx.