Android Question Bluetooth latency on Samsung SM-T220

Arf

Well-Known Member
Licensed User
Longtime User
One of my products establishes a Bluetooth (classic) connection with my device and streams live data to my app, this is a medical device.
Packets are 32 bytes in length and sent every 100ms.
On my old Nexus 7 with Android 6.0.1, the packets are always received and decoded by my app approximately 100ms (+- 20ms or so jitter) and the graphing is smooth on screen.

On a much newer Samsung Tab A7 Lite with Android 13, the packets arrive every 100ms with less jitter for the first 4 seconds, then from precisely 4000 milliseconds onwards I get multiple packets in rapid succession every 500ms or so, which makes the onscreen graphing looking jumpy.

It is completely reproducible and always occurs exactly when 4 seconds of streaming has occurred - see log output below, the green is milliseconds between last packet being handled and current packet being handled (green pre 4000 ms, pink after) and the red is milliseconds since streaming started.

Does anyone have any idea as to whether this 4000ms could be a clue as to why this is happening? I am using AsyncStreams and there is no real overhead in my packet handling so these timings are the timings of when data arrives in the AsyncStreams NewData event.

1692777224407.png
 

techknight

Well-Known Member
Licensed User
Longtime User
How are you pausing/waiting between packet sends? I have learned on newer devices that sleeps, etc hold up the main thread in ways that cause bluetooth packets to jam up against one another. Only way I got around this was setting up a FIFO and a timer to send and return, no "sleeps" or wait fors.

Also, turn off the Wifi. newer samsung devices have notorious buggy bluetooth stacks that only seem to be solved when WiFi is disabled.

Those ancient phones/tablets had far better bluetooth chipsets, and the bluetooth chipset was separate from the Wifi chipset back then, so if there is a lot of WiFi activity its going to murder your bluetooth performance.
 
Last edited:
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
I have no sleeps at all in my app, it's all async event based. The NewData event is def not being held up by anything in my program. Good point about turning off the Wifi, I will try that.
The thing that bothers me is the whole 4000millisecond switchover, it's is so strange and 100% repeatable!
 
Upvote 0
Top