I use two nRF52840 to send notifications every second. Analysis using a logic analyzer revealed that the reception interval had strange variations. What is causing this? Why is there a gap at 1 second from the reception?
connection interval 10ms.
I use two nRF52840 to send notifications every second. Analysis using a logic analyzer revealed that the reception interval had strange variations. What is causing this? Why is there a gap at 1 second from the reception?
connection interval 10ms.
Hi
Can you show me how you've set the connection interval in both peripheral and central, as well as how the notification is set to be transmitted every second in your application?
Best regards,
Simon
The program is based on the sample ble_app_blinky and ble_app_multilink. The connection interval defined MAX and MIN on the peripheral side.
For the notification of every second, the timeout was set every second using app_timer.
I also wanted to know the time it takes to send and receive, so I switched GPIOs just before the peripheral sd_ble_gatts_hvx and at the beginning of the on_hvx in the central, and observed. I wanted to check it as low as possible, but that was the limit I think.
This graph is the time from the transmission pin to the reception pin which I set measured on the logic analyzer. The time is [ms]. I am worried about the strange law of delay.
I'm sorry for my bad English.
Hi
Please upload a snippet of code showing your advertising_init function, as it is pretty hard to judge if it's correct when you're describing it rather than seeing it myself. Also, you say the time is ms. You mean that from 6.8 to 7.3 there are 0.5 seconds, right?
Best regards,
Simon
static void advertising_init(void) { ret_code_t err_code; ble_advdata_t advdata; ble_advdata_t srdata; ble_uuid_t adv_uuids[] = {{LBS_UUID_SERVICE, m_lbs.uuid_type}}; // Build and set advertising data. memset(&advdata, 0, sizeof(advdata)); advdata.name_type = BLE_ADVDATA_FULL_NAME; advdata.include_appearance = true; advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE; memset(&srdata, 0, sizeof(srdata)); srdata.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]); srdata.uuids_complete.p_uuids = adv_uuids; err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len); APP_ERROR_CHECK(err_code); err_code = ble_advdata_encode(&srdata, m_adv_data.scan_rsp_data.p_data, &m_adv_data.scan_rsp_data.len); APP_ERROR_CHECK(err_code); ble_gap_adv_params_t adv_params; // Set advertising parameters. memset(&adv_params, 0, sizeof(adv_params)); adv_params.primary_phy = BLE_GAP_PHY_1MBPS; adv_params.duration = APP_ADV_DURATION; adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED; adv_params.p_peer_addr = NULL; adv_params.filter_policy = BLE_GAP_ADV_FP_ANY; adv_params.interval = APP_ADV_INTERVAL; err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &adv_params); APP_ERROR_CHECK(err_code); }
is this OK?
In most cases, it is received after 6.8ms.
Why is the occasional reception delay concentrated in 0.5ms?
Hi
I see why you're confused. You're checking to see when the sd_ble_gatts_hvx event occurs, but this event does not actually transmit the packages, it is only adding them to the queue. So the reason you occasionally see these delays is that the chip isn't able to transmit the packet until the next connection interval, and therefore you don't get a new sd_ble_gatts_hvx event for some time.
Best regards,
Simon