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

Sending scanning data via UART

Hey guys. I am making a firmware using nrf52840 dongle which scans nearby bluetooth devices. I do not want to connect to any device, just send scanning data to another device via UART.

Below is the code where I am getting scanning data on console

static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{

switch (p_ble_evt->header.evt_id)
{
 case BLE_GAP_EVT_ADV_REPORT:
 {
      NRF_LOG_RAW_HEXDUMP_INFO (m_scan.scan_buffer.p_data, m_scan.scan_buffer.len);
      NRF_LOG_RAW_INFO ("----------------------------------\r\n");
}

 default:
 break;
}

}

I changed nrf logging tx pin and connect to my other device and got the same result, but it gives me ascii format such as I want 4C in hex but it is giving me 4C in ascii, so now I want to use uart and send hex data, but same as I am getting in ascii.

My other code is below, but it is not giving me the right result. I want advertisement data to be sent to other device via uart and I will decode the data on that side to get only ble beacons and extract MAC address from the advertised data. I hope you guys understand me.

static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{

ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt;
uint8_t uuid[30];
uint8_array_t adv_data;

switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_ADV_REPORT:
{
for (int i=0;i<100;i++)
{
  app_uart_put(p_gap_evt->params.adv_report.data.p_data);
}

}
}


}

Your suggestion will be appreciated.

Regards,

Related