Will it be possible to upload your project?
Link layer privacy is required to Resolve Private address at the link layer (a feature of BLE 4.2) or to use Resolvable private address for advertisement. However, for your application you do not need LL privacy feature. You can refer to section 7 of AN99209 for complete details on Link Layer privacy or can read the BLE 4.2 spec as well .
For your issue, are you calling Cy_BLE_StoreBondingData API till cy_ble_pendingFlashWrite is 0 to store the bonding data? Are you generating the keys and setting them for every connection?
Meenakshi Sundaram R
Thanks for the reply. I can't really upload my project.
I was able to make the bonding work with my parameters by modifying the example project CE212742, but I am having issues porting it to my project. It might have something to do with the fact that I am using the PSoC 6 in single core mode (only using the CM0p). Right now, my issue seems to be that the call to Cy_BLE_StoreBondingData() fail and returns CY_BLE_ERROR_FLASH_WRITE.
Let me know if you have any idea why that would happen.
Do you have Cy_SysEnableCM4() API call in your code? If not, can you call the API and in the CM4 code, put the core to deep sleep (if not using).
If you have SysEnableCM4 in your code already, then I think I will have to take a look at the code to see what is happening.
If you cannot upload the code, then can you put a Breakpoint in "Cy_BLE_HAL_NvramWrite" API present in "cy_ble_hal_pvt.c" file and let me know in which line of code it fails (you will have to step till the "swtich(rc)" switch case and then see what is the value of rc).
Meenakshi Sundaram R
I have added the Cy_SysEnableCM4() and then put the CM4 to sleep. I still get the CY_BLE_ERROR_FLASH_WRITE.
I have added a breakpoint like you asked in Cy_BLE_HAL_NvramWrite() and the value of rc at the switch case is CY_FLASH_DRV_IPC_BUSY.
What does it tell you?
CY_FLASH_DRV_IPC_BUSY can be a result of multiple cases.
Since you are not uploading the project, you will need to do the debug for me
Can you break in Cy_Flash_SendCmd API and let me which line of the API returns CY_FLASH_DRV_IPC_BUSY error? Also, this API will be called two times (Erase and Program) per Cy_BLE_HAL_NvramWrite() API, so let me know which call it fails.
Since you do not use CM4, you can call Cy_SysDisableCM4() API in the beginning. This should narrow down "if" statement in the Cy_Flash_SendCmd API.
Calling Cy_SysDisableCM4() has solved the flash error issue, but the bonding still doesn't work.
After pairing, if I disconnect and reconnect, I need to pair again.
I don't really care for privacy at the moment, so I would like for my device to use a public address, but it needs to work with an Android phone that uses a private address. All I need is for the bonding to work so I don't need to pair manually every time. Could you give me a list of steps that are required to do this so I can verify that I am doing the right things?
I found the issue!
I was casting the eventParam to the wrong type in CY_BLE_EVT_GAP_ENHANCE_CONN_COMPLETE since LL Privacy is enabled.
Bonding works fine now.
Thanks for your help.