Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
AdvertisingDataSimpleBuilder< DataSize > Class Template Reference
[Gap]
  Build advertising data. More...
#include <AdvertisingDataSimpleBuilder.h>
| Public Member Functions | |
| AdvertisingDataSimpleBuilder () | |
| Construct a AdvertisingDataSimpleBuilder. | |
| AdvertisingDataSimpleBuilder & | setAppearance (adv_data_appearance_t appearance) | 
| Add device appearance in the advertising payload. | |
| AdvertisingDataSimpleBuilder & | setFlags (adv_data_flags_t flags=adv_data_flags_t::default_flags) | 
| Add BLE flags in the advertising payload. | |
| AdvertisingDataSimpleBuilder & | setTxPowerAdvertised (advertising_power_t txPower) | 
| Add the advertising TX in the advertising payload. | |
| AdvertisingDataSimpleBuilder & | setName (const char *name, bool complete=true) | 
| Add device name to the advertising payload. | |
| AdvertisingDataSimpleBuilder & | setManufacturerSpecificData (mbed::Span< const uint8_t > data) | 
| Add manufacturer specific data to the advertising payload. | |
| AdvertisingDataSimpleBuilder & | setAdvertisingInterval (adv_interval_t interval) | 
| Add advertising interval to the payload. | |
| AdvertisingDataSimpleBuilder & | setConnectionIntervalPreference (conn_interval_t min, conn_interval_t max) | 
| Add connection interval preferences to the payload. | |
| AdvertisingDataSimpleBuilder & | setServiceData (UUID service, mbed::Span< const uint8_t > data) | 
| Add service data to the advertising payload. | |
| AdvertisingDataSimpleBuilder & | setLocalService (const UUID &data, bool complete=true) | 
| Add local service ID to the advertising payload. | |
| AdvertisingDataSimpleBuilder & | setLocalServiceList (mbed::Span< const UUID > data, bool complete=true) | 
| Add local service IDs to the advertising payload. | |
| AdvertisingDataSimpleBuilder & | setRequestedService (const UUID &data) | 
| Add a UUID of a solicited service. | |
| AdvertisingDataSimpleBuilder & | setRequestedServiceList (mbed::Span< const UUID > data) | 
| Add a list of UUIDs of solicited services. | |
| AdvertisingDataSimpleBuilder & | addData (adv_data_type_t advDataType, mbed::Span< const uint8_t > fieldData) | 
| Add a new field into the payload. | |
| mbed::Span< const uint8_t > | getAdvertisingData () const | 
| Get the subspan of the buffer containing valid data. | |
Detailed Description
template<size_t DataSize>
 class ble::AdvertisingDataSimpleBuilder< DataSize >
Build advertising data.
It is a simplified version of AdvertisingDataBuilder that can generate advertising data "inline".
It differs from AdvertisingDataBuilder on the following points:
- The buffer used to build the advertising data is embedded in the object.
- If insertion fails, an assertion is raised. Outside of debug mode, if an insertion fails, the buffer is not modified.
- The API is fluent.
- It hides advanced functions.
void setupAdvertisingData(ble::Gap& gap) { using namespace ble; gap.setAdvertisingPayload( LEGACY_ADVERTISING_HANDLE, AdvertisingDataSimpleBuilder<LEGACY_ADVERTISING_MAX_SIZE>() .setFlags() .setName("My device", true) .setAppearance(adv_data_appearance_t::GENERIC_HEART_RATE_SENSOR) .setLocalService(ATT_UUID_HEART_RATE_SERVICE) .getAdvertisingData() ); }
Definition at line 61 of file AdvertisingDataSimpleBuilder.h.
Constructor & Destructor Documentation
Construct a AdvertisingDataSimpleBuilder.
Definition at line 66 of file AdvertisingDataSimpleBuilder.h.
Member Function Documentation
| AdvertisingDataSimpleBuilder& addData | ( | adv_data_type_t | advDataType, | 
| mbed::Span< const uint8_t > | fieldData | ||
| ) | 
Add a new field into the payload.
The operation fails if type is already present.
- Note:
- Data size for individual types cannot exceed 255 bytes.
- Parameters:
- 
  [in] advDataType The type of the field to add. [in] fieldData Span of data to add. 
- Returns:
- A reference to this object.
Definition at line 292 of file AdvertisingDataSimpleBuilder.h.
| mbed::Span<const uint8_t> getAdvertisingData | ( | ) | const | 
Get the subspan of the buffer containing valid data.
- Returns:
- A Span containing the payload.
Definition at line 307 of file AdvertisingDataSimpleBuilder.h.
| AdvertisingDataSimpleBuilder& setAdvertisingInterval | ( | adv_interval_t | interval ) | 
Add advertising interval to the payload.
This field can only carry 2 bytes.
- Parameters:
- 
  interval Interval to advertise. Cannot be larger than 0xFFFF. 
