Hello,
We are developing a BLE beacon with nRF52810 and SDK17.0.0. I modified the code on the basis of ble_app_beacon. I rewrited m_advertising.adv_modes_config.ble_adv_fast_interval to change advertsing interval and through nRF connect for Android I find it worked. However, when I verified it by another scanner - a custom board based on nRF52832, I observed something wrong.
I used RTC1 to calculate elapsed time between two scanning.The relevant code is as follows:
uint32_t last_rtc1_ticks = 0;
uint32_t cur_rtc1_ticks = 0;
float ms_diff = 0;
uint8_t mac_addr[6];
void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
uint32_t err_code;
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:
memcpy(mac_addr ,p_gap_evt->params.adv_report.peer_addr.addr, 6);
if(accord_with_beacon_uuids(m_scan, m_beacon_uuids) && accord_with_specific_mac(mac_addr, test_mac))
{
if(last_rtc1_ticks == 0)
{
last_rtc1_ticks = app_timer_cnt_get();
return;
}
else
{
cur_rtc1_ticks = app_timer_cnt_get();
ms_diff = ((float)cur_rtc1_ticks - last_rtc1_ticks)/32;
last_rtc1_ticks = cur_rtc1_ticks;
}
}
break;
....
}
}
I debugged with it and the result is half of the setup, e.g., if I set the adv interval to 300ms, the ms_diff is usually about 150. Can you tell me what the problem is. Thanks in advance.