aboutsummaryrefslogtreecommitdiffstats
path: root/lib/data/data_providers/vehicle_notifier.dart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/data/data_providers/vehicle_notifier.dart')
-rw-r--r--lib/data/data_providers/vehicle_notifier.dart42
1 files changed, 40 insertions, 2 deletions
diff --git a/lib/data/data_providers/vehicle_notifier.dart b/lib/data/data_providers/vehicle_notifier.dart
index fb69595..b9a543c 100644
--- a/lib/data/data_providers/vehicle_notifier.dart
+++ b/lib/data/data_providers/vehicle_notifier.dart
@@ -136,7 +136,17 @@ class VehicleNotifier extends StateNotifier<Vehicle> {
state = state.copyWith(fanSpeed: update.entry.value.uint32);
}
break;
-
+ case VSSPath.vehicleDriverTemperature:
+ if (update.entry.value.hasInt32()) {
+ state = state.copyWith(driverTemperature: update.entry.value.int32);
+ }
+ break;
+ case VSSPath.vehiclePassengerTemperature:
+ if (update.entry.value.hasInt32()) {
+ state =
+ state.copyWith(passengerTemperature: update.entry.value.int32);
+ }
+ break;
// default:
// debugPrint("ERROR: Unexpected path ${update.entry.path}");
// break;
@@ -302,7 +312,6 @@ class VehicleNotifier extends StateNotifier<Vehicle> {
}, onError: (stacktrace, errorDescriptor) {
debugPrint(stacktrace.toString());
state = const Vehicle.initialForDebug();
-
});
} catch (e) {
debugPrint(e.toString());
@@ -340,6 +349,35 @@ class VehicleNotifier extends StateNotifier<Vehicle> {
}
}
+ void setTemperature({required Side side, required int value}) {
+ var helper = ValClientHelper(channel: channel, stub: stub);
+ try {
+ switch (side) {
+ case Side.left:
+ helper.setInt32(
+ VSSPath.vehicleDriverTemperature,
+ value,
+ false,
+ );
+ state = state.copyWith(driverTemperature: value);
+ break;
+ case Side.right:
+ helper.setInt32(
+ VSSPath.vehiclePassengerTemperature,
+ value,
+ false,
+ );
+ state = state.copyWith(passengerTemperature: value);
+ break;
+ default:
+ debugPrint("ERROR: Unexpected side value $side}");
+ break;
+ }
+ } catch (e) {
+ debugPrint(e.toString());
+ }
+ }
+
void updateFanSpeed(int newValue) {
state = state.copyWith(fanSpeed: newValue);
}