sputnikdev / eclipse-smarthome-bluetooth-binding

Eclipse SmartHome Bluetooth Binding
46 stars 10 forks source link

Add support for iGrill mini #81

Open jesperldk opened 5 years ago

jesperldk commented 5 years ago

This device needs authentication, but it seems to have been hacked already: https://github.com/bjoernhoefer/igrill

I am ready to give it a try to make a GATT specification, but I am clueless on how to make the authentication.

vkolotov commented 5 years ago

Right, I had a quick look at the way how authentication works for that device.

Effectively that python scripts sends a bytes sequence to a specific characteristic, then receives response then encrypts the response and sends it back to the device. This obviously is not supported at the moment.

The binding can do basic authentication so called "pin code" authentication, this is the very first part of the process above. Obviously two next parts are missing (receiving response, encrypting and sending back to device).

This class is responsible for pin code authentication strategy: https://github.com/sputnikdev/bluetooth-manager/blob/master/src/main/java/org/sputnikdev/bluetooth/manager/auth/PinCodeAuthenticationProvider.java

It would not be very difficult to add another one for your device, however this will require some changes not only in the BT manager, but also in Gatt parser (to somehow specify characteristics that are responsible for receiving encrypted response) and the binding itself.

jesperldk commented 5 years ago

Let me know how I can help. I can use a little time on it, and I do know Java. I do however unfortunately not have the time to spend days getting my way around all parts of you great binding, so if I should do anything it needs to be very directed - sorry about that.

By the way, have you seen this: https://medium.com/machine-learning-world/how-i-hacked-xiaomi-miband-2-to-control-it-from-linux-a5bd2f36d3ad That guy apparently hacked the authentication for a Xiaomi Miband and got it running on linux. If you are adding support for more types of devices it might be an idea to review this. And it might work for other Xiaomi devices as well?? (I have some on order ;-)

vkolotov commented 5 years ago

Unfortunately I don't have much time too. Giving that this device is quite rare and have a little demand, I'd say this will take some time to make it working.

Thanks for pointing out to that article, looks interesting.

Normally xiaomi devices use some proprietary authentication protocol that requires some native libraries. Also they normally advertise data, so as a workaround for the xiaomi auth we just listen to their advertisements which is more than enough. Have a read here: https://github.com/sputnikdev/eclipse-smarthome-bluetooth-binding/blob/master/xiaomi.md#important-note-for-all-xiaomi-devices

jesperldk commented 5 years ago

Thank you for your comments! I will return if I get the time later ;-)