Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

AdvertisingDataSimpleBuilder< DataSize > Class Template Reference

AdvertisingDataSimpleBuilder< DataSize > Class Template Reference
[Gap]

Build advertising data. More...

#include <AdvertisingDataSimpleBuilder.h>

Public Member Functions

 AdvertisingDataSimpleBuilder ()
 Construct a AdvertisingDataSimpleBuilder.
AdvertisingDataSimpleBuildersetAppearance (adv_data_appearance_t appearance)
 Add device appearance in the advertising payload.
AdvertisingDataSimpleBuildersetFlags (adv_data_flags_t flags=adv_data_flags_t::default_flags)
 Add BLE flags in the advertising payload.
AdvertisingDataSimpleBuildersetTxPowerAdvertised (advertising_power_t txPower)
 Add the advertising TX in the advertising payload.
AdvertisingDataSimpleBuildersetName (const char *name, bool complete=true)
 Add device name to the advertising payload.
AdvertisingDataSimpleBuildersetManufacturerSpecificData (mbed::Span< const uint8_t > data)
 Add manufacturer specific data to the advertising payload.
AdvertisingDataSimpleBuildersetAdvertisingInterval (adv_interval_t interval)
 Add advertising interval to the payload.
AdvertisingDataSimpleBuildersetConnectionIntervalPreference (conn_interval_t min, conn_interval_t max)
 Add connection interval preferences to the payload.
AdvertisingDataSimpleBuildersetServiceData (UUID service, mbed::Span< const uint8_t > data)
 Add service data to the advertising payload.
AdvertisingDataSimpleBuildersetLocalService (const UUID &data, bool complete=true)
 Add local service ID to the advertising payload.
AdvertisingDataSimpleBuildersetLocalServiceList (mbed::Span< const UUID > data, bool complete=true)
 Add local service IDs to the advertising payload.
AdvertisingDataSimpleBuildersetRequestedService (const UUID &data)
 Add a UUID of a solicited service.
AdvertisingDataSimpleBuildersetRequestedServiceList (mbed::Span< const UUID > data)
 Add a list of UUIDs of solicited services.
AdvertisingDataSimpleBuilderaddData (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


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]advDataTypeThe type of the field to add.
[in]fieldDataSpan 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:
intervalInterval 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]appearanceThe 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:
minMinimum connection interval to advertise.
maxMaximum 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]flagsBitfield 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]dataNew data to be added.
[in]completeTrue 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]dataNew data to be added.
[in]completeTrue 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]dataNew 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]nameNull terminated string containing the name.
[in]completeComplete 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]dataList 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]dataList 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]serviceUUID of the service.
[in]dataNew 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]txPowerTransmission 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.