micropython / micropython-lib

Core Python libraries ported to MicroPython
Other
2.39k stars 994 forks source link

The order of bt_addr passed up in the ScanResult #884

Open brianreinhold opened 3 months ago

brianreinhold commented 3 months ago

In the aioble code there is a line like this:

self.addr: bytes = addr if len(addr) == 6 else binascii.unhexlify(addr.replace(":", ""))

The unhexify part with the colons suggests the bt address is passed up to the application in big endian. You don't see BT addresses expressed in little endian with colons.

The normal way one would write the BT address on a device is ae:f4:27:9F:d2:ee. In BLE this would be transmitted as ee d2 9f 27 f4 ae.

It's not clear what I get in ScanResult.device.addr

is it ee d2 9f 27 f4 ae or ae f4 27 9F d2 ee?

AgentSonji commented 2 months ago

From what I am seeing it appears that you get back ae f4 27 9F d2 ee from entering ae:f4:27:9F:d2:ee. I don't see anywhere where the address gets packed into big endian. Although I admit my ignorance as to the fine details of the bluetooth module.