Hi,
I'm developing a simple software that records RSSI values from both the Central and Peripheral device, using nRF5 SDK 15, adapting from two of the provided examples:
ble_app_multipheral for the server/peripheral & ble_app_blinky_c for the client/central.
My issue arose when I was getting a positive value for the RSSI in the server.
static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
ret_code_t err_code;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
{
on_connected(&p_ble_evt->evt.gap_evt);
} break;
case BLE_GAP_EVT_DISCONNECTED:
{
on_disconnected(&p_ble_evt->evt.gap_evt);
} break;
case BLE_GAP_EVT_RSSI_CHANGED:
{
NRF_LOG_DEBUG("**RSSI** On RSSI Change Event Received...");
on_rssi_change(&p_ble_evt->evt.gap_evt);
/*** < To Do: Change from Event to periodic sampling > ***/
} break;
/**@brief Function for handling the Connected event.
*
* @param[in] p_gap_evt GAP event received from the BLE stack.
*/
static void on_connected(const ble_gap_evt_t * const p_gap_evt)
{
ret_code_t err_code;
uint32_t periph_link_cnt = ble_conn_state_peripheral_conn_count(); // Number of peripheral links.
uint16_t conn_handle = p_gap_evt->conn_handle;
NRF_LOG_INFO("Connection with link 0x%x established.", conn_handle);
err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_CONN, conn_handle, TX_POWER);
APP_ERROR_CHECK(err_code);
// Assign connection handle to available instance of QWR module.
for (uint32_t i = 0; i < NRF_SDH_BLE_PERIPHERAL_LINK_COUNT; i++)
{
if (m_qwr[i].conn_handle == BLE_CONN_HANDLE_INVALID)
{
err_code = nrf_ble_qwr_conn_handle_assign(&m_qwr[i], conn_handle);
APP_ERROR_CHECK(err_code);
break;
}
}
sd_ble_gap_rssi_start(conn_handle, RSSI_THRESHOLD_DBM, RSSI_SKIP_COUNT); // Enable RSSI Scanning for this connection
ble_pds_assign_handle(&m_pds, conn_handle);
link_led_update(periph_link_cnt);
if (periph_link_cnt == NRF_SDH_BLE_PERIPHERAL_LINK_COUNT)
advertising_stop(); // All connections were taken, stop advertising.
else
advertising_start(); // Continue advertising. More connections can be established because the maximum link count has not been reached.
}
/**@brief Function for handling the Changed RSSI event.
*
* @param[in] p_gap_evt GAP event received from the BLE stack.
*/
static void on_rssi_change(ble_gap_evt_t const * const p_gap_evt)
{
ret_code_t err_code;
uint16_t conn_handle = p_gap_evt->conn_handle;
NRF_LOG_DEBUG("**RSSI** Sent: %d", p_gap_evt->params.rssi_changed.rssi);
ble_pds_send_rssi(conn_handle,
&m_pds,
p_gap_evt->params.rssi_changed.rssi);
}
Trying to debug this code, I tried using some "NRF_LOG_DEBUG()" functions, they work perfectly everywhere but when a RSSI Changed Event occurs, they don't show on the debug terminal.

I don't understand this behaviour.
As for the information received on the central / client:

It's own RSSI reading is working properly but the information sent by the client is not correct, while debugging with breakpoints this happens (data comes empty):

And when debugging the on_rssi_change function, the ble_event -> gap_event . params . rssi_changed is empty.

I hope I was able to convey my problem clearly.
Thank you in advance for taking your time to help me.
Marco Corrente.