17 #ifndef MBED_GAP_ADVERTISING_DATA__LEGACY_H__ 18 #define MBED_GAP_ADVERTISING_DATA__LEGACY_H__ 23 #include "blecommon.h" 32 #define GAP_ADVERTISING_DATA_MAX_PAYLOAD (31) 574 return addField(advDataType, payload, len, field);
577 return appendField(advDataType, payload, len);
600 return updateField(advDataType, payload, len, field);
621 _appearance = appearance;
668 memset(&_payload, 0, GAP_ADVERTISING_DATA_MAX_PAYLOAD);
701 return (uint16_t)_appearance;
716 for (uint8_t idx = 0; idx < _payloadLen; ) {
717 uint8_t fieldType = _payload[idx + 1];
719 if (fieldType == type) {
720 return &_payload[idx];
724 idx += _payload[idx] + 1;
744 ble_error_t appendField(DataType advDataType,
const uint8_t *payload, uint8_t len)
747 if (_payloadLen + len + 2 > GAP_ADVERTISING_DATA_MAX_PAYLOAD) {
752 memset(&_payload[_payloadLen], len + 1, 1);
756 memset(&_payload[_payloadLen], (uint8_t)advDataType, 1);
760 memcpy(&_payload[_payloadLen], payload, len);
777 return const_cast<uint8_t*
>(
803 const uint8_t *payload,
809 switch(advDataType) {
819 if ((_payloadLen + len) <= GAP_ADVERTISING_DATA_MAX_PAYLOAD) {
825 uint8_t* end = &_payload[_payloadLen];
827 while (&field[1] < end) {
833 for (uint8_t idx = 0; idx < len; idx++) {
834 field[2 + idx] = payload[idx];
848 result = updateField(advDataType, payload, len, field);
871 const uint8_t *payload,
876 uint8_t dataLength = field[0] - 1;
879 if (len == dataLength) {
880 for (uint8_t idx = 0; idx < dataLength; idx++) {
881 field[2 + idx] = payload[idx];
887 if ((_payloadLen - dataLength + len) <= GAP_ADVERTISING_DATA_MAX_PAYLOAD) {
890 while ((field + dataLength + 2) < &_payload[_payloadLen]) {
891 *field = field[dataLength + 2];
896 _payloadLen -= dataLength + 2;
899 result = appendField(advDataType, payload, len);
909 uint8_t _payload[GAP_ADVERTISING_DATA_MAX_PAYLOAD];
919 uint16_t _appearance;
Generic Bar Code Scanner.
Generic Heart Rate Sensor.
Outdoor Location and Navigation Display Device.
On Hip Running/Walking Sensor.
In Shoe Running/Walking Sensor.
Incomplete list of 16-bit Service IDs.
Peripheral device is discoverable for a limited period of time.
Slave Connection Interval Range.
Complete list of 32-bit Service IDs (not relevant for Bluetooth 4.0).
Generic Running/Walking Sensor.
Peripheral device is discoverable at any moment.
uint16_t getAppearance(void) const
Get the appearance set.
uint8_t getPayloadLen(void) const
Get the payload length.
Complete list of 128-bit Service IDs.
ble_error_t updateData(DataType_t advDataType, const uint8_t *payload, uint8_t len)
Update a specific field in the advertising payload.
Appearance, refer to GapAdvertisingData::Appearance_t.
ble_error_t addData(DataType_t advDataType, const uint8_t *payload, uint8_t len)
Adds a new field into the payload.
GAP advertising data builder.
Complete list of 16-bit Service IDs.
Outdoor Location and Navigation Pod.
Outdoor Location Display Device.
Incomplete list of 32-bit Service IDs (not relevant for Bluetooth 4.0).
const uint8_t * findField(DataType_t type) const
Search advertisement data for a specific field.
Appearance_t
Enumeration of values for the DataType_t::APPEARANCE.
Human Interface Device (HID).
Manufacturer Specific Data.
Peripheral device is LE only and does not support Bluetooth Enhanced DataRate.
On Shoe Running/Walking Sensor.
Flags_t
Enumeration of allowed flags for DataType_t::FLAGS.
enum Appearance_t Appearance
Alias for GapAdvertisingData::Appearance_t.
ble_error_t addTxPower(int8_t txPower)
Add the advertising TX in the advertising payload.
Wrist Worn Pulse Oximeter.
enum DataType_t DataType
Alias for GapAdvertisingData::DataType_t.
List of 128-bit service UUIDs the device is looking for.
ble_error_t addAppearance(Appearance appearance=GENERIC_TAG)
Add device appearance in the advertising payload.
const uint8_t * getPayload(void) const
Get the pointer to the advertising payload bytes.
enum Flags_t Flags
Alias for GapAdvertisingData::Flags_t.
Unknown or unspecified appearance type.
The requested action would cause a buffer overflow and has been aborted.
Not relevant - dual mode only.
Flags, refer to GapAdvertisingData::Flags_t.
GapAdvertisingData(void)
Construct a GapAdvertising instance with an empty payload.
Fingertip Pulse Oximeter.
Incomplete list of 128-bit Service IDs.
ble_error_t addFlags(uint8_t flags=LE_GENERAL_DISCOVERABLE)
Add BLE flags in the advertising payload.
Cycling Speed and Cadence Sensor.
Not relevant - dual mode only.
void clear(void)
Clears the advertising data payload.
ble_error_t
Error codes for the BLE API.