decoder
decoder copied to clipboard
Give decoders access to the device's Bluetooth address
Is your feature request related to a problem? Please describe.
I'd like to implement a decoder for AirTag advertisements. The public key advertised by an AirTag is partly encoded in the device's Bluetooth address. So the decoder should have access to this address.
Describe the solution you'd like
A function device_address that returns a hex string of the Bluetooth address, e.g. de479e575f8b.
Describe alternatives you've considered
None
Additional context
I think I'll also need some kind of concatenation function for hex strings. See https://github.com/koenvervloesem/openhaystack-zephyr/blob/main/modules/openhaystack/src/openhaystack.c for how the public key is encoded. The first six bytes of the public key are encoded in the Bluetooth address, then come some bytes encoded in the manufacturer data.
Hi @koenvervloesem, just to clarify a few points
• will a property function device_address suffice (initially), or would a model condition and/or property condtion for the MAC address also be required?
• With a property function something like
"decoder":["string_from_mac_address", 6, 6]
to get a substring from index 6 with length 6?
• For string concatenation an additional functionality could be implemented in post_proc, so that one substring could be acquired in a .cal property, then post_proc concatenated with a second substring acquired through "string_from_hex_data"!?!
A string_from_mac_address function seems like an excellent solution.
Concatenation of hex strings in post_proc seems fine too.
Not following this up at the moment because with the constantly rotating MAC address this would never allow to identify one specific AirTag, but only show an ever changing cryptic public key, which would not really be useful for any user implementation.
Decoder accessing the MAC address and implementing a future string concatenation functionality is still on the table if and when such functionalities are required for utilitarian properties.
Implemented model condition access to device's MAC address in correct order or reversed with
https://github.com/theengs/decoder/pull/263
Closing as implemented.