Bluetooth-Devices / bthome-ble

Parser for BTHome BLE devices
https://bthome.io/
MIT License
74 stars 16 forks source link

Add 2-way communication for acknowledgement and control? #146

Open EternityForest opened 2 months ago

EternityForest commented 2 months ago

Is your feature request related to a problem? Please describe.

Right now it doesn't seem like there's any way to use bthome for something like a controllable relay, or for a remote control button where the user would expect reliability.

Describe the solution you'd like A clear and concise description of what you want to happen.

A simple anycast acknowledgement scheme could be very useful, if there was a way to mark a packet as acknowledgeable, and to tell a device you've already heard it and it can be quiet now.

Perhaps the same back channel could also be used to control things like relays.

Additional context Add any other context or screenshots about the feature request here.

Ernst79 commented 2 months ago

BTHome is (at this moment) a protocol that uses passive BLE messages, so only one way communication is possible right now. 2 way communication is possible with BLE, ,but that would require to set up a connection. That is a different communication technique.

My skills lack to implement this, but I think we will welcome contributions from others if they want to add this somehow. Unfortunately, I can’t help with that.

EternityForest commented 2 months ago

If there's interest, I might be able to find some time to create a prototype. I can think of a few different ways it could be done.

The simplest could be to just reuse exactly the same protocol that's already there, since there's already object types that could fit a lot of common use cases.

A new acknowledgement ID object could be created, you could just write that same object back to the device to acknowledge it?

I'm not sure exactly how the encryption would work in that case though, implementing it in a fully safe way with only a 4 byte counter for the nonce could be a challenge.

On Tue, Sep 3, 2024, 11:07 PM Ernst Klamer @.***> wrote:

BTHome is (at this moment) a protocol that uses passive BLE messages, so only one way communication is possible right now. 2 way communication is possible with BLE, ,but that would require to set up a connection. That is a different communication technique.

My skills lack to implement this, but I think we will welcome contributions from others if they want to add this somehow. Unfortunately, I can’t help with that.

— Reply to this email directly, view it on GitHub https://github.com/Bluetooth-Devices/bthome-ble/issues/146#issuecomment-2327930989, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFZCH7DY7NWGSTEHCFNBFTZU2IS3AVCNFSM6AAAAABNTHN7UKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRXHEZTAOJYHE . You are receiving this because you authored the thread.Message ID: @.***>

thecode commented 2 months ago

@EternityForest I suggest you first check if ESPHome meets your requirements, it has a BLE client and support active connections to devices.

The protocol used here is based on advertising from sensors (connection-less), in BLE you can't simply send a response back to an advertising, you have to make an active connection to the device first which is a longer process and battery consuming, so the process of clicking on a button on a remote control, creating a BLE link and sending back an ACK may take too long for a decant user experience.