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[5]+1); btMacAddr = [Nsstring stringWithFormat:@"Mac Address : %02x : %02x : %02x : %02x : %02x : %02x",base[5]+1]; } else { fprintf(stderr,"ERROR - len is not 6"); } } cursor = cursor->ifa_next; } freeifaddrs(addrs);}解决方法 那就不是这样的:
[[UIDevice currentDevice] name];
这给了iOS设备的名称,如“Henriks iPhone”
总结以上是内存溢出为你收集整理的如何以编程方式在iOS中获取iPhone蓝牙适配器名称全部内容,希望文章能够帮你解决如何以编程方式在iOS中获取iPhone蓝牙适配器名称所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)