From 035e7dd7d9c318c3c7a1df9a5d695c89cedef04c Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Thu, 27 Nov 2025 12:21:29 +0100 Subject: [PATCH] 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. --- mac.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mac.go b/mac.go index 168bca3b..7c4440c4 100644 --- a/mac.go +++ b/mac.go @@ -56,6 +56,11 @@ func (mac MAC) String() string { return unsafe.String(unsafe.SliceData(buf), 17) } +// Address returns the MAC address in the typical (big-endian) format. +func (mac MAC) Address() [6]uint8 { + return [6]uint8{mac[5], mac[4], mac[3], mac[2], mac[1], mac[0]} +} + const hexDigit = "0123456789ABCDEF" // AppendText appends the textual representation of itself to the end of b