1 of 1 people found this helpful
If you need to use a fixed passkey, you need to set this during the CY_BLE_EVT_GAP_AUTH_REQ event and not during CY_BLE_EVT_STACK_ON event, the reason being the function uses the parameter which requires the bdHandle. The bdHandle is not available during the STACK ON event. You can modify your code as below:
cy_stc_ble_gap_auth_info_t gapAuthInfo = *(cy_stc_ble_gap_auth_info_t*)eventParameter;
/* appConnHandle should be set during the CY_BLE_EVT_GAP_DEVICE_CONNECTED event */
pk.fixedPassKey = 123456;
pk.isFixed = CY_BLE_GAP_PASSKEY_FIXED;
pk.bdHandle = appConnHandle.bdHandle;
apiResult = Cy_BLE_GAPP_AuthReqReply(&(cy_ble_configPtr-> authInfo[CY_BLE_SECURITY_CONFIGURATION_0_INDEX]));
Let me know if this helps.
(Edited my previous reply).
It looks like that worked, thanks for the suggestion!
Note for Cypress: The reason I had put the Cy_BLE_GAP_FixAuthPassKey() call in the CY_BLE_EVT_STACK_ON handler was because that is what the PDL documentation and source header said for that API call.
Good to know that your issue got resolved!
Thanks for pointing out the error in our PDL documentation ... We shall update the PDL documentation accordingly.