I have a custom board that has a nRF52832 device (receiver). I am scanning for remote beacons (also custom boards with nRF82832). The result is that I obtain the MAC of the beacon closest (best RSSI) to the receiver. All remote beacons have the same device_name set. When scanning, I first search for beacons that have the device_name. If the device_name is found, I then read the RSSI value. Once the RSSI value is obtained, I compare it with the previously obtained RSSI. If "if(last_beacon.rssi < p_adv_report->rssi)" then I "last_beacon.rssi = p_adv_report->rssi;"
My problem is that when I enter the following line in my code to display the RSSI in my debugger, my code stops. "cPrintLog(CDBG_FCTRL_INFO,"Beacon RSSI : %s\n",p_adv_report->rssi );"
I am using Keil uVision.
My Code:` case BLE_GAP_EVT_ADV_REPORT: { const ble_gap_evt_adv_report_t * p_adv_report = &p_gap_evt->params.adv_report; { {
// Prepare advertisement report for parsing.
adv_data.p_data = (uint8_t *)p_gap_evt->params.adv_report.data;
adv_data.size = p_gap_evt->params.adv_report.dlen;
// Search for advertising names.
err_code = adv_report_parse(BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME,
&adv_data,
&dev_name);
if (err_code != NRF_SUCCESS)
{
// Look for the short local name if it was not found as complete.
err_code = adv_report_parse(BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME, &adv_data, &dev_name);
if (err_code != NRF_SUCCESS)
{
// If we can't parse the data, then exit.
return;
}
else
{
found_name = true;
}
}
else
{
found_name = true;
}
if (found_name)
{
if (strlen(m_target_periph_name) != 0)
{
if (memcmp((char*)dev_name.p_data,m_target_periph_name , dev_name.size) == 0)
{
if(last_beacon.rssi < p_adv_report->rssi)
{
for(count = 0;count < 6; count++)
{
last_beacon.addr[count] = p_adv_report->peer_addr.addr[5-count];
}
last_beacon.rssi = p_adv_report->rssi;
}
cPrintLog(CDBG_FCTRL_INFO,"found beacon : %s\n",dev_name.p_data );
// cPrintLog(CDBG_FCTRL_INFO,"Beacon RSSI : %s\n",p_adv_report->rssi );
cPrintLog(CDBG_FCTRL_INFO,"Scanning target: %02x%02x%02x%02x%02x%02x\r\n",
p_adv_report->peer_addr.addr[0],
p_adv_report->peer_addr.addr[1],
p_adv_report->peer_addr.addr[2],
p_adv_report->peer_addr.addr[3],
p_adv_report->peer_addr.addr[4],
p_adv_report->peer_addr.addr[5]
);
}
}
}
}
}
}break;`