在iOS中获取蓝牙低功耗外设的MAC地址 [英] Get MAC address of bluetooth low energy peripheral in iOS

查看:736
本文介绍了在iOS中获取蓝牙低功耗外设的MAC地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在基于蓝牙低功耗设备的iOS应用程序上工作.为了获得唯一的标识符以比较所获得的外围设备,我必须获取外围设备的MAC地址.

I am currently working on an iOS application based on bluetooth low energy devices. In order to get a unique identifier to compare the peripherals got, I have to get the MAC address of the peripherals.

观察到,外围设备的UUID属性在iOS设备之间有所不同,并且外围设备要获取UUID,还必须至少与主设备连接一次.由于我必须办理入住手续,因此我不想建立连接.当我浏览蓝牙服务门户时,我发现设备信息本身就是一项服务,除非在主iOS设备和外围蓝牙低能耗设备之间建立了连接,否则无法检索该信息.

It is observed that the UUID property of a peripheral device varies across iOS devices and also for the peripheral device to get a UUID, it will have to get connected to a master device at least once. Since I have to deal with check-in's I don't want to establish a connection. As I went through the bluetooth services portal, I found that the device information itself is a service, which couldn't be retrieved unless a connection has been established between the master iOS device and the peripheral bluetooth low energy device.

我发现在Android中,当我们从设备扫描自身时获得响应时,就可以获取设备的全部信息,包括其MAC地址(使用getAddress()).

I found that in Android we get the entire information of the device, including its MAC address (using getAddress()) when we get the response from the device on scanning itself.

我在CBPeripheral类中没有找到与设备地址相关的任何属性. 获取唯一参数的另一种方法是自定义广告数据以发送有关设备的其他信息,这需要在固件方面进行更多工作.

I didn't find any properties in CBPeripheral class related to the device address. Another way to get a unique parameter would be to customize the advertisement data to send additional information regarding the device, which requires more work on firmware side.

那么iOS上有什么方法可以在不建立连接的情况下获取蓝牙低功耗外设的MAC地址吗?

So is there any way in iOS that I could get the MAC address of the bluetooth low energy peripheral without establishing a connection?

任何帮助将不胜感激.

推荐答案

更新后的答案:-

在iOS 12之后,我们可以获取UDID

   print(UIDevice.current.identifierForVendor)

   print(UIDevice.current.identifierForVendor?.uuidString)

iOS 12之前的版本**

没有公共API可以获取此信息.

Before iOS 12**

There is no public API to get this information.

如果这是内部或越狱应用程序,则可以通过 liblockdown.dylib

If this is an internal or jailbreak application you can get the value of the kLockdownBluetoothAddressKey key via liblockdown.dylib

这篇关于在iOS中获取蓝牙低功耗外设的MAC地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