private static async Task<string> InitSensorAsync(Sensor sensor) { try { await sensor.InitAsync(); return string.Empty; } catch (Exception exception) { return exception.Message; } }
private static bool TryReadSensor( Sensor sensor, out SensorReadings readings, out string errorMessage) { errorMessage = string.Empty; if (sensor.Initiated) { try { if (sensor.Update()) { readings = sensor.Readings; return true; } } catch (Exception exception) { errorMessage = exception.Message; } } readings = new SensorReadings(); return false; }