public async Task <byte[]> ReadValueAsync(bool sendConfirmOnReceive = false) { var data = await _gattCharacteristic1Proxy.ReadValueAsync(new Dictionary <string, object>()); if (sendConfirmOnReceive) { await _gattCharacteristic1Proxy.ConfirmAsync(); } return(data); }
public static async Task <byte[]> ReadValueAsync(this IGattCharacteristic1 characteristic, TimeSpan timeout) { var options = new Dictionary <string, object>(); var readTask = characteristic.ReadValueAsync(options); var timeoutTask = Task.Delay(timeout); await Task.WhenAny(new Task[] { readTask, timeoutTask }); if (!readTask.IsCompleted) { throw new TimeoutException("Timed out waiting to read characteristic value."); } return(await readTask); }
Task <Memory <byte> > _ReadValueAsync() => proxy.ReadValueAsync(new Dictionary <string, object>()).ContinueWith(t => t.Result.AsMemory());