Dear all,
I'm using SDk130 and the Software is based on the ble_app_uart_c example. Now I want to scan the advertising data from a peripheral (device name, peer address, raw data etc.) and output it via UART on a terminal programm. The output is always interrupted by the "BLE_GAP_EVT_ADV_REPORT" event. I commented the routine sd_ble_gap_connect to not get an additional event. So, how to handle the output via UART correctly?
this is the code snippet
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code;
uint8_t cntData;
uint8_t devNameBuff[25], AdvData[31];
const ble_gap_evt_t * p_gap_evt = &p_ble_evt->evt.gap_evt;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_ADV_REPORT:
const ble_gap_evt_adv_report_t * p_adv_report = &p_gap_evt->params.adv_report;
if (is_uuid_present(&m_tb_uuid, p_adv_report))
{
for(cntData=0 ; cntData<31;cntData++)
{
AdvData[cntData] = p_adv_report->data[cntData];
}
uint16_t plen;
printf("Found target %02x%02x%02x%02x%02x%02x\n\tPower: %i\n\t dlen: %02x\n \tscan_rsp: %i\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],
p_adv_report->rssi,
p_adv_report->dlen,
p_adv_report->scan_rsp
);
err_code = sd_ble_gap_device_name_get(devNameBuff,&plen);
printf("device name: ");
for(cntData=0 ; cntData<25;cntData++)
{
printf("%02x ",devNameBuff[cntData]);
}
printf("\n");
for(cntData=0 ; cntData<31;cntData++)
{
printf("AdvData[%i]: %02x\n",cntData,AdvData[cntData]);
}
// err_code = sd_ble_gap_connect(&p_adv_report->peer_addr,
// &m_scan_params,
// &m_connection_param);
err_code = 0;
if (err_code == NRF_SUCCESS)
{
// scan is automatically stopped by the connect
printf("Connecting to 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;
...
}
this is the output I receive on the terminal program:
the output is always interrupted after 7th byte of data (but this can also differ).
Many thanks for your support!
BR, Robert
btw: Unfortunately, i don't know how to mark code in a question correctly.