2

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.

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.

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.

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.

4

1 回答 1

0

你为什么不试试这个

它首先指定您需要向需要 GATT_AUTHEN_READ 权限的 GATT 特征发送请求。然后您的 CC2541 将响应 INVALID AUTHENTICATION。这将触发 Apple 的内部绑定机制并要求提供密钥。您可以输入密码,然后如果设备和CC2541成功配对,它将读取特征值并输入您的回调。

注意:我不是 iOS 开发人员,但我使用过 CC2541。如果您使用默认的 simplePERipheral 示例,则 simpleProfile 特征 5 中的特征需要身份验证才能读取。看看profiles/SimpleProfile/simpleGATTprofile.c

于 2014-01-29T07:17:52.563 回答