Skip to content

Commit dbd5524

Browse files
aykevldeadprogram
authored andcommitted
Add MAC accessor for returning the MAC in the usual format
The MAC address in the bluetooth.MAC type is little endian, the reverse of what is commonly used. The usual way a MAC address is printed is big endian. To simplify code, the Address() method will return the address in the usual (big endian) format.
1 parent 6b07e06 commit dbd5524

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

mac.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ func (mac MAC) String() string {
5656
return unsafe.String(unsafe.SliceData(buf), 17)
5757
}
5858

59+
// Address returns the MAC address in the typical (big-endian) format.
60+
func (mac MAC) Address() [6]uint8 {
61+
return [6]uint8{mac[5], mac[4], mac[3], mac[2], mac[1], mac[0]}
62+
}
63+
5964
const hexDigit = "0123456789ABCDEF"
6065

6166
// AppendText appends the textual representation of itself to the end of b

0 commit comments

Comments
 (0)