1 of 1 people found this helpful
I see a mistake in your CY_BLE_EVT_GET_RSSI_COMPLETE event handling. The eventParam for this event is of type "cy_stc_ble_events_param_generic_t*" and the cy_stc_ble_events_param_generic_t structure has another element called "eventParams" and this is the element that contains the "cy_stc_ble_rssi_info_t*". So modifying the rssi_param line to below fixed the issue.
rssi_param = (cy_stc_ble_rssi_info_t*)(((cy_stc_ble_events_param_generic_t*) eventParam)->eventParams);
Some other notes -
1. In the CY_BLE_EVT_GAP_DEVICE_CONNECTED event, you don't have to get the address and then use GetPeerBdHandle to retrieve the bdHandle. The bdHandle member/element of "conn_param" already contains the bdHandle of the peer. So you can directly use it (conn_param->bdHandle).
2. Even though in theory RSSI gives approx. estimate of the distance from the peer. It should be noted that the environment loss can vary a lot and the distance estimated from RSSI might not give the actual distance (because of varying and lossy nature of environment). You will have to model your environment, find out the loss (again this can change) and the use it in RSSI equation to arrive at the distance. I hope you already understand this
Let me know if this helps.
Meenakshi Sundaram R