Dear All,
I am trying to develop a simple BLE scanner that will scan for BLE beacons and print the retrieved packages.
I am using nRF5 SDK v16.0.0.
I have mostly succeeded in doing so, but I have noticed this:
When the softdevice broadcasts the BLE_GAP_EVT_ADV_REPORT event and after printing out the advertisement package the scanning seems to stop. In order to mitigate that I manually continue the scanning. My ble_evt_handler looks like this:
static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
ret_code_t err_code = NRF_SUCCESS;
ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_ADV_REPORT:
{
ble_gap_evt_adv_report_t const * p_adv_report = &p_gap_evt->params.adv_report;
NRF_LOG_INFO("Advertising packet received:");
NRF_LOG_RAW_HEXDUMP_INFO(p_adv_report->data.p_data, p_adv_report->data.len);
sd_ble_gap_scan_start(NULL, &m_data); // Manually continue scanning after printing out this result
} break;
...
}
}My scanner is configured like this:
#define SCAN_INTERVAL 0x00A0 /**< Determines scan interval in units of 0.625 millisecond. */
#define SCAN_WINDOW 0x0050 /**< Determines scan window in units of 0.625 millisecond. */
#define SCAN_TIMEOUT 0x0000 /**< Timout when scanning. 0x0000 disables timeout. */
/**@brief Scan parameters requested for scanning and connection. */
static ble_gap_scan_params_t m_scan_params =
{
.extended = 1,
.active = 1,
.interval = SCAN_INTERVAL,
.window = SCAN_WINDOW,
.filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL,
.scan_phys = BLE_GAP_PHY_CODED,
.timeout = SCAN_TIMEOUT,
};
static uint8_t data[255];
ble_data_t m_data = {
.p_data = data,
.len = 255
};
/**@brief Function to start scanning. */
static void scan_start(void)
{
ret_code_t ret;
ret = sd_ble_gap_scan_start(&m_scan_params, &m_data);
APP_ERROR_CHECK(ret);
}So my question is the following: Do I need to do the manual continuation of the scanning after a BLE device was discovered, or I am missing something in my configuration that causes this behaviour?
Please note that this behaviour is the same both for the 1MBPS_PHY and the CODED_PHY, I am using
Thank you very much for your assistance.