private async Task TestReadableSensor(IEarable earable, IReadableSensor <SensorValueType> sensor) { await EarableUtility.Reconnect(earable); Status.StatusUpdate("Reading value of sensor {0}", sensor); Status.StatusUpdate("Current value is {0}", await sensor.ReadAsync()); }
private async Task SetName(IEarable earable, string name) { await earable.SetNameAsync(name); Assert.Equal(name, earable.Name); await EarableUtility.Reconnect(earable); Assert.Equal(name, earable.Name); }
private async Task TestSubscribableSensor(IEarable earable, ISubscribableSensor <SensorValueType> sensor) { await EarableUtility.Reconnect(earable); _sampleReceiver = new TaskCompletionSource <SensorValueType>(); sensor.ValueChanged += OnValueChanged; Status.StatusUpdate("Subscribing to sensor {0}", sensor); await sensor.StartSamplingAsync(); Status.StatusUpdate("Waiting for a value update from sensor {0}", sensor); var valueReceived = _sampleReceiver.Task; var timeout = Task.Delay(10000); await Task.WhenAny(valueReceived, timeout); _sampleReceiver = null; await sensor.StopSamplingAsync(); sensor.ValueChanged -= OnValueChanged; Assert.True(valueReceived.IsCompleted, "Result recieved within 10 seconds."); Status.StatusUpdate("Received value {1} from sensor {0}", sensor, valueReceived.Result); }