Can somebody help me to extract the data from value field in
I want to just show bytes data. Read method
public async Task<NSData> ReadValue(CBPeripheral peripheral, CBCharacteristic characteristic)
{
BTProgressHUD.Show("Loading...", 1000, ProgressHUD.MaskType.Gradient);
var taskCompletion = new TaskCompletionSource<bool>();
var task = taskCompletion.Task;
EventHandler<CBCharacteristicEventArgs> handler = (s, e) =>
{
if (e.Characteristic.UUID?.Uuid == characteristic.UUID?.Uuid)
{
// e.Characteristic.Value = characteristic.Value;
taskCompletion.SetResult(true);
}
};
try
{
peripheral.UpdatedCharacterteristicValue += handler;
System.Threading.Thread.Sleep(900);
peripheral.ReadValue(characteristic);
BTProgressHUD.Dismiss();
await Task.Delay(200);
return characteristic.Value;
}
finally
{
//to get the updated characteristics value.
peripheral.UpdatedCharacterteristicValue -= handler;
BTProgressHUD.Dismiss();
}
}