iOS的CoreBluetooth与UUID重新连接设备 [英] iOS CoreBluetooth reconnecting device with UUID

查看:416
本文介绍了iOS的CoreBluetooth与UUID重新连接设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个蓝牙4.0(BLE)使用的我通过iOS的蓝牙核心框架接口的CC2541芯片组的设备。

I have a Bluetooth 4.0 (BLE) device using the CC2541 chipset which I am interfacing with via the iOS Core Bluetooth Framework.

我可以使用核心蓝牙当设备处于可发现/广告模式传送数据到和从设备而没有任何问题成功地使该设备的连接。

I can successfully make a connection to the device using Core Bluetooth when the device is in a discoverable/advertising mode and transfer data to and from the device without any problem.

我认为我已经与连接的设备的UUID的集合,我现在尝试连接到再次使用这些设备之一:

I maintain a collection of device UUIDs that I have connected with and I am now attempting to connect to one of these devices again using:

CBCentralManager 
- (void)retrievePeripherals:(NSArray *)peripheralUUIDs

调用此函数似乎工作,我收到一个回调到我实现以下功能:

Calling this function appears to work and I receive a callback to my implementation of the the following function:

CBCentralManagerDelegate 
- (void)centralManager:(CBCentralManager *)central didRetrievePeripherals:(NSArray *)peripherals

我试图连接的设备是独一无二的传递给这个函数的外设阵列中只列出周边

The device I'm attempting to connect with is the one and only peripheral listed in the peripherals array that is passed to this function.

当我再尝试使用我的连接功能(如下所示)的连接不会主动连接到该设备,我在所有在任一CBCentralManagerDelegate或CBPeripheralDelegate。拿不出回调

When I then attempt to connect to this device using my connect function (shown below) the connection will not initiate and I get no callbacks at all on either the CBCentralManagerDelegate or the CBPeripheralDelegate.

- (void) connectPeripheral:(CBPeripheral *)peripheral {
    NSLog(@"Connecting to peripheral with UUID : %s\r\n",[self UUIDToString:peripheral.UUID]);
    activePeripheral = peripheral;
    activePeripheral.delegate = self;
    [CM connectPeripheral:activePeripheral options:nil];
}

我可以使连接经过成功,如上所述,如果我第一次将设备插入发现/广告模式,但是这不是一个可行的解决方案。该设备必须允许重新连接,没有它被置于发现模式。

I can make the connection go through successfully, as described above, if I first place the device into discoverable/advertising mode, but this is not a workable solution. The device must allow reconnection without it being placed into discoverable mode.

我确实注意到对此问题<一个答案href=\"http://stackoverflow.com/questions/17575949/corebluetooth-what-is-the-lifetime-of-unique-uuids\">CoreBluetooth:什么是独特的UUID 表明我需要配对/与iOS设备粘合BLE装置,但是,这可能是依赖于BLE芯片组,我使用的设备是CC2541的寿命。关于如何去配对的设备将是最有用的,或者实际上这是否是一个必要的步骤任何意见。我试图观看 WWDC 2012:高级核心蓝牙这可能会给我一些帮助,但由于苹果公司在周四砍死我无法访问我的acccount观看视频。

I did note the answer given to this question CoreBluetooth: What is the lifetime of unique UUIDs suggests I need to pair/bond the BLE device with the iOS device but that this may be dependent on the BLE chipset, the device I'm using is the CC2541. Any advice on how to go about pairing with the device would be most useful, or indeed whether this is a necessary step. I have attempted to watch WWDC 2012: Advanced Core Bluetooth which might give me some assistance, but since Apple were hacked on Thursday I'm not able to access my acccount to watch the video.

请让我知道是否需要任何更多的细节。蓝牙设备是稳定的,但它正在内部开发的。如果变化,可能需要向固件以协助配对处理,我可以沿到电子队将此信息传递

Please let me know if any more details are required. The Bluetooth device is stable, but it is being developed internally. If changes may be required to the firmware to assist with the pairing process, I can pass this information along to the electronics team.

推荐答案

你为什么不尝试这个

它指定首先你需要发送到需要GATT_AUTHEN_READ权限的关贸总协定特性的要求。那么你的CC2541将无效的验证响应。这将触发苹果内部结合机制,并要求关键。您可以输入密码,然后如果设备和CC2541已成功配对,将读取的特征值,并输入您的回调。

It specifies first you need to send a request to a GATT characteristic that requires GATT_AUTHEN_READ permission. Then your CC2541 will respond with INVALID AUTHENTICATION. This will trigger Apple's internal Bonding mechanism and ask for a key. You can enter the passkey and then if the device and CC2541 are successfully paired, it will read the characteristic value and enter your callback.

请注意:我不是一个iOS开发者,但我已经与CC2541工作。如果您使用的是默认simplePEripheral例子,那么在simpleProfile characteristic5特征需要验证阅读。看看配置文件/ SimpleProfile / simpleGATTprofile.c

NOTE: I'm not an iOS developer, but I have worked with CC2541. If you are using the default simplePEripheral example, then a characteristic in simpleProfile characteristic5 requires authentication to read. Take a look at profiles/SimpleProfile/simpleGATTprofile.c

这篇关于iOS的CoreBluetooth与UUID重新连接设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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