gpt4 book ai didi

iphone - 如何以编程方式在 iOS 中获取 iPhone 蓝牙适配器名称

转载 作者:可可西里 更新时间:2023-11-01 06:10:39 24 4
gpt4 key购买 nike

我正在开发需要显示设备蓝牙信息的应用程序。我终于在蓝牙 mac 地址方面取得了一些成功,但无法获得设备名称。有没有办法通过一些公共(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);
}

最佳答案

那不就是这样的吗:[[UIDevice 当前设备]名称];

这给出了 iOS 设备的名称,例如“Henriks iPhone”

关于iphone - 如何以编程方式在 iOS 中获取 iPhone 蓝牙适配器名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15698302/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com