IOBluetooth没有为某些服务返回任何特征

时间:2013-12-21 00:05:41

标签: macos bluetooth-lowenergy core-bluetooth iobluetooth

我正在尝试从蓝牙LE设备上的服务中读取特征。出于某种原因,对于某些特性,在调用-[CBPeripheralManager discoverCharacteristics:forService]之后,peripheral:didDiscoverServices:回调获得0个特征。是否有任何变通方法可以让我阅读此服务的特征?

安装Hardware IO Tools for Xcode并运行PacketLogger时,很明显,discoverServices调用导致0x08 Read By Type请求(Bluetooth®CoreSpecification Volume 3,Part F,Section 3.4.4.1),Starting Handle = 0x1a ,Ending Handle = 0x1a,属性类型= 0x2803。

此外,通过定义以下类扩展来读取受保护的字段,很明显我感兴趣的服务,0x180a =设备信息,ATT句柄也太接近舒适:_startHandle = 0x1a和_endHandle = 0X1A。

@implementation CBService(ProtectedProps)
- (NSNumber*) startHandle {
    return self->_startHandle;
}
- (NSNumber*) endHandle {
    return self->_endHandle;
}
@end
@implementation CBCharacteristic(ProtectedProps)
- (NSNumber*) descriptorHandle {
    return self->_handle;
}
- (NSNumber*) valueHandle {
    return self->_valueHandle;
}
@end

顺便说一句,当我在iPhone 4S上从LightBlue读取设备时,该服务运行正常,我可以阅读该服务的3个特征。

我正在使用Apple蓝牙软件版本:4.2.0f6 12982在OSX 10.9 Mavericks上进行测试。我正在测试的设备是Livescribe 3。

这是一个实际GATT句柄,CBService句柄和UUID的表。在128位UUID搞砸了表之后,它看起来像是一个16位的UUID。蓝牙4.0第3.1节规定16位UUID服务“应该”组合在一起以提高性能,但我不认为它们必须。

  1. 0001-0004 0001-0004 uuid:1801
  2. 0005-0009 0005-0009 uuid:1800
  3. 0010-0019 0010-0019 uuid:128位UUID
  4. 001A-0020 001A-001A uuid:180a
  5. 0021-0023 缺失 uuid:180f
  6. 0024-002A 0021-0027 uuid:128位UUID
  7. 002E-0031 002B-002E uuid:128位UUID

1 个答案:

答案 0 :(得分:1)

在OSX 10.9.1中修复了读取与128位UUID交错的16位UUID的错误。但是,坏的值仍然被缓存,因为计算机仍然与外围设备绑定。因此,如果您之前已连接到外围设备,则无论您重新连接或重新启动多少次,由于缓存的GATT值错误,该错误仍会显现出来。

我不得不擦除绑定缓存/Library/Preferences/com.apple.Bluetooth.plist并杀死蓝色。有关详细信息,请参阅我的其他问题Does blued cache ATT values, and how to clear the cache?