I tried your code on my CYBT-413034-EVAL for several times but I seem not to repeat the fault?
After I press the reset button and the board restarts, I reconnect to CYBT-413034-EVAL and didn't find the FAIL result as what you posted. See my logs below:
connection_down 00 a0 50 __ __ 9c conn_id:1 reason:19
Advertisement State Change: 4
Hello Sensor Start
local keys read from NVRAM result: 0
hello_sensor_load_keys_for_address_resolution 00 a0 50 __ __ 9c result:0
Advertisement State Change: 3
hello_sensor_timeout: 1, ft:962
hello_sensor_timeout: 2, ft:1947
hello_sensor_timeout: 3, ft:2930
hello_sensor_timeout: 4, ft:3914
>>>conn_up; IdentityAddress retrieved
hello_sensor_conn_up 00 a0 50 __ __ 9c id:1
:**IdentityAddress: 00 a0 50 __ __ 9c result:Ok
Advertisement State Change: 0
NVRAM write 9
Advertisement State Change: 0
hello_sensor_timeout: 5, ft:4867
hello_sensor_timeout: 6, ft:5852
hello_sensor_gatts_req_cb. conn 1, type 5
Taking into consideration, I'm using CySmart 1.3 on Windows, with CY5677 USB Dongle. And the keys were saved to the resolving list at CySmart side in previous power cycle.
Please let me know if I misunderstood something.
That is because your client (CySmart 1.3 on Windows) using it's public address, not RPA for connection - pay attention that in your log returned connection/disconnection addresses are the same as your identity address! Try some device that will use RPA, not its public or static address for connection - you can see in my log which I posted: all the connections/disconnection events were from BD 57 68 55 9a f5 0e then (and now is already something else .. ), which is RPA, while the identity address of this device (when successfully reported is always e4 xx xx xx xx 4b ).
The device that I were using for this log is with Android 7.1 - same for Android 6.1 and I think back to Android 5 all were using RPA, but cant find older log before I upgraded this device (will double check and keep you posted if find something)
Android 4.4.4 though connects with its Public address and does not have the issue reported too (I didn't pay attention till now though - before I read your post ).
So obviously bug happens only when RPA is used, but not on those devices that don't use RPA/privacy and maybe have and some dependency and which Bluetooth version (4.0, 4.2 etc. is used)
I also tried using CySmart app, LightBlue app, and even LE Hello Client app (which can be found in <SDK_6.2>\common\peer_apps\hello_sensor\Android), on Android 7.1, to connect to your program. But they all failed to connect.
So then I went back using CY5677 on WIndows, which gave me the results showed above. In fact, even CY5677 can't connect to your program everytime.
As a contrast, the default hello_sensor program running on the same CYBT-413034- EVAL doesn't face the same problem and can be debugged successfully.
"My" program is exactly the Cypresse's program from SDK 6.2.1 with only added those lines @836 and this can be verified right away with any file compare utility like Examdiff:
// ss ***:
result = wiced_bt_get_identity_address ( p_status->bd_addr, identity_address ); // 1 Ok, 0 false
// WICED_BT_TRACE("**IdentityAddress: %B result:%d \n", identity_address, result );
WICED_BT_TRACE("**IdentityAddress: %B result:%s \n", identity_address, result?"Ok":"--FAIL--" );
Feel free to use any source code whatever you want, just try to get result from wiced_bt_get_identity_address when the client using RPA and the bonding to the client happened before current power cycle.
P.S. I also have problems with connecting bonded only devices as reported here and wiced_bt_get_identity_address (if was working) was one of the ways I was trying to bypass the other bug