virtualabs / btlejack

Bluetooth Low Energy Swiss-army knife
MIT License
1.9k stars 196 forks source link

Use select() to avoid burning the CPU when reading from the UARTs #42

Open nviennot opened 5 years ago

virtualabs commented 5 years ago

I tried to use select() when I was developping Btlejack, but always had a bigger latency and sometimes Btlejack missed some packets ... Anyway, I'll give your version a try and see if it saves my CPU :)

nviennot commented 5 years ago

Arguably, the latency should be better with the select() version when using multi devices, because the client will know which devices to read from, as opposed to try them all round robin. So if we have three devices, and only the third device has data to read, then we just return from the select() call, and invoke read() on the right device immediately.

Having said that, I have not benchmarked the latency.