NEHotspotNetwork BSSID missing first character?

please consider this code:

[NEHotspotNetwork fetchCurrentWithCompletionHandler:^(NEHotspotNetwork *network) {
            if (network) {
                DebugLog(@"Network ssid: %@, bssid: %@", network.SSID, network.BSSID);                
            } else {
                DebugLog(@"No available network");              
            }
        }];

For me, I have a strange situation - say that the BSSID of my network is "01:34:56:78:90"

the string in the property is missing the first character! what is contains (and is printed) is "1:34:56:78:90" - the leading "0" is missing.

So, I was wondering if this is a know thing, or if perhaps it's only Asus (my router)? Or, am I doing something wrong?

Pointers would be much appreciated.

BSSIDs are MAC addresses, which means the on-the-wire format is 6 bytes of data. The BSSID property is rendering that in the traditional way, that is, rendering each byte in hex and inserting a colon between them.

Except that there are two traditional ways (-: one that includes leading zeroes and one that doesn’t, and it looks like NE has chosen the latter. If need the former, you can add back in the leading zero with code like this:

let fixed = bssid
    .split(separator: ":", omittingEmptySubsequences: false)
    .map { "00\($0)".suffix(2) }
    .joined(separator: ":")

You could reasonably file a bug requesting that we add the leading zeroes always. If you do that, please post your bug number, just for the record. It’ll be interesting to see how that pans out, as I could imagine the fix breaking other folks who rely on the current behaviour.

FWIW, I personally prefer to have the leading zeroes (-:

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks Quinn for the great explanation. If I really need it I'll file a bug report. Have a great day.

NEHotspotNetwork BSSID missing first character?
 
 
Q