I am developing an application in which I need to show the information of a Bluetooth device. I finally made some progress regarding bluetooth mac address, but couldn't get the device name. Is there any way to legally get a device name through some public API?
NSString*btMacAddr = @"Bt "; BOOL success; struct ifaddrs * addrs; const struct ifaddrs * cursor; const struct sockaddr_dl * dlAddr; const uint8_t * base; success = getifaddrs(&addrs) == 0; if (success) { cursor = addrs; while (cursor != NULL) { if ( (cursor->ifa_addr->sa_family == AF_LINK) && (((const struct sockaddr_dl *) cursor->ifa_addr)->sdl_type == IFT_ETHER) && (strcmp(cursor->ifa_name, "en0") == 0)) { dlAddr = (const struct sockaddr_dl *) cursor->ifa_addr; base = (const uint8_t *) &dlAddr->sdl_data[dlAddr->sdl_nlen]; if (dlAddr->sdl_alen == 6) { //fprintf(stderr, ">>> WIFI MAC ADDRESS: %02x:%02x:%02x:%02x:%02x:%02x\n", base[0], base[1], base[2], base[3], base[4], base[5]); //fprintf(stderr, ">>> IPHONE BLUETOOTH MAC ADDRESS: %02x:%02x:%02x:%02x:%02x:%02x\n", base[0], base[1], base[2], base[3], base[4], base[5]+1); btMacAddr = [NSString stringWithFormat:@"Mac Address : %02x : %02x : %02x : %02x : %02x : %02x", base[0], base[1], base[2], base[3], base[4], base[5]+1]; } else { fprintf(stderr, "ERROR - len is not 6"); } } cursor = cursor->ifa_next; } freeifaddrs(addrs); }
source share