Dear community,
I'm facing a problem during bluetooth scanning. I'm using the example named in the subject. This allows me to use the UART as debug printout.
I slightly adjusted the scan_evt_handler:
/**@brief Function for handling Scanning Module events.
*/
static void scan_evt_handler(scan_evt_t const * p_scan_evt)
{
ret_code_t err_code;
switch(p_scan_evt->scan_evt_id)
{
case NRF_BLE_SCAN_EVT_CONNECTING_ERROR:
{
err_code = p_scan_evt->params.connecting_err.err_code;
APP_ERROR_CHECK(err_code);
printf("Connecting error.\n");
} break;
case NRF_BLE_SCAN_EVT_CONNECTED:
{
ble_gap_evt_connected_t const * p_connected =
p_scan_evt->params.connected.p_connected;
// Scan is automatically stopped by the connection.
NRF_LOG_INFO("Connecting to target %02x%02x%02x%02x%02x%02x",
p_connected->peer_addr.addr[0],
p_connected->peer_addr.addr[1],
p_connected->peer_addr.addr[2],
p_connected->peer_addr.addr[3],
p_connected->peer_addr.addr[4],
p_connected->peer_addr.addr[5]
);
printf("connected.\n");
} break;
case NRF_BLE_SCAN_EVT_SCAN_TIMEOUT:
{
NRF_LOG_INFO("Scan timed out.");
printf("Scan timed out.\n");
scan_start();
} break;
default:
scanNr=(scanNr+1)%65535;
printf("scan/time: %u %d\n", scanNr, my_timer_get_ms());
NRF_LOG_INFO("Scanning evt.");
break;
}
}
To add the my_timer_get_ms(), I followed:
The problem is, that the scanner is not running smoothly, which means, it temporarely produces results each 0.1s (as expected from sdk_config setting: #define NRF_BLE_SCAN_SCAN_INTERVAL 160), but then it halts in com-viewer for about 1.2 seconds before resuming again.
As I can see from the timestamp, the CPU/timer is not stalled during these 1.2 seconds, because when operation resumes, the value of my_timer_get_ms() also increased by 1.2s.
Any advice or help on how to get rid of that 1.2 second sporadic scan-outages would be greatly appreciated.
Best regards,
Richard