When I NSLog characteristic.value
it shows as either <1100>
or <2200>
. I know this is a hexadecimal. I'm confused as what to write when I'm changing the value.
Any help would be much appreciated.
At the moment I'm doing the following, but getting null when I change the values.
- (IBAction)deviceSwitchPressed:(id)sender {
if ([sender isOn]) {
[activePeripheral writeValue:[@"1100" dataUsingEncoding:NSUTF8StringEncoding] forCharacteristic:switchCharacterictic type:CBCharacteristicWriteWithResponse];
} else {
[activePeripheral writeValue:[@"2200" dataUsingEncoding:NSUTF8StringEncoding] forCharacteristic:switchCharacterictic type:CBCharacteristicWriteWithResponse];
}
NSLog(@"characteristic.value = %@", switchCharacterictic.value);
}
This is what I use to convert hex string values into data objects.
However writing a value to a characteristic doesn't guarantee that is what will be returned. The peripheral can handle that data in anyway that it wants.