I have beacon that broadcast its name with type 09. I cannot get it while scanning of nrf_uart_c (adv_report).
I assume I need to activate scan_req and then parse the response data - how can I do it?
I have beacon that broadcast its name with type 09. I cannot get it while scanning of nrf_uart_c (adv_report).
I assume I need to activate scan_req and then parse the response data - how can I do it?
Hi Avi,
Yes correct. If you use the nrf_ble_scan module, you need to set active=true in your scan param ble_gap_scan_params_t you feed into nrf_ble_scan_init().
The scan response packet will be reported the same as a normal advertising packet. It's reported to the application either by NRF_BLE_SCAN_EVT_FILTER_MATCH or NRF_BLE_SCAN_EVT_WHITELIST_ADV_REPORT if you use filter or by NRF_BLE_SCAN_EVT_NOT_FOUND event if you don't use any filter.
It is already set to active in the original code:
static void nrf_ble_scan_default_param_set(nrf_ble_scan_t * const p_scan_ctx)
{
// Set the default parameters.
p_scan_ctx->scan_params.active = 1;
I add SCAN NAME filter and also the releavnt part in the sdk_config and cannot get the scan_req data
If I use the blinky example it works (both in the peripheral and in the central).
My beacon data is as follows:
Hi,
I am able to read this data using the following way:
uint8_t *device_name;
device_name = ble_advdata_parse(p_adv_report->data.p_data, p_adv_report->data.len, BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME);
NRF_LOG_INFO("%s",device_name);
It means that I it trasnmitted and recieved.
But how can it be filtered?
Thanks
Avi
Hi Avi,
Then it should parsed correctly in the filter. You may want to add a breakpoint inside nrf_ble_scan_on_adv_report() where adv_name_compare() is called.
I checked with breakpoints, the comparison fails but there is no data that I can see (null).
It would be great if you can prepare a version of NRF_UART_C with Scan Name example that works
I was able to find a solution:
In ble_advdata.c, function: bool ble_advdata_name_find
I changed the lines:
//p_parsed_name = &p_encoded_data[data_offset];
p_parsed_name = ble_advdata_parse(p_encoded_data, data_len, BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME);
//if ( (data_offset != 0)
// && (parsed_name_len != 0)
// && (strlen(p_target_name) == parsed_name_len)
// && (memcmp(p_target_name, p_parsed_name, parsed_name_len) == 0))
if ( (data_offset != 0)
&& (parsed_name_len != 0)
&& (parsed_name_len >= strlen(p_target_name))
&& (memcmp(p_target_name, p_parsed_name, strlen(p_target_name)) == 0))
I'm glad that you are able to find a solution. I'm not entire sure why the original code doesn't work for you but it works for normal advertising packet.
I'm glad that you are able to find a solution. I'm not entire sure why the original code doesn't work for you but it works for normal advertising packet.