alex willrock
alex willrock

Reputation: 996

objective c get mac address from wifi point on iOS device and no see zero in address

i use function and see

BSSID = "d4:ca:6d:d4:e:89";
SSID = "ExtremeFitness_FreeInternet";
SSIDDATA = <45787472 656d6546 69746e65 73735f46 72656549 6e746572 6e6574>;

but mac address from wifi pointer d4:ca:6d:d4:0e:89

after, i compare current wifi bssid with mac address from database, compare NSString

why i not see 0 in this code ?

+(NSString *) getMac{

CFArrayRef myArray = CNCopySupportedInterfaces();
CFDictionaryRef captiveNetWork = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
//NSLog(@"Connected at : %@", captiveNetWork);
NSDictionary *myDictionnary = (__bridge NSDictionary *)captiveNetWork;
NSString *bssid = [myDictionnary objectForKey:@"BSSID"];

if (bssid.length == 0) {

    return @"";
}

return bssid;
}

-(void)compareMacAddress{

for (int i = 0; i < _clubs.count; i ++) {


    NSString *macFromClub = [[NSString stringWithFormat:@"%@", _clubs[i][@"mac"]] lowercaseString];

    NSLog(@"%@", _clubs[i]);

    EFMacAddressUtil *macUtil = [[EFMacAddressUtil alloc] init];

    NSLog(@"%@", [[macUtil getMac] lowercaseString]);

    NSRange range = [macFromClub rangeOfString:[[macUtil getMac] lowercaseString]];

    if (range.length > 0) {

        [_clubInfo setObject:_clubs[i][@"address"]  forKey:@"address"];
        [_clubInfo setObject:_clubs[i][@"id"]       forKey:@"id"];
        [_clubInfo setObject:_clubs[i][@"ip"]       forKey:@"ip"];
        [_clubInfo setObject:_clubs[i][@"mac"]      forKey:@"mac"];

        _inClub = true;

        [_mainOfficeTableView reloadData];
        break;

    }else{

        _inClub = false;

        [_mainOfficeTableView reloadData];
    }
}

}

Upvotes: 5

Views: 1741

Answers (1)

alex willrock
alex willrock

Reputation: 996

solved if my app see in mac address xx:xx:xx:e:xx:xx i make string xx:xx:xx:0e:xx:xx

Upvotes: 2

Related Questions