加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 在iPhone上获取蓝牙MAC地址

发布时间:2020-12-16 06:50:13 所属栏目:百科 来源:网络整理
导读:前言 我正在使用 Swift 2开发Xcode 7.0.1 我试图了解如何检索此信息的小时数(更新,天数). 我已经看到有一个框架,CoreBluetooth,也许可以帮助我. (更新,绝对不是!!) 任何的想法? Objective-c / swift / c / c ..无论是什么……都是一样的. 我已经在this answ
前言
我正在使用 Swift 2开发Xcode 7.0.1

我试图了解如何检索此信息的小时数(更新,天数).
我已经看到有一个框架,CoreBluetooth,也许可以帮助我. (更新,绝对不是!!)

任何的想法? Objective-c / swift / c / c ..无论是什么……都是一样的.

我已经在this answer测试了代码,但打印出来:

>>> WIFI MAC ADDRESS: 02:00:00:00:00:00
>>>
IPHONE BLUETOOTH MAC ADDRESS: 02:00:00:00:00:ffffffff
>>> IPAD
BLUETOOTH MAC ADDRESS: 02:00:00:00:00:01

关于这个,我在官方documentation上读到:

In iOS 7 and later,if you ask for the MAC address of an iOS device,
the system returns the value 02:00:00:00:00:00. If you need to
identify the device,use the identifierForVendor property of UIDevice
instead. (Apps that need an identifier for their own advertising
purposes should consider using the advertisingIdentifier property of
ASIdentifierManager instead.)

问题是:如果其他设备可以读取我的蓝牙mac地址,为什么我不能?
我认为应该有办法做到这一点,当然.

我也尝试this answer(和其他答案)的片段,但我从来没有得到真正的mac地址.

我知道要知道mac的蓝牙信息我可以在终端上运行:

system_profiler SPBluetoothDataType | sed -n "/Apple Bluetooth Software Version:/,/Manufacturer:/p"

并且只检索mac地址我可以“管道”到上一个命令:

egrep -o '([[:xdigit:]]{1,2}-){5}[[:xdigit:]]{1,2}'

我问..我能以编程方式在iPhone上运行此命令吗?

实际上,我已经尝试过这个伪代码:

script = ""
system("system_profiler SPBluetoothDataType > blueInfo.txt")
sleep
read from file "blueInfo.txt" its content

此代码编译并“正常工作”,但在读取不存在的文件时失败.

我正在考虑放弃):

解决方法

正如评论者 and the devs on this GitHub issue所指出的那样,由于隐私问题,即使可以从第二个设备读取它,也无法检索您正在运行它的当前设备的MAC地址.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读