This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Server Name extraction from received advertising data

I am trying to get the board advertiser name from the advertising data received by another scanner board. I am using softdevice S140 version 7.2.0.

The server board name is: "Nordic_Server". This is 13 characters. The client board is scanning and printing names of nearby servers. The problem is that data received length is 18 characters (data->len is 18 sometimes and 31 in another times). The rest 5 characters are varied randomly with each new advertising packet. The server and client are running versions of ble_app_uart and ble_app_uart_c respectively (Without automatic connection).

This is my code under BLE_GAP_EVT_ADV_REPORT event id:

const ble_gap_evt_adv_report_t *p_adv_report = &p_gap_evt->params.adv_report;
const ble_data_t *data = &p_adv_report->data;
uint8_t * device_name;

device_name = ble_advdata_parse(data->p_data, data->len, BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME);
int8_t report = p_ble_evt->evt.gap_evt.params.adv_report.rssi;

device_name[data->len] = 0;
print_string(device_name);

print_char('\n');

These are the names printed on the terminal:

There is always 5 extra characters printed randomly after the server name.

The root cause most probably can be from 3 sources:

1- The server is not sending its name correctly. (This is most probably NOT the case here as the name is detected correctly on my mobile phone and laptop).

2- The client is reading the advertising data in a wrong way (The softdevice has a bug when Bluetooth stack event is called with p_ble_evt)

3- The client is reading the advertising data in a wrong way (The ble_advdata_parse has a bug in retrieving the name from advertising data)

NOTE: Printing functionality is tested and verified well. It is excluded from possible sources of errors.

So does anyone has tested such a thing and worked correctly ???

Can anyone confirm that the name sent by the server is not concatenated with any garbage data ???

Related