I'm just starting to play with my pyboard-D and I am a bit confused how it reports mac addresses. for instance,
>>> w.config('mac')
b'HJ0\x01\xb2\xd0'
I understand that the b' means that it is a byte string and that the H means they are unsigned short integers, but I dont understand why there only seem to be three integers in the mac address. I am used to seeing mac addresses as a group of six integers in hexadecimal, like this, abef:12:34:56. I have just learnt from the internet that the first three integers in a mac address identify the manufacturer, is that why the w.config('mac') only reports three integers? Is the J0 something to do with the manufacturers OUI code? (OUI={Organizationally Unique Identifier}
How network.WLAN reports a mac address
Re: How network.WLAN reports a mac address
The byte string is all bytes, 6 in total. H is just a byte with the hex value 0x48, J is 0x49, 0 is 0x30, so all in all it is:
48:49:30:01:b2:d0. To see the usual representation, you can convet it to hex using ubinascii.hexlify()
48:49:30:01:b2:d0. To see the usual representation, you can convet it to hex using ubinascii.hexlify()
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: How network.WLAN reports a mac address
Code: Select all
>>> mac = b'HJ0\x01\xb2\xd0'
>>> '{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}'.format(*mac)
'48:4a:30:01:b2:d0'
>>>
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.