advertising data

pull/8738/head
paul-szczepanek-arm 2018-11-15 13:42:16 +00:00 committed by Vincent Coubard
parent ad127d76af
commit 33ab365d2c
1 changed files with 17 additions and 36 deletions

View File

@ -87,44 +87,23 @@
* sending a scan request. If the broadcaster accepts scan requests, it can reply * sending a scan request. If the broadcaster accepts scan requests, it can reply
* with a scan response packet containing additional information. * with a scan response packet containing additional information.
* *
* @code * Advertising parameters are updated using setAdvertisingParams(). The main
* // assuming gap has been initialized * advertising payload is updated using setAdvertisingPayload() and the scan response
* Gap& gap; * is updated using setAdvertisingScanResponse(). If the advertising is already active
* updated the data will take effect from the next advertising event.
* *
* // construct the packet to advertise * To create a valid advertising payload and scan response you may use
* GapAdvertisingData advertising_data; * AdvertisingDataBuilder(). You must first allocate memory and crate an mbed::Span and
* pass that into the AdvertisingDataBuilder which will only be able to add as much
* data as fits in the provided buffer. The builder will accept any size of the buffer
* but for the created data to be usable it must be smaller than the maximum data
* length returned from getMaxAdvertisingDataLength().
* *
* // Add advertiser flags * @note The maximum size of data depends on the controller and its support for
* advertising_data.addFlags( * extended advertising however even if the controller supports larger data lengths if
* GapAdvertisingData::LE_GENERAL_DISCOVERABLE | * you wish to be compatible with older devices you may wish to use legacy
* GapAdvertisingData::BREDR_NOT_SUPPORTED * advertising and then should use LEGACY_ADVERTISING_MAX_SIZE instead of
* ); * getMaxAdvertisingDataLength().
*
* // Add the name of the device to the advertising data
* static const uint8_t device_name[] = "HRM";
* advertising_data.addData(
* GapAdvertisingData::COMPLETE_LOCAL_NAME,
* device_name,
* sizeof(device_name)
* );
*
* // set the advertising data in the gap instance, they will be used when
* // advertising starts.
* gap.setAdvertisingPayload(advertising_data);
*
* // Configure the advertising procedure
* GapAdvertisingParams advertising_params(
* GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED, // type of advertising
* GapAdvertisingParams::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(1000), // interval
* 0 // The advertising procedure will not timeout
* );
*
* gap.setAdvertisingParams(advertising_params);
*
* // start the advertising procedure, the device will advertise its flag and the
* // name "HRM". Other peers will also be allowed to connect to it.
* gap.startAdvertising();
* @endcode
* *
* @par Extended advertising * @par Extended advertising
* *
@ -1116,6 +1095,8 @@ public:
/** Special advertising set handle used for the legacy advertising set. */ /** Special advertising set handle used for the legacy advertising set. */
static const AdvHandle_t LEGACY_ADVERTISING_HANDLE = 0x00; static const AdvHandle_t LEGACY_ADVERTISING_HANDLE = 0x00;
static const uint8_t LEGACY_ADVERTISING_MAX_SIZE = 0x1F;
/** Special advertising set handle used as return or parameter to signify an invalid handle. */ /** Special advertising set handle used as return or parameter to signify an invalid handle. */
static const AdvHandle_t INVALID_ADVERTISING_HANDLE = 0xFF; static const AdvHandle_t INVALID_ADVERTISING_HANDLE = 0xFF;