Really struggling with writing back to a BLE Peripheral. Please help...
I'm connected and have read the characteristics available and wish to write back from a IBAction Slider:
-(IBAction)SrControlIndex:(UISegmentedControl *)sender
{
switch (_SRControl.selectedSegmentIndex)
{
case 0:
[self writeModeCharacteristic:Status_UUID data:[@"00" dataUsingEncoding:NSUTF8StringEncoding]];
NSLog(@"First Sel");
break;
case 1:
NSLog(@"Second Sel");
break;
default:
break;
}
}
And calls the following write:
-(void)writeModeCharacteristic:(CBCharacteristic *)ModeCharacteristic data:(NSData*)data
{
[ModeCharacteristic.service.peripheral writeValue:data forCharacteristic:ModeCharacteristic type:CBCharacteristicWriteWithResponse];
}
What am I missing?
Thanks to Larme for the answer:
@property (nonatomic, strong) CBCharacteristic statusCharacteristic; When you discovers it: _statusCharacteristic = statusCharacteristicJustDiscovered; Then you can reuse it in your method.
This worked great...