laptou / bluez-rs

Control Bluetooth on Linux.
MIT License
39 stars 9 forks source link

Panic after device connect #3

Closed timvisee closed 4 years ago

timvisee commented 4 years ago

After confirming a connection request, I'm getting a panic happening at the following line:

https://github.com/laptou/bluez-rs/blob/02ec3fc08f6f10e4717ed7dfa3e0a2f3c2354676/src/interface/response.rs#L75

This apparently comes up when processing the NewLongTermKey event.

buf.get_u8() gives a 3. The FromPrimitive helper can't parse this into a LongTermKeyType which is why it panics.

Any idea what is going on?

laptou commented 4 years ago

Got it. I implemented this according to the BlueZ spec and it defines the long term key type enum inconsistently for different events:

https://github.com/Vudentz/BlueZ/blob/4e926f8e3ef2e3321f9b169db54ec256d9b41207/doc/mgmt-api.txt#L859-L862

https://github.com/Vudentz/BlueZ/blob/4e926f8e3ef2e3321f9b169db54ec256d9b41207/doc/mgmt-api.txt#L3108-L3114

So I didn't see the version of the enum that includes the value 3.

timvisee commented 4 years ago

Awesome. Thanks for the quick fix!