已关闭 - 如何将已知的MAC地址转换为CBPeipheral标识符?

时间:2017-10-21 13:27:32

标签: ios iphone xcode bluetooth core-bluetooth

我知道在iOS中,我们无法直接获取设备的Mac ID。有什么办法,所以如果我有一个MAC ID,我可以将其转换为CoreBluetooth提供的标识符。

这是我的用例: 我知道来自服务器的Mac ID。因此,在可用的设备列表中,我应该连接具有已知Mac Id的设备。任何解决方法?感谢。

更新:我们无法将其作为两个不同的完整实体。抱歉有点初学者问题。

1 个答案:

答案 0 :(得分:1)

无法直接使用MAC地址。但有一种方法可以识别您的设备,即发现UUID的服务。 有一个名为

的API
- (void)scanForPeripheralsWithServices:(NSArray<CBUUID *> *)serviceUUIDs 
                               options:(NSDictionary<NSString *,id> *)options

示例:

[self.centralManager 
 scanForPeripheralsWithServices:@[[CBUUID UUIDWithString:DEVICE_INFO_SERVICE_UUID]] 
                        options:nil];

转到最佳做法https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/BestPracticesForInteractingWithARemotePeripheralDevice/BestPracticesForInteractingWithARemotePeripheralDevice.html

更多信息: https://medium.com/@yostane/getting-started-with-bluetooth-low-energy-on-ios-ada3090fc9cc