Hello,
I'm using the nordic UART service and am successfully using it as a bluetooth serial console to an ESP32-S3 on a mobile phone.
My only issue is that sometimes I overrun the internal tx message FIFO and messages get dropped. I was using the ble_gap_event callback to detect when a TX message was sent with BLE_GAP_EVENT_NOTIFY_TX, and thus safe to send another packet. But it seems that this callback is actually called from the same context as ble_gatts_notify_custom when the message is actually placed into the FIFO, NOT when it is sent out through the PHY.
I'm not actually trying to achieve maximum throughput, and my app does not need max throughput. Its just that some console commands generate lots a separate messages and I want a method to queue up each packet before being allowed to send. It seems like the Nimble internal FIFO/queue is around 18 or 19 long.
What can I call to discover the FIFO status? I want to block until it is ok to continue pushing out packets.
Thanks in advance!
NimBLE tx data sent callback is not from an interupt.
-
zachleedogg
- Posts: 3
- Joined: Tue Oct 28, 2025 6:42 pm
-
MicroController
- Posts: 2669
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: NimBLE tx data sent callback is not from an interupt.
You may want to use indications instead of notifications. And/or implement a timeout, e.g. 50ms, so that you collect data until you either have 'enough' data or the timeout expires, before sending it out.
-
zachleedogg
- Posts: 3
- Joined: Tue Oct 28, 2025 6:42 pm
Re: NimBLE tx data sent callback is not from an interupt.
Thanks, i'll look into that.
I still think it seems odd that there is no way to query the nimble buffer state before attempting to ble_gatts_notify_custom.
It seems that the only way to know if the buffer is full is to call ble_gatts_notify_custom and look for ENOMEM error returned.
I just thought there would be a cleaner way.
I still think it seems odd that there is no way to query the nimble buffer state before attempting to ble_gatts_notify_custom.
It seems that the only way to know if the buffer is full is to call ble_gatts_notify_custom and look for ENOMEM error returned.
I just thought there would be a cleaner way.
Who is online
Users browsing this forum: Qwantbot and 3 guests