GAP advertising data builder. More...
#include <GapAdvertisingData.h>
Public Types | |
typedef enum DataType_t | DataType |
Alias for GapAdvertisingData::DataType_t. More... | |
typedef enum Flags_t | Flags |
Alias for GapAdvertisingData::Flags_t. More... | |
typedef enum Appearance_t | Appearance |
Alias for GapAdvertisingData::Appearance_t. More... | |
Public Member Functions | |
GapAdvertisingData (void) | |
Construct a GapAdvertising instance with an empty payload. More... | |
ble_error_t | addData (DataType_t advDataType, const uint8_t *payload, uint8_t len) |
Adds a new field into the payload. More... | |
ble_error_t | updateData (DataType_t advDataType, const uint8_t *payload, uint8_t len) |
Update a specific field in the advertising payload. More... | |
ble_error_t | addAppearance (Appearance appearance=GENERIC_TAG) |
Add device appearance in the advertising payload. More... | |
ble_error_t | addFlags (uint8_t flags=LE_GENERAL_DISCOVERABLE) |
Add BLE flags in the advertising payload. More... | |
ble_error_t | addTxPower (int8_t txPower) |
Add the advertising TX in the advertising payload. More... | |
void | clear (void) |
Clears the advertising data payload. More... | |
const uint8_t * | getPayload (void) const |
Get the pointer to the advertising payload bytes. More... | |
uint8_t | getPayloadLen (void) const |
Get the payload length. More... | |
uint16_t | getAppearance (void) const |
Get the appearance set. More... | |
const uint8_t * | findField (DataType_t type) const |
Search advertisement data for a specific field. More... | |
GAP advertising data builder.
Advertising data are used by broadcaster or peripheral to advertise state about the device. This class offers the function to add and update states present in an advertisement payload.
After construction, the advertising payload contained in the instance of GapAdvertisingData is empty. Adding new states and named fields can be achieved by invoking the function addData(), and updating existing state involves calling the function updateData().
Fields present in the payload can be retrieved by a call to the function findField.
This class includes shorthand for the most common fields:
Record
length (1 byte). AD
Type (1 byte). AD
payload (optional; only present if record length > 1).Definition at line 117 of file GapAdvertisingData.h.
typedef enum Appearance_t Appearance |
Alias for GapAdvertisingData::Appearance_t.
Definition at line 536 of file GapAdvertisingData.h.
typedef enum DataType_t DataType |
Alias for GapAdvertisingData::DataType_t.
Definition at line 224 of file GapAdvertisingData.h.
Alias for GapAdvertisingData::Flags_t.
Definition at line 270 of file GapAdvertisingData.h.
enum Appearance_t |
Enumeration of values for the DataType_t::APPEARANCE.
These values describe the physical shape or appearance of the device.
Bluetooth
Core Specification Supplement, Part A, Section 1.12. Bluetooth
Core Specification 4.0 (Vol. 3), Part C, Section 12.2. https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml
. Definition at line 283 of file GapAdvertisingData.h.
enum DataType_t |
List of standard Advertising Data types.
These AD types are used to describe the capabilities of the peripheral and are inserted inside the advertising or scan response payloads.
Bluetooth
Core Specification 4.0 (Vol. 3), Part C, Section 11, 18. https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile
. Enumerator | |
---|---|
FLAGS |
Flags, refer to GapAdvertisingData::Flags_t. |
INCOMPLETE_LIST_16BIT_SERVICE_IDS |
Incomplete list of 16-bit Service IDs. |
COMPLETE_LIST_16BIT_SERVICE_IDS |
Complete list of 16-bit Service IDs. |
INCOMPLETE_LIST_32BIT_SERVICE_IDS |
Incomplete list of 32-bit Service IDs (not relevant for Bluetooth 4.0). |
COMPLETE_LIST_32BIT_SERVICE_IDS |
Complete list of 32-bit Service IDs (not relevant for Bluetooth 4.0). |
INCOMPLETE_LIST_128BIT_SERVICE_IDS |
Incomplete list of 128-bit Service IDs. |
COMPLETE_LIST_128BIT_SERVICE_IDS |
Complete list of 128-bit Service IDs. |
SHORTENED_LOCAL_NAME |
Shortened Local Name. |
COMPLETE_LOCAL_NAME |
Complete Local Name. |
TX_POWER_LEVEL |
TX Power Level (in dBm). |
DEVICE_ID |
Device ID. |
SLAVE_CONNECTION_INTERVAL_RANGE |
Slave Connection Interval Range. |
LIST_128BIT_SOLICITATION_IDS |
List of 128-bit service UUIDs the device is looking for. |
SERVICE_DATA |
Service Data. |
APPEARANCE |
Appearance, refer to GapAdvertisingData::Appearance_t. |
ADVERTISING_INTERVAL |
Advertising Interval. |
MANUFACTURER_SPECIFIC_DATA |
Manufacturer Specific Data. |
Definition at line 131 of file GapAdvertisingData.h.
enum Flags_t |
Enumeration of allowed flags for DataType_t::FLAGS.
Bluetooth
Core Specification 4.0 (Vol. 3), Part C, Section 18.1. Definition at line 236 of file GapAdvertisingData.h.
GapAdvertisingData | ( | void | ) |
Construct a GapAdvertising instance with an empty payload.
Definition at line 541 of file GapAdvertisingData.h.
ble_error_t addAppearance | ( | Appearance | appearance = GENERIC_TAG | ) |
Add device appearance in the advertising payload.
[in] | appearance | The appearance to advertise. |
Definition at line 619 of file GapAdvertisingData.h.
ble_error_t addData | ( | DataType_t | advDataType, |
const uint8_t * | payload, | ||
uint8_t | len | ||
) |
Adds a new field into the payload.
If the supplied advertising data type is already present in the advertising payload, then the value is updated.
[in] | advDataType | The type of the field to add. |
[in] | payload | Pointer to the value of the field to add. |
[in] | len | Size in bytes of the value to add. |
Definition at line 567 of file GapAdvertisingData.h.
ble_error_t addFlags | ( | uint8_t | flags = LE_GENERAL_DISCOVERABLE | ) |
Add BLE flags in the advertising payload.
[in] | flags | Bitfield describing the capability of the device. See allowed flags in Flags_t. |
Definition at line 638 of file GapAdvertisingData.h.
ble_error_t addTxPower | ( | int8_t | txPower | ) |
Add the advertising TX in the advertising payload.
[in] | txPower | Transmission power level in dB. |
Definition at line 655 of file GapAdvertisingData.h.
void clear | ( | void | ) |
Clears the advertising data payload.
Definition at line 666 of file GapAdvertisingData.h.
const uint8_t* findField | ( | DataType_t | type | ) | const |
Search advertisement data for a specific field.
[in] | type | The type of the field to find. |
Definition at line 713 of file GapAdvertisingData.h.
uint16_t getAppearance | ( | void | ) | const |
Get the appearance set.
If no value has been set, this function returns GENERIC_TAG.
Definition at line 699 of file GapAdvertisingData.h.
const uint8_t* getPayload | ( | void | ) | const |
Get the pointer to the advertising payload bytes.
Definition at line 677 of file GapAdvertisingData.h.
uint8_t getPayloadLen | ( | void | ) | const |
Get the payload length.
Definition at line 687 of file GapAdvertisingData.h.
ble_error_t updateData | ( | DataType_t | advDataType, |
const uint8_t * | payload, | ||
uint8_t | len | ||
) |
Update a specific field in the advertising payload.
[in] | advDataType | The type of the field to update. |
[in] | payload | Pointer to the updated value of the field. |
[in] | len | Size of the new value in bytes. |
Definition at line 593 of file GapAdvertisingData.h.