Hi,
I’m currently developing an application for the nRF52833 that collects sensor data via SPI and sends it out over BLE using notifications. My primary goal is to achieve a stable, periodic notification interval. Specifically, I want the time between consecutive packets received by the central device to be as stable as possible.
Current Implementation
Here’s my current approach:static void notify_work_handler(struct k_work *work)
{
rc = bt_gatt_notify(NULL, &ess.attrs[1], val_ptr, sizeof(*val_ptr));
int freq = 1000 / get_current_MODR();
k_work_reschedule(k_work_delayable_from_work(work), K_MSEC(freq));
}
This setup uses bt_gatt_notify
to queue notifications. However, this causes the following issues:
Batching of Notifications: Notifications are sent in bursts, as many as the BLE stack can fit into a single connection interval. (According to my understanding)
My Desired Outcome
- The arrival time between two notification packtes should be stable. CurrentlyI observing multiple packets at once and sometimes skipping of connection intervals.
- I want to avoid multiple notifications arriving at the central device at the same time.
I also don't really care if values inbetween are lost. I would rather just send out the latest value at a regular interval. I understand that i would need to set the connection interval to my desired frequency but how would i go about the queuing of the packages and only sending the latest value once per connection interval?
In the appended image i captured the time difference between the arrival of the packets using the nrfSniffer with Wireshark. I set the frequency in the notify worker to 50hz and the connection interval was 7.5ms
Any advice would be greatly appreciated!