问题现象:
目前需要动态调整Scan Response Data,发现了问题:
首先停蓝牙广播,更新广播数据,再开启广播这个过程,发现蓝牙广播成功停止,但是数据更新失败。Cy_BLE_GAPP_UpdateAdvScanData仍旧是CY_BLE_ERROR_INVALID_OPERATION;停广播后 Cy_BLE_StackGetBleSsState仍旧是DEEPSLEEP。并且这个函数的返回值不在SDK中定义的返回值列表中
解决方法:
[size=14.6667px]Please refer to below code to change Scan Response:
[size=14.6667px]cy_ble_configPtr-
>discoveryModeInfo[CY_BLE_PERIPHERAL_CONFIGURATION_0_INDEX].advData = &advdata;
cy_ble_configPtr-
>discoveryModeInfo[CY_BLE_PERIPHERAL_CONFIGURATION_0_INDEX].scanRspData =
&scanRspData;
/* Start Advertisement and enter discoverable mode */
Result = Cy_BLE_GAPP_UpdateAdvScanData(&cy_ble_configPtr-
>discoveryModeInfo[CY_BLE_PERIPHERAL_CONFIGURATION_0_INDEX]);
If (Result == CY_BLE_SUCCESS)
Cy_BLE_ProcessEvent();
[size=14.6667px]Where advdata and scanRspData are custom adv/scan response data array.
[size=14.6667px]The address of target data arrays can be directly assigned to cy_ble_configPtr-
>discoveryModeInfo[CY_BLE_PERIPHERAL_CONFIGURATION_0_INDEX].advData
[size=14.6667px]
If advertising is already on, Cy_BLE_GAPP_UpdateAdvScanData() can be
called. Otherwise, just call Cy_BLE_GAPP_StartAdvertisement after switching
data array point, and then Cy_BLE_GAPP_UpdateAdvScanData() can be called
inside it.
|