Checklist
Feature description
A callback or method to know when a specific ACL packet (or packets) has left the controller.
Or, some method to know that the BLE controller will be able to handle an upcoming connection event for a given connection with sufficient time to enqueue notifications to be sent during that event.
Use cases
In our device, the BLE controller is quite busy handling many things all at once:
- Being a GATT Peripheral for a 1M PHY device
- Passively scanning for CODED PHY devices
- Updating and transmitting a CODED PHY extended advert
- Being a GATT Central to a CODED PHY device or listening to a CODED PHY periodic sync
I'd like to be able to send timestamped notifications to the 1M PHY Central connected to this device at the known connection interval with an attempt at latency no worse than the connection interval. With everything the controller is doing, I know (I've seen) that it won't be able to send a notification on every connection event and in some cases the delivery of the notification is quite delayed (ex: 180ms late when trying to use a 30ms interval).
BLE_GAP_EVENT_NOTIFY_TX events occur after the notification has been enqueued in either the controller or the host; not when its been sent. It is possible to fill up both queues and not have those enqueued notifications sent in a timely fashion. The Central ends up getting very stale data and new data gets dropped due to the queues being full.
Alternatives
Our current method is to use the value of ble_hs_hci_avail_pkts as a water line:
- Mark the value of
ble_hs_hci_avail_pkts before any timestamped notifications have been enqueued as the water line (grabbed within a ble_hs_lock()/ble_hs_unlock() block).
- Enqueue timestamped notification(s) (
ble_gatts_notify_custom()).
- Don't enqueue new timestamped data until
ble_hs_hci_avail_pkts is at or above the water line (value grabbed within a lock/unlock).
This might be flawed in some manner, but we've had success with this approach for a while.
Additional context
Given the HCI API, I know my alternate feature request (callback before when the controller might be able to handle a connection event for a given connection) is unlikely.
I decided to post this request after trying to build against ESP-IDF 5.5.3. The new BLE_STATIC_TO_DYNAMIC flag being on by default made ble_hs_hci_avail_pkts disappear. I know peaking at internal variables can be dangerous, but I otherwise have no clue how we are supposed to throttle notifications.
Checklist
Feature description
A callback or method to know when a specific ACL packet (or packets) has left the controller.
Or, some method to know that the BLE controller will be able to handle an upcoming connection event for a given connection with sufficient time to enqueue notifications to be sent during that event.
Use cases
In our device, the BLE controller is quite busy handling many things all at once:
I'd like to be able to send timestamped notifications to the 1M PHY Central connected to this device at the known connection interval with an attempt at latency no worse than the connection interval. With everything the controller is doing, I know (I've seen) that it won't be able to send a notification on every connection event and in some cases the delivery of the notification is quite delayed (ex: 180ms late when trying to use a 30ms interval).
BLE_GAP_EVENT_NOTIFY_TXevents occur after the notification has been enqueued in either the controller or the host; not when its been sent. It is possible to fill up both queues and not have those enqueued notifications sent in a timely fashion. The Central ends up getting very stale data and new data gets dropped due to the queues being full.Alternatives
Our current method is to use the value of
ble_hs_hci_avail_pktsas a water line:ble_hs_hci_avail_pktsbefore any timestamped notifications have been enqueued as the water line (grabbed within able_hs_lock()/ble_hs_unlock()block).ble_gatts_notify_custom()).ble_hs_hci_avail_pktsis at or above the water line (value grabbed within a lock/unlock).This might be flawed in some manner, but we've had success with this approach for a while.
Additional context
Given the HCI API, I know my alternate feature request (callback before when the controller might be able to handle a connection event for a given connection) is unlikely.
I decided to post this request after trying to build against ESP-IDF 5.5.3. The new
BLE_STATIC_TO_DYNAMICflag being on by default madeble_hs_hci_avail_pktsdisappear. I know peaking at internal variables can be dangerous, but I otherwise have no clue how we are supposed to throttle notifications.