Hi - I am trying to port some code from nRF5 SDK to NRF Connect SDK.
I set up a scan for a specific BT_SCAN_FILTER_TYPE_NAME name and then using the scan_filter_no_match event I get the details of the peripheral that caused the event.
I then make sure that the UUID matches what I am looking for and then see if the rssi is greater than the strongest value I have found so far. If so, then I save the peer address.
After three seconds I stop the scan and then start scanning again using SCAN_ADDR_FILTER so that that peripheral connects to me.
I would like to know how to achieve the same with NRF CONNECT SDK. Below is the existing code from NRF5 SDK.
Please help....
case NRF_BLE_SCAN_EVT_NOT_FOUND: // new case added. Implement ble_advdata.c->ble_advdata_name_find() type function here
{
ble_gap_evt_adv_report_t const * adv_report = p_scan_evt->params.p_not_found;
/* Scan encoded adv. payload for data of type BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME */
parsed_len = ble_advdata_search(adv_report->data.p_data, adv_report->data.len, &data_offset, BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME);
if (parsed_len != 0)
{
/* Name found if parsed_len != 0 */
p_parsed = &adv_report->data.p_data[data_offset];
// make sure not besecure
if (*p_parsed != 'B')
{
data_offset = 0;
parsed_len = ble_advdata_search(adv_report->data.p_data, adv_report->data.len, &data_offset, BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE);
p_parsed = &adv_report->data.p_data[data_offset];
if (parsed_len != 0)
{
if (memcmp(&bsc_service_uuid, p_parsed, parsed_len)== 0)
{
if (p_scan_evt->params.filter_match.p_adv_report->rssi > scanrssi)
{
memcpy_fast(&strongest_peer, &p_scan_evt->params.filter_match.p_adv_report->peer_addr, 8);
scanrssi = p_scan_evt->params.filter_match.p_adv_report->rssi;
sysStat.found = 1;
}
}
}
}
}
break;
}