edwios / dotIoT

dotIoT projects
MIT License
0 stars 0 forks source link

BLE responses got dropped in dimond #3

Closed edwios closed 4 years ago

edwios commented 5 years ago

Module dimond was not able to get all BLE responses thus communication with devices has become unreliable.

edwios commented 5 years ago

Reason was due to btle did not have the suitable mechanism to catch and process all received BLE responses generated from different calling threads.

btle.py didn't handle incoming BLE responses well from bluepyhelper. There is a partial fix from the IanHarvey/bluepy but not merged to any branch: https://github.com/IanHarvey/bluepy/pull/355

This got rid of the ugly drop out problem where responses got dropped since this fix has stored everything in a queue (_lineq). However, it does not address the issues where threads are reading the wrong input because there is no control over who would receive what and when.

edwios commented 5 years ago

Latest commit addressed largely the out-of-sequence arrival of BLE responses by allowing the _getResp() to continue to read the whole queue and only drop what they have found to be theirs while leaving everything-else in the queue untouched.

edwios commented 4 years ago

Bluepy + RPi is a disaster. Ported dimond to pygatt and renamed package to telink in commit 772ac9326c618f324140916da01a7c017c1f7b15 Worked beautifully.