Periodic Advertising with Responses (PAwR) {#periodic_advertizing_with_responses}
This section describes the Central and Peripheral setup for Periodic Advertising with Responses (PAwR).
Central Setup
Start scanning using
Gap_StartScanning
. Wait forgPeriodicDeviceScannedV2_c
events in the scanning callback.Synchronize with a periodic advertiser by calling
Gap_PeriodicAdvCreateSync
. Wait for thegPeriodicAdvSyncEstablished_c
event in the scanning callback. When PAwR is involved, this event includes additional information such as number of subevents, subevent interval, response slot delay and spacing,Synchronize to a PAwR subevent by calling
Gap_SetPeriodicSyncSubevent
. This API instructs the Controller to sync with a subset of the subevents within a PAwR train identified by syncHandle (obtained after synchronizing with the PAwR train in the previous step).bleResult_t Gap_SetPeriodicSyncSubevent ( uint16_t syncHandle, const gapPeriodicSyncSubeventParameters_t* pParams );
Wait for the
gPeriodicSyncSubeventComplete_c
event.Use
Gap_SetPeriodicAdvResponseData
to set data in the AD format which would be sent as a Periodic Advertising Response to the broadcaster.bleResult_t Gap_SetPeriodicAdvResponseData ( uint16_t syncHandle, const gapPeriodicAdvertisingResponseData_t* pData );
Optionally, the periodic advertiser may initiate a connection. If no connection callback was set on the scanner via APIs such as
Gap_Connect
orGap_StartAdvertising/Gap_StartExtAdvertising
, one must be explicitly set. This is achieved by callingBluetoothLEHost_SetConnectionCallback
(defined inapp_conn.h
), which in turn callsGap_SetConnectionCallback
.void Gap_SetConnectionCallback ( gapConnectionCallback_t pfConnectionCallback );
Parent topic:Periodic Advertising with Responses (PAwR)
Peripheral Setup
First set the extended advertising parameters using
Gap_SetExtAdvertisingParameters
. The extended advertising type must be set to non-connectable and non-scannable.Set the periodic advertising parameters with the same handle as in the previous command. Use the
Gap_SetPeriodicAdvParametersV2
command. Compared toGap_SetPeriodicAdvParameters
, this command also configures parameters relevant to PAwR, such as the number of subevents and response slots as well as timing information.
bleResult_t Gap_SetPeriodicAdvParametersV2
(gapPeriodicAdvParametersV2_t* pAdvertisingParameters);
Wait for a gPeriodicAdvParamSetupComplete_c
event in the generic callback.
Start extended advertising using
Gap_StartExtAdvertising
.Start periodic advertising using
Gap_StartPeriodicAdvertising
.Wait for
gPerAdvSubeventDataRequest_c
events. These events are used by the Controller to indicate that it is ready to transmit one or more subevents and it is requesting the advertising data for these subevents. Upon receiving an event, useGap_SetPeriodicAdvSubeventData
to set the advertising data for specific subevents.
bleResult_t Gap_SetPeriodicAdvSubeventData
(uint8_t advHandle, const gapPeriodicAdvertisingSubeventData_t* pData);
Wait for the gPeriodicAdvSetSubeventDataComplete_c
event in the generic callback.
Wait for
gPerAdvResponse_c
events. These events contain responses sent by devices who are synchronized to the periodic advertising. They include data in the AD format.Optionally, PAwR allows the advertising device to initiate a connection to one of the synchronized scanners. The connection can be initiated by calling
Gap_ConnectFromPawr
.
bleResult_t Gap_ConnectFromPawr
(const gapConnectionFromPawrParameters_t* pParameters, gapConnectionCallback_t connCallback);
Parent topic:Periodic Advertising with Responses (PAwR)
Parent topic:Generic Access Profile (GAP) Layer