diff options
author | 2023-09-14 14:01:24 -0400 | |
---|---|---|
committer | 2023-09-14 14:37:02 -0400 | |
commit | cbbb9f40e283d12f6c52ad28609516f390316f7a (patch) | |
tree | d8d2cd8f4641299dd35a3138c0e28f11443928d6 /lib/vehicle-signals/vss_signal_providers.dart | |
parent | 5ce59ba69f1451ec18c565b7b18301856553f574 (diff) |
Rework to use KUKSA.val databroker gRPC API
Rework to move from the WebSocket API with the older KUKSA.val
server to the gRPC "VAL" API of the databroker.
Changes include:
- All VISS WebSocket API code has been removed, and the signal
providers replumbed to be driven by a new VssClient class with
a homescreen-specific child class to hold all the gRPC API
handling.
- The generated code for the VAL API and its dependencies has
been checked in under lib/generated, as there still does not
seem to be a good way to generate it during the Flutter build.
- The configuration file is now expected to be "homescreen.yaml"
instead of "homescreen_config.yaml". The authorization token
field name has been renamed to "authorization", and there are
new "use-tls" and "ca-certificate" configuration fields. TLS
is disabled by default for now, and the default CA certificate
is /etc/kuksa.val/CA.pem.
- Updated .gitignore to cover a couple of generated files that
weren't included.
Bug-AGL: SPEC-4762, SPEC-4903
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Change-Id: I1b95ed27a72435364d54ec846f2be88e3d8bb092
Diffstat (limited to 'lib/vehicle-signals/vss_signal_providers.dart')
-rw-r--r-- | lib/vehicle-signals/vss_signal_providers.dart | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/lib/vehicle-signals/vss_signal_providers.dart b/lib/vehicle-signals/vss_signal_providers.dart new file mode 100644 index 0000000..8f0bfc1 --- /dev/null +++ b/lib/vehicle-signals/vss_signal_providers.dart @@ -0,0 +1,98 @@ +// SPDX-License-Identifier: Apache-2.0 +import 'dart:io'; +import 'package:meta/meta.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +// Media Volume + +@immutable +class VehicleSignalMediaVolume { + const VehicleSignalMediaVolume({required this.volume}); + + final int volume; + + VehicleSignalMediaVolume copyWith({int? volume}) { + return VehicleSignalMediaVolume(volume: volume ?? this.volume); + } +} + +class VehicleSignalMediaVolumeNotifier + extends StateNotifier<VehicleSignalMediaVolume> { + VehicleSignalMediaVolumeNotifier() : super(_initialValue); + + static final VehicleSignalMediaVolume _initialValue = + VehicleSignalMediaVolume(volume: 50); + + void update({int? volume}) { + int? n = volume; + if (n != null) { + n = n.toUnsigned(8); + if (n > 100) n = 100; + } + state = state.copyWith(volume: n); + } +} + +final vehicleSignalMediaVolumeProvider = StateNotifierProvider< + VehicleSignalMediaVolumeNotifier, + VehicleSignalMediaVolume>((ref) => VehicleSignalMediaVolumeNotifier()); + +// Inside Temperature + +@immutable +class VehicleSignalInsideTemp { + const VehicleSignalInsideTemp({required this.temp}); + + final double temp; + + VehicleSignalInsideTemp copyWith({double? temp}) { + return VehicleSignalInsideTemp(temp: temp ?? this.temp); + } +} + +class VehicleSignalInsideTempNotifier + extends StateNotifier<VehicleSignalInsideTemp> { + VehicleSignalInsideTempNotifier() : super(_initialValue); + + static final VehicleSignalInsideTemp _initialValue = + VehicleSignalInsideTemp(temp: 25); + + void update({double? temp}) { + state = state.copyWith(temp: temp); + } +} + +final vehicleSignalInsideTempProvider = StateNotifierProvider< + VehicleSignalInsideTempNotifier, VehicleSignalInsideTemp>( + (ref) => VehicleSignalInsideTempNotifier(), +); + +// Outside Temperature + +@immutable +class VehicleSignalOutsideTemp { + const VehicleSignalOutsideTemp({required this.temp}); + + final double temp; + + VehicleSignalOutsideTemp copyWith({double? temp}) { + return VehicleSignalOutsideTemp(temp: temp ?? this.temp); + } +} + +class VehicleSignalOutsideTempNotifier + extends StateNotifier<VehicleSignalOutsideTemp> { + VehicleSignalOutsideTempNotifier() : super(_initialValue); + + static final VehicleSignalOutsideTemp _initialValue = + VehicleSignalOutsideTemp(temp: 32); + + void update({double? temp}) { + state = state.copyWith(temp: temp); + } +} + +final vehicleSignalOutsideTempProvider = StateNotifierProvider< + VehicleSignalOutsideTempNotifier, VehicleSignalOutsideTemp>( + (ref) => VehicleSignalOutsideTempNotifier(), +); |