shmuelzon / esp32-ble2mqtt

A BLE to MQTT bridge running on an ESP32
MIT License
682 stars 108 forks source link

Try pairing when descriptor write fails #190

Open dakhnod opened 1 year ago

dakhnod commented 1 year ago

The code tries pairing with a BLE device when an initial characteristic read operation fails, and then tries to read the value again after pairing.

Yet, there might be a failing descriptor write operation first, or no characteristic read at all. Hence, this code adds handling of such a case by buffering every write, issuing pairing if needed and re writing the descriptor.

This code is just a starting point. @shmuelzon How would you buffer the writes?

dakhnod commented 1 year ago

@shmuelzon any comment on this?

dakhnod commented 1 year ago

@shmuelzon how about this: Instead of focusing on single operations, we run the regular initialization routine as it used to be. When we hit an insufficient-encryption or encryption we try bonding, and then re-run the regular routine from start. That way, all possible types of read/write operations should be covered.