简体   繁体   English

CoreBluetooth:如何获取所连接的BLE设备的蓝牙MAC地址?

[英]CoreBluetooth: How to obtain Bluetooth MAC address of BLE device I'm connected to?

Is there a particular service and characteristic that I can read from a BLE device that will provide its MAC address? 我可以从提供其MAC地址的BLE设备中读取特定的服务和特性吗? I've tried reading the Serial Number in the blind hope that it was the MAC (from the Device Info), but attempting to do so seems to give an error. 我已经尝试过盲目地读取序列号,即它是MAC(来自设备信息),但是尝试这样做似乎会出错。 I'm coding this for iOS, but if iOS is blocking my good-natured desire to obtain data, I'd be willing to dump it and move to Android. 我正在为iOS编写此代码,但是如果iOS阻止了我本能的获取数据的愿望,我将愿意将其转储并迁移到Android。

您无法使用iOS上的Core Bluetooth获取设备MAC地址。

If you have control of the BlE accessory,you can add a MAC address to your advertisementData,so that you can get the MAC address even without connectting. 如果您可以控制BlE附件,则可以将MAC地址添加到AdvertiseData中,这样即使不连接也可以获取MAC地址。
But since you can always get your BlE accessory's UUID,why bother use MAC address instead. 但是,由于您始终可以获取BlE配件的UUID,因此为什么要改用MAC地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM