diff options
author | OpenEmbedded <oe.patch@oe> | 2023-09-13 14:37:41 +0000 |
---|---|---|
committer | Scott Murray <scott.murray@konsulko.com> | 2023-09-14 14:34:04 -0400 |
commit | e389b9fa646f90d50e853c2dbf870cdf9f9b80b7 (patch) | |
tree | 9d7b93e3e6e300a7e40dd03993ed8da129c98369 /lib/vehicle-signals/vehicle_methods.dart | |
parent | adc3fca51b9ebfc23b503126065d97d692d0ec64 (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 dashboard-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 "dashboard.yaml"
instead of "dashboard.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.
- Bumped minimum SDK version to 2.18 in pubspec.yaml to enable
"super" keyword support. This matches what the version was set
to in flutter-homescreen.
- Removed .dart_tool generated output that had been checked in,
and added .gitignore file from flutter-homescreen so that things
will hopefully stay clean in the future.
Bug-AGL: SPEC-4762
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Change-Id: Ie23091b759458b5a131bc2d85e62925238839166
Diffstat (limited to 'lib/vehicle-signals/vehicle_methods.dart')
-rw-r--r-- | lib/vehicle-signals/vehicle_methods.dart | 183 |
1 files changed, 0 insertions, 183 deletions
diff --git a/lib/vehicle-signals/vehicle_methods.dart b/lib/vehicle-signals/vehicle_methods.dart deleted file mode 100644 index 8259450..0000000 --- a/lib/vehicle-signals/vehicle_methods.dart +++ /dev/null @@ -1,183 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -import 'dart:convert'; -import 'dart:io'; - -import 'package:dashboard_app/vehicle-signals/vss_providers.dart'; -import 'package:dashboard_app/vehicle-signals/vehicle_server_path.dart'; -import 'package:dashboard_app/config.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; - -class VISS { - static const requestId = "test-id"; - static void init(WebSocket socket, WidgetRef ref) { - authorize(socket, ref); - subscribe(socket, ref, VSSPath.vehicleSpeed); - subscribe(socket, ref, VSSPath.vehicleEngineSpeed); - subscribe(socket, ref, VSSPath.vehicleFuelLevel); - subscribe(socket, ref, VSSPath.vehicleFrontLeftTire); - subscribe(socket, ref, VSSPath.vehicleFrontRightTire); - subscribe(socket, ref, VSSPath.vehicleRearLeftTire); - subscribe(socket, ref, VSSPath.vehicleRearRightTire); - subscribe(socket, ref, VSSPath.vehicleIsChildLockActiveLeft); - subscribe(socket, ref, VSSPath.vehicleIsChildLockActiveRight); - subscribe(socket, ref, VSSPath.vehicleFuelRate); - subscribe(socket, ref, VSSPath.vehicleInsideTemperature); - subscribe(socket, ref, VSSPath.vehicleOutsideTemperature); - } - - static void update(WebSocket socket, WidgetRef ref) { - get(socket, ref, VSSPath.vehicleSpeed); - get(socket, ref, VSSPath.vehicleEngineSpeed); - get(socket, ref, VSSPath.vehicleFuelLevel); - get(socket, ref, VSSPath.vehicleOutsideTemperature); - get(socket, ref, VSSPath.vehicleFrontLeftTire); - get(socket, ref, VSSPath.vehicleFrontRightTire); - get(socket, ref, VSSPath.vehicleRearLeftTire); - get(socket, ref, VSSPath.vehicleRearRightTire); - get(socket, ref, VSSPath.vehicleIsChildLockActiveLeft); - get(socket, ref, VSSPath.vehicleIsChildLockActiveRight); - get(socket, ref, VSSPath.vehicleFuelRate); - get(socket, ref, VSSPath.vehicleInsideTemperature); - } - - static void authorize(WebSocket socket, WidgetRef ref) { - final config = ref.read(ConfigStateprovider); - - Map<String, dynamic> map = { - "action": "authorize", - "tokens": config.kuksaAuthToken, - "requestId": requestId - }; - socket.add(jsonEncode(map)); - } - - static void get(WebSocket socket, WidgetRef ref, String path) { - final config = ref.read(ConfigStateprovider); - - Map<String, dynamic> map = { - "action": "get", - "tokens": config.kuksaAuthToken, - "path": path, - "requestId": requestId - }; - socket.add(jsonEncode(map)); - } - - static void set(WebSocket socket, WidgetRef ref, String path, String value) { - final config = ref.read(ConfigStateprovider); - Map<String, dynamic> map = { - "action": "set", - "tokens": config.kuksaAuthToken, - "path": path, - "requestId": requestId, - "value": value - }; - socket.add(jsonEncode(map)); - } - - static void subscribe(WebSocket socket, WidgetRef ref, String path) { - final config = ref.read(ConfigStateprovider); - - Map<String, dynamic> map = { - "action": "subscribe", - "tokens": config.kuksaAuthToken, - "path": path, - "requestId": requestId - }; - socket.add(jsonEncode(map)); - } - - static void parseData(WidgetRef ref, String data) { - Map<String, dynamic> dataMap = jsonDecode(data); - if (dataMap["action"] == "subscription" || dataMap["action"] == "get") { - if (dataMap.containsKey("data")) { - if ((dataMap["data"] as Map<String, dynamic>).containsKey("dp") && - (dataMap["data"] as Map<String, dynamic>).containsKey("path")) { - String path = dataMap["data"]["path"]; - Map<String, dynamic> dp = dataMap["data"]["dp"]; - if (dp.containsKey("value")) { - if (dp["value"] != "---") { - switch (path) { - case VSSPath.vehicleSpeed: - ref - .read(vehicleSignalSpeedProvider.notifier) - .update(speed: dp["value"]); - break; - case VSSPath.vehicleEngineSpeed: - ref - .read(vehicleSignalEngineSpeedProvider.notifier) - .update(speed: dp["value"].toDouble()); - break; - case VSSPath.vehicleFuelLevel: - ref - .read(vehicleSignalFuelLevelProvider.notifier) - .update(level: dp["value"]); - break; - case VSSPath.vehicleFuelRate: - ref - .read(vehicleSignalFuelRateProvider.notifier) - .update(rate: dp["value"]); - break; - case VSSPath.vehicleFrontLeftTire: - ref - .read(vehicleSignalFrontLeftTirePressureProvider.notifier) - .update(pressure: dp["value"]); - break; - case VSSPath.vehicleFrontRightTire: - ref - .read( - vehicleSignalFrontRightTirePressureProvider.notifier) - .update(pressure: dp["value"]); - break; - case VSSPath.vehicleRearLeftTire: - ref - .read(vehicleSignalRearLeftTirePressureProvider.notifier) - .update(pressure: dp["value"]); - break; - case VSSPath.vehicleRearRightTire: - ref - .read(vehicleSignalRearRightTirePressureProvider.notifier) - .update(pressure: dp["value"]); - break; - case VSSPath.vehicleIsChildLockActiveLeft: - ref - .read(vehicleSignalLeftChildLockActiveProvider.notifier) - .update(engaged: dp["value"]); - break; - case VSSPath.vehicleIsChildLockActiveRight: - ref - .read(vehicleSignalRightChildLockActiveProvider.notifier) - .update(engaged: dp["value"]); - break; - case VSSPath.vehicleInsideTemperature: - ref - .read(vehicleSignalInsideTempProvider.notifier) - .update(temp: dp["value"]); - break; - case VSSPath.vehicleOutsideTemperature: - ref - .read(vehicleSignalOutsideTempProvider.notifier) - .update(temp: dp["value"]); - break; - default: - print("$path Not Available yet!"); - } - } else { - print("ERROR:Value not available yet! Set Value of $path"); - } - } else { - print("ERROR:'value': Key not found!"); - } - } else if ((!dataMap["data"] as Map<String, dynamic>) - .containsKey("path")) { - print("ERROR:'path':key not found !"); - } else if ((dataMap["data"] as Map<String, dynamic>) - .containsKey("dp")) { - print("ERROR:'dp':key not found !"); - } - } else { - print("ERROR:'data':key not found!"); - } - } - } -} |