在iOS中获取BLE的广告数据 [英] Get advertisement data for BLE in iOS

查看:438
本文介绍了在iOS中获取BLE的广告数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个应用程序,它可以获取范围内所有BLE设备的UUID。我已经让它在Android中运行良好,它将广告数据作为字节数组提供给我。现在我试图在iOS中做同样的事情。

I'm creating an app that gets the UUID of all BLE devices within range. I've gotten it working fine in Android, where it gives me the advertisement data as a byte array. Now I'm trying to do the same in iOS.

我正在运行扫描并且它正在检测设备,而在回调中有一个名为advertisementData的NSDictionary。但其中唯一的信息如下:

I'm running a scan and it's detecting the device, and in the callback there's an NSDictionary called advertisementData. But the only information in it is as follows:

kCBAdvDataChannel = 39;
kCBAdvDataIsConnectable = 1;
kCBAdvDataLocalName = jaalee;
kCBAdvDataTxPowerLevel = 0;

我是否认为我应该获得整个广告包?如果没有,我怎么能得到它?

Am I right in thinking I should be getting the entirety of the advertising packet? If not, how can I get it?

推荐答案

不幸的是,iOS不允许您访问原始广告数据。我写了一篇博文证明这一点。 虽然帖子是关于iBeacons的,但它适用于任何BLE广告。

Unfortunately, iOS does not allow you to access the raw advertisement data. I wrote a blog post demonstrating this. While the post is specifically about iBeacons, it applies to any BLE advertisement.

编辑:为了澄清,你可以读取非iBeacon广告的原始字节。只有iBeacon广告的字节被 CoreLocation 隐藏。请参阅此处:获取蓝牙LE扫描响应iOS的数据

To clarify, you can read the raw bytes of non-iBeacon advertisements. It is only the iBeacon advertisements that have their bytes hidden by CoreLocation. See here: Obtaining Bluetooth LE scan response data with iOS

等效的OSX CoreLocation方法允许这样做,因此它可能是iOS上的故意安全或省电限制。

The equivalent OSX CoreLocation methods do allow this, so it is probably an intentional security or power saving restriction on iOS.

这篇关于在iOS中获取BLE的广告数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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