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

  1. Start scanning using Gap_StartScanning. Wait for gPeriodicDeviceScannedV2_c events in the scanning callback.

  2. Synchronize with a periodic advertiser by calling Gap_PeriodicAdvCreateSync. Wait for the gPeriodicAdvSyncEstablished_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,

  3. 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.

  4. 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 );
    
  5. Optionally, the periodic advertiser may initiate a connection. If no connection callback was set on the scanner via APIs such as Gap_Connect or Gap_StartAdvertising/Gap_StartExtAdvertising, one must be explicitly set. This is achieved by calling BluetoothLEHost_SetConnectionCallback (defined in app_conn.h), which in turn calls Gap_SetConnectionCallback.

    void Gap_SetConnectionCallback ( gapConnectionCallback_t pfConnectionCallback );
    

Parent topic:Periodic Advertising with Responses (PAwR)

Peripheral Setup

  1. First set the extended advertising parameters using Gap_SetExtAdvertisingParameters. The extended advertising type must be set to non-connectable and non-scannable.

  2. Set the periodic advertising parameters with the same handle as in the previous command. Use the Gap_SetPeriodicAdvParametersV2 command. Compared to Gap_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.

  1. Start extended advertising using Gap_StartExtAdvertising.

  2. Start periodic advertising using Gap_StartPeriodicAdvertising.

  3. 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, use Gap_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.

  1. 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.

  2. 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