- Returns:
- a reference to this object.
Definition at line 163 of file AdvertisingDataSimpleBuilder.h.
| AdvertisingDataSimpleBuilder& setAppearance | ( | adv_data_appearance_t | appearance ) | 
Add device appearance in the advertising payload.
- Parameters:
- 
  [in] appearance The appearance to advertise. 
- Returns:
- A reference to this object.
- Note:
- If the field is already present in the payload, it is replaced.
Definition at line 79 of file AdvertisingDataSimpleBuilder.h.
| AdvertisingDataSimpleBuilder& setConnectionIntervalPreference | ( | conn_interval_t | min, | 
| conn_interval_t | max | ||
| ) | 
Add connection interval preferences to the payload.
- Parameters:
- 
  min Minimum connection interval to advertise. max Maximum connection interval to advertise. 
- Returns:
- a reference to this object.
Definition at line 178 of file AdvertisingDataSimpleBuilder.h.
| AdvertisingDataSimpleBuilder& setFlags | ( | adv_data_flags_t | flags = adv_data_flags_t::default_flags) | 
Add BLE flags in the advertising payload.
- Parameters:
- 
  [in] flags Bitfield describing the capability of the device. See allowed flags in Flags_t. 
- Returns:
- A reference to this object.
- Note:
- If the field is already present in the payload, it is replaced.
Definition at line 96 of file AdvertisingDataSimpleBuilder.h.
| AdvertisingDataSimpleBuilder& setLocalService | ( | const UUID & | data, | 
| bool | complete = true | ||
| ) | 
Add local service ID to the advertising payload.
If the data can't fit, no modification will take place.
- Note:
- Data size for individual types cannot exceed 255 bytes.
- Parameters:
- 
  [in] data New data to be added. [in] complete True if this is a complete list. 
- Returns:
- A reference to this object.
Definition at line 216 of file AdvertisingDataSimpleBuilder.h.
| AdvertisingDataSimpleBuilder& setLocalServiceList | ( | mbed::Span< const UUID > | data, | 
| bool | complete = true | ||
| ) | 
Add local service IDs to the advertising payload.
If the data can't fit, no modification will take place.
- Note:
- Data size for individual types cannot exceed 255 bytes.
- Parameters:
- 
  [in] data New data to be added. [in] complete True if this is a complete list. 
- Returns:
- A reference to this object.
Definition at line 240 of file AdvertisingDataSimpleBuilder.h.
| AdvertisingDataSimpleBuilder& setManufacturerSpecificData | ( | mbed::Span< const uint8_t > | data ) | 
Add manufacturer specific data to the advertising payload.
- Note:
- Data size for individual types cannot exceed 255 bytes.
- Parameters:
- 
  [in] data New data to be added. 
- Returns:
- a reference to this object.
Definition at line 149 of file AdvertisingDataSimpleBuilder.h.
| AdvertisingDataSimpleBuilder& setName | ( | const char * | name, | 
| bool | complete = true | ||
| ) | 
Add device name to the advertising payload.
- Note:
- Data size for individual types cannot exceed 255 bytes.
- Parameters:
- 
  [in] name Null terminated string containing the name. [in] complete Complete local name if true, otherwise 
- Returns:
- A reference to this object.
- Note:
- If the field is already present in the payload, it is replaced.
Definition at line 133 of file AdvertisingDataSimpleBuilder.h.
| AdvertisingDataSimpleBuilder& setRequestedService | ( | const UUID & | data ) | 
Add a UUID of a solicited service.
- Note:
- Data size for individual types cannot exceed 255 bytes.
- Parameters:
- 
  [in] data List of 128 or 16 bit service UUIDs. 
- Returns:
- A reference to this object.
Definition at line 259 of file AdvertisingDataSimpleBuilder.h.
| AdvertisingDataSimpleBuilder& setRequestedServiceList | ( | mbed::Span< const UUID > | data ) | 
Add a list of UUIDs of solicited services.
- Note:
- Data size for individual types cannot exceed 255 bytes.
- Parameters:
- 
  [in] data List of 128 or 16 bit service UUIDs. 
- Returns:
- A reference to this object.
Definition at line 275 of file AdvertisingDataSimpleBuilder.h.
| AdvertisingDataSimpleBuilder& setServiceData | ( | UUID | service, | 
| mbed::Span< const uint8_t > | data | ||
| ) | 
Add service data to the advertising payload.
- Note:
- Data size for individual types cannot exceed 255 bytes.
- Parameters:
- 
  [in] service UUID of the service. [in] data New data to be added. 
- Returns:
- A reference to this object.
Definition at line 198 of file AdvertisingDataSimpleBuilder.h.
| AdvertisingDataSimpleBuilder& setTxPowerAdvertised | ( | advertising_power_t | txPower ) | 
Add the advertising TX in the advertising payload.
- Parameters:
- 
  [in] txPower Transmission power level in dB. 
- Returns:
- A reference to this object.
- Note:
- If the field is already present in the payload, it is replaced.
Definition at line 114 of file AdvertisingDataSimpleBuilder.h.
Generated on Tue Jul 12 2022 13:55:39 by
 1.7.2
 1.7.2