【问题标题】:Closed - How to convert a known MAC address into CBPheripheral identifier?已关闭 - 如何将已知 MAC 地址转换为 CBPeripheral 标识符?
【发布时间】:2017-10-21 13:27:31
【问题描述】:

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

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

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

【问题讨论】:

  • 不,你不能,除非你可能将“随机”MAC 逆向工程为 iOS 使用的 UUID。但是,如果您可以控制设备,则可以将其放入广告数据或特征值中,这可以帮助您识别要连接的正确设备。

标签: ios iphone xcode bluetooth core-bluetooth


【解决方案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

【讨论】:

    猜你喜欢
    • 2013-12-31
    • 2013-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-13
    • 2012-12-05
    • 1970-01-01
    相关资源
    最近更新 更多