summaryrefslogtreecommitdiffstats
path: root/lib/kuksa-server/vehicle_methods.dart
diff options
context:
space:
mode:
authorHritik Chouhan <hritikc3961@gmail.com>2022-09-01 19:15:56 +0200
committerHritik Chouhan <hritikc3961@gmail.com>2022-09-16 17:25:01 +0200
commit5559cdb261cfd3e69daa2349906f071dc2491c0d (patch)
tree12a530a7ab6b8f5fc758f228bf1729e733db9aa8 /lib/kuksa-server/vehicle_methods.dart
parentb7ba5e78b0ca5245cd9c09313d40561e75d0b120 (diff)
Upload Flutter-HVAC application for IVI
Flutter hvac app which sets value to KUKSA.VAL like Fan speed,left and right zone climate temperature, AC vent direction, Air circulation,Front and Rear Wind shield defrost. Update UI and removed Unused code. Bug-AGL: SPEC-4546 Change-Id: I57f7a9a2954520f4bb781a5ec02be612d72cf404 Signed-off-by: Hritik Chouhan <hritikc3961@gmail.com>
Diffstat (limited to 'lib/kuksa-server/vehicle_methods.dart')
-rw-r--r--lib/kuksa-server/vehicle_methods.dart97
1 files changed, 97 insertions, 0 deletions
diff --git a/lib/kuksa-server/vehicle_methods.dart b/lib/kuksa-server/vehicle_methods.dart
new file mode 100644
index 0000000..2dda79f
--- /dev/null
+++ b/lib/kuksa-server/vehicle_methods.dart
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: Apache-2.0
+
+import 'dart:convert';
+import 'dart:io';
+
+import 'package:flutter_hvac/config.dart';
+import 'package:flutter_riverpod/flutter_riverpod.dart';
+import 'package:flutter_hvac/kuksa-server/vehicle_server_path.dart';
+
+
+class VISS {
+ static const requestId = "test-id";
+ static void init(WebSocket socket,WidgetRef ref) {
+ authorize(socket,ref);
+
+ subscribe(socket,ref, VSPath.vehicleFrontLeftTier);
+ subscribe(socket,ref, VSPath.vehicleFrontRightTier);
+ subscribe(socket,ref, VSPath.vehicleRearLeftTier);
+ subscribe(socket,ref, VSPath.vehicleRearRightTier);
+ subscribe(socket,ref, VSPath.vehicleIsChildLockActiveLeft);
+ subscribe(socket,ref, VSPath.vehicleIsChildLockActiveRight);
+ subscribe(socket,ref, VSPath.vehicleCurrentLatitude);
+ subscribe(socket,ref, VSPath.vehicleCurrentLongitude);
+ subscribe(socket,ref, VSPath.vehicleInsideTemperature);
+ subscribe(socket,ref, VSPath.vehicleAmbientAirTemperature);
+ }
+
+ static void update(WebSocket socket,WidgetRef ref) {
+ get(socket,ref, VSPath.vehicleAmbientAirTemperature);
+ get(socket,ref, VSPath.vehicleTrunkLocked);
+ get(socket, ref,VSPath.vehicleTrunkOpen);
+
+ get(socket,ref, VSPath.vehicleFrontLeftTier);
+ get(socket,ref, VSPath.vehicleFrontRightTier);
+ get(socket,ref, VSPath.vehicleRearLeftTier);
+ get(socket,ref, VSPath.vehicleRearRightTier);
+ get(socket,ref, VSPath.vehicleIsChildLockActiveLeft);
+ get(socket,ref, VSPath.vehicleIsChildLockActiveRight);
+ get(socket,ref, VSPath.vehicleCurrentLatitude);
+ get(socket,ref, VSPath.vehicleCurrentLongitude);
+ get(socket,ref, VSPath.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));
+ }
+
+
+}