I am writing data using [peripheral writeValue:startFrame forCharacteristic:cbWriteCharacteristic type:CBCharacteristicWriteWithResponse];
which calls "didWriteValueForCharacteristic as shown below"
- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
{
NSLog(@"characteristic.value %@",characteristic.value);
NSLog(@"Write Data characteristic.value %@",characteristic.value);
CBCharacteristic * cbReadCharacterstic = [self getCharacteristicWtihCBUUID:MHSW_READ_CHARACTERISTIC_ID];
[peripheral setNotifyValue:TRUE forCharacteristic:cbReadCharacterstic];
}
When i am printing value of "characteristic.value" in did write method it returns null.
Instead it should give value of data to be sent. When i am printing value of charateristics in write method:- " <CBCharacteristic: 0x166d0, UUID = D0F0-9DD7-7047, properties = 0x8, value = (null), notifying = NO>
"
value appears null in write method itself. Why it is coming so?
What should i do to resolve. Thanks in advance.
A call to didWriteValueForCharacteristic
informs you that a write with response has completed (i.e. the response has been received). It does not tell you anything about the value of that characteristic, so nil is the correct value.
The characteristic value could have changed between the execution of your write and the reception of the response.
If you want the current value of the characteristic then you need to issue a read request (or subscribe to value changes via notify).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With