Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

Bluetooth® LE: Change advertisement and scan response data during advertising - KBA230308

Bluetooth® LE: Change advertisement and scan response data during advertising - KBA230308

ArunKumarChoul
Employee
Employee
50 questions asked 50 sign-ins 25 sign-ins

Version: **

Affected products: PSoC™ 4 and PSoC™ 6 MCUs with AIROC™ Bluetooth® LE.

In Bluetooth® LE GAP Peripheral role, when a device is advertising, you can change the advertisement and scan response data by using APIs as follows:

For PSoC 4 CY8C4x47xx-BLxxxx MCU with AIROC Bluetooth® LE:
The CyBle_GapUpdateAdvData API function is used for setting the advertisement and scan response data while advertising is ongoing. This API function must be called when CyBle_GetBleSsState() returns the CYBLE_BLESS_STATE_EVENT_CLOSE state. See the following sample code segment:

if(CyBle_GetBleSsState() == CYBLE_BLESS_STATE_EVENT_CLOSE)
     {
        /* Update the ADV and Scan Response data */
        cyBle_discoveryModeInfo.advData->advData[5]=0x06;
        cyBle_discoveryModeInfo.scanRspData->scanRspData[5]=0x05;
        /* Update the ADV and Scan Response data */
        CyBle_GapUpdateAdvData(cyBle_discoveryModeInfo.advData,
        cyBle_discoveryModeInfo.scanRspData);

     }

For PSoC 6 CY8C63x7 MCU with AIROC Bluetooth® LE:
The Cy_BLE_GAPP_UpdateAdvScanData API function is used for setting the advertisement and scan response data while advertising is ongoing. On completion of this operation, the GAP Peripheral application receives the CY_BLE_EVT_GAPP_UPDATE_ADV_SCAN_DATA_COMPLETE event. This API function must be called when Cy_BLE_StackGetBleSsState() returns the CY_BLE_BLESS_STATE_EVENT_CLOSE state. See the following sample code segment:

     if(Cy_BLE_GetAdvertisementState() == CY_BLE_ADV_STATE_ADVERTISING)
     {
        if(Cy_BLE_StackGetBleSsState() == CY_BLE_BLESS_STATE_EVENT_CLOSE)
        {
           /* Updating the ADV and SCAN Response data */
           cy_ble_discoveryModeInfo->advData->advData[5]='A';
           cy_ble_discoveryModeInfo->scanRspData->scanRspData[5]='A';
           /* Updating the ADV and SCAN Response data */
           Cy_BLE_GAPP_UpdateAdvScanData(cy_ble_discoveryModeInfo);
        }
     }

0 Likes
590 Views