如何使用IOBluetooth / CoreBluetooth服务请求? [英] How to use service soliciting with IOBluetooth/CoreBluetooth?

查看:523
本文介绍了如何使用IOBluetooth / CoreBluetooth服务请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要做的是在我的Mac上使用iPhone上的Apple Notification Center服务(ANCS)。为了让我的iPhone在我的iPhone的蓝牙设置中显示,我显然需要使用服务请求。

What I'm trying to do is use the Apple Notification Center Service (ANCS) from my iPhone on my Mac. To make my Mac show up on in my iPhone's Bluetooth settings, I apparently need to use service soliciting.

到目前为止我尝试的是发起我的Mac上的CBPeripheralManager ,添加ANCS服务并开始做广告。这似乎没有这样做,因为我的Mac没有出现在我的iPhone的蓝牙设置中。我还尝试了启动 CBCentralManager 并开始扫描,使用 CBCentralManagerScanOptionSolicitedServiceUUIDsKey 键中的ANCS UUID,也不起作用。

What I've tried so far is initiate a CBPeripheralManager on my Mac, add the ANCS service to it and start advertising. That doesn't seem to do it, as my Mac doesn't show up in my iPhone's Bluetooth settings. What I've also tried is initiate a CBCentralManager and start scanning, with the ANCS UUID in the CBCentralManagerScanOptionSolicitedServiceUUIDsKey key, which doesn't work either.

有没有人知道如何做到这一点?我花了大量时间观看WWDC视频并浏览Apple的文档,但除了一些模糊的提及服务征集之外,我找不到它。

Does anyone have an idea on how to accomplish this? I've spent tons of hours watching WWDC videos and browsing through Apple's documentation, but other than some vague mentions of "service soliciting", I can't find it.

谢谢!

推荐答案

当蓝牙LE设备通告时,它在其广告包中包含某些数据。这可以溢出到所谓的扩展查询响应(EIR)数据中,扫描设备可以请求。

When a Bluetooth LE device advertises, it contains certain data in its advertising packet. This can overflow into what is known as Extended Inquiry Response (EIR) data, which the scanning device can request.

要使用服务请求,必须包含密钥0x15 (标记为128位服务请求UUID列表,请参阅这里)和ANCS UUID 7905F431 -B5CE-4E99-A40F-4B1E122D00D0

To use service solicitation, one has to include the key 0x15 (marking "List of 128-bit Service Solicitation UUIDs, see here) and the ANCS UUID 7905F431-B5CE-4E99-A40F-4B1E122D00D0.

我已经能够在嵌入式平台和iOS上使用它,但尚未在OSX上尝试过。但是,您应该可以使用上面提到的密钥请求系统添加广告数据:

I have been able to get this to work on embedded platforms and iOS but have not tried it on OSX. However, you should be able to request the system to add the advertising data in by using the key you mentioned above:

CBCentralManager *manager = [[CBCentralManager alloc] initWithDelegate:self 
                                                                 queue:nil];
[manager scanForPeripheralsWithServices:nil
                                options:@{
    CBCentralManagerScanOptionSolicitedServiceUUIDsKey:@[
        [CBUUID UUIDWithString:@"7905F431-B5CE-4E99-A40F-4B1E122D00D0"]]}];

这会传递包含该密钥的字典,该字典与ANCS UUID的单个CBUUID对象的数组配对。

This passes a dictionary containing that key paired with an array of a single CBUUID object for the ANCS UUID.

这篇关于如何使用IOBluetooth / CoreBluetooth服务请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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