Ios 无法在didUpdateNotificationStateForCharacteristic中获取CBcharacteristics值

Ios 无法在didUpdateNotificationStateForCharacteristic中获取CBcharacteristics值,ios,bluetooth-lowenergy,core-bluetooth,cbcentralmanager,cbperipheral,Ios,Bluetooth Lowenergy,Core Bluetooth,Cbcentralmanager,Cbperipheral,我有一个已成功连接的可扩展设备。在这种情况下,每当我向BLE设备发送字符串“GET DATA”时,该设备都会通过向我发送特定的响应来进行响应。我正在使用DidDiscoveryCharacteristicsForService来编写值(“获取数据”)。我期待didUpdateNotificationStateForCharacteristic中的数据,但每次都会得到响应 - (void)peripheral:(CBPeripheral *)peripheral didDiscoverChara

我有一个已成功连接的可扩展设备。在这种情况下,每当我向BLE设备发送字符串“GET DATA”时,该设备都会通过向我发送特定的响应来进行响应。我正在使用DidDiscoveryCharacteristicsForService来编写值(“获取数据”)。我期待didUpdateNotificationStateForCharacteristic中的数据,但每次都会得到响应

 - (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error
{
    if ([service.UUID isEqual:[CBUUID UUIDWithString:@"Some service UUID"]])
    {         
         for (CBCharacteristic *aChar in service.characteristics)
         {
             if ([aChar.UUID isEqual:[CBUUID UUIDWithString:@"Some UUID"]]) 
             {
                 NSString *str = @"GET DATA";
                 NSData *someData = [str dataUsingEncoding:NSUTF8StringEncoding];
                [self.RN2058Peripheral setNotifyValue:YES forCharacteristic:aChar];
                [self.RN2058Peripheral writeValue:someData forCharacteristic:aChar type:CBCharacteristicWriteWithResponse];
             }  
         }
     }
}



- (void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
{
    if ([characteristic.UUID isEqual:[CBUUID UUIDWithString:@"Some UUID"]])
    {
        NSString *value = [[NSString alloc] initWithData:characteristic.value encoding:NSUTF8StringEncoding];
        NSLog(@"Value %@",value);

        NSData *data = characteristic.value;
        NSString *stringFromData = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"Data ====== %@", stringFromData);
    }
}

调用
DidUpdateNotifymentStateforCharacteristic
以响应调用
setNotifyValue


当特征值在外围设备上更改时,您将得到对
didUpdateValueForCharacteristic
委托方法的调用。在此方法中,您可以访问特征值

didUpdateNotifymentStateforCharacteristic
被调用,以响应您对
setNotifyValue
的调用


当特征值在外围设备上更改时,您将得到对
didUpdateValueForCharacteristic
委托方法的调用。在此方法中,您可以访问特征值

didUpdateNotifymentStateforCharacteristic
被调用,以响应您对
setNotifyValue
的调用


当特征值在外围设备上更改时,您将得到对
didUpdateValueForCharacteristic
委托方法的调用。在此方法中,您可以访问特征值

didUpdateNotifymentStateforCharacteristic
被调用,以响应您对
setNotifyValue
的调用

当特征值在外围设备上更改时,您将得到对
didUpdateValueForCharacteristic
委托方法的调用。在此方法中,您可以访问特征值