Ios7 核心蓝牙特性通知不工作

Ios7 核心蓝牙特性通知不工作,ios7,bluetooth-lowenergy,core-bluetooth,Ios7,Bluetooth Lowenergy,Core Bluetooth,我正在尝试编写一个接收通知的BTLE监控应用程序。我已经使用核心蓝牙(在iOS 7.1上)构建了中央应用程序和模拟外围应用程序。My central可以很好地连接到外围设备,外围设备宣传具有2CBCharacteristicPropertyNotify特征的服务。但一旦中央发现了这些特征(为了清晰起见,删除了不必要的代码),就会发生这样的情况 PD=CBPeripheralDelegate位于中央 PMD=cbperipheraldmanager在外围设备中释放 已调用PD回调 - (void)

我正在尝试编写一个接收通知的BTLE监控应用程序。我已经使用核心蓝牙(在iOS 7.1上)构建了中央应用程序和模拟外围应用程序。My central可以很好地连接到外围设备,外围设备宣传具有2
CBCharacteristicPropertyNotify
特征的服务。但一旦中央发现了这些特征(为了清晰起见,删除了不必要的代码),就会发生这样的情况

PD=CBPeripheralDelegate位于中央

PMD=cbperipheraldmanager在外围设备中释放

已调用PD回调

- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error
{
    for (CBCharacteristic *characteristic in service.characteristics)
    {
        [peripheral setNotifyValue:YES forCharacteristic:characteristic];
    }
}
为2个特征调用了两次PMD回调

- (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central didSubscribeToCharacteristic:(CBCharacteristic *)characteristic
{
    if ([characteristic.UUID isEqual:[CBUUID UUIDWithString:FILTER_GENUINE_CHARACTERISTIC_UUID]])
    {
        BOOL genuineSent = [self.peripheralManager updateValue:genuineValue
                                                     forCharacteristic:self.filterGenuineCharacteristic
                                                  onSubscribedCentrals:nil];
    }
    else if ([characteristic.UUID isEqual:[CBUUID UUIDWithString:FILTER_LOADING_CHARACTERISTIC_UUID]])
    {
        BOOL loadingSent = [self.peripheralManager updateValue:loadingValue
                                                     forCharacteristic:self.filterLoadingCharacteristic
                                                  onSubscribedCentrals:nil];
    }
}
- (void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
注意:第一次调用此方法时,SubscribedCentrals:上的
updateValue:forCharacteristic:onSubscribedCentrals:
返回值为
YES
。第二次返回总是
NO

为2个特征调用了两次PD回调

- (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central didSubscribeToCharacteristic:(CBCharacteristic *)characteristic
{
    if ([characteristic.UUID isEqual:[CBUUID UUIDWithString:FILTER_GENUINE_CHARACTERISTIC_UUID]])
    {
        BOOL genuineSent = [self.peripheralManager updateValue:genuineValue
                                                     forCharacteristic:self.filterGenuineCharacteristic
                                                  onSubscribedCentrals:nil];
    }
    else if ([characteristic.UUID isEqual:[CBUUID UUIDWithString:FILTER_LOADING_CHARACTERISTIC_UUID]])
    {
        BOOL loadingSent = [self.peripheralManager updateValue:loadingValue
                                                     forCharacteristic:self.filterLoadingCharacteristic
                                                  onSubscribedCentrals:nil];
    }
}
- (void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
注意:
特征。isNotifying
始终为
YES

但就是这样,不会调用其他回调方法

PMD callback
外围设备管理器ReadyToUpdatesSubscribers:
从不为返回的
调用的
updateValue:forCharacteristic:onSubscribedCentrals:
调用

- (void)peripheralManagerIsReadyToUpdateSubscribers:(CBPeripheralManager *)peripheral
PD回调
peripal:didUpdateValueForCharacteristic:error:
从不为订阅的Central:调用返回的
YES

- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
我一直在iPad Air和iPhone 5s上测试这些应用程序,这两款应用程序都运行iOS 7.1


知道为什么从不调用通知吗?

我在iPhone 6的iOS 8.1.3上也有同样的问题。我打电话给updateValue获取已通知的订阅特征。但是,在第一次调用updateValue失败后,没有ReadyToUpdateSubscribers回调。