aboutsummaryrefslogtreecommitdiffstats
path: root/lib/data/data_providers
diff options
context:
space:
mode:
authorLisandro Pérez Meyer <lpmeyer@ics.com>2023-11-28 13:40:59 -0300
committerLisandro Perez Meyer <lpmeyer@ics.com>2023-11-28 17:17:09 +0000
commitb9377beb28bb372f8fc29dfe3eeb9145462b716f (patch)
treedc8ee6133102bd5f789c0a550d7c26345142d1b5 /lib/data/data_providers
parent8558b640173de8fbfe37111b29e4fc68dbc80da1 (diff)
Update HVAC fan.
This also removes commented out code. Original by Sabin Sajeevan <ssajeevan@ics.com>. Bug-AGL: SPEC-4971 Change-Id: I31c3b3046f6e3bdd9cc641d403467eda11144f31 Signed-off-by: Lisandro Pérez Meyer <lpmeyer@ics.com>
Diffstat (limited to 'lib/data/data_providers')
-rw-r--r--lib/data/data_providers/vehicle_notifier.dart47
1 files changed, 26 insertions, 21 deletions
diff --git a/lib/data/data_providers/vehicle_notifier.dart b/lib/data/data_providers/vehicle_notifier.dart
index 8538ac1..c11332c 100644
--- a/lib/data/data_providers/vehicle_notifier.dart
+++ b/lib/data/data_providers/vehicle_notifier.dart
@@ -158,10 +158,10 @@ class VehicleNotifier extends StateNotifier<Vehicle> {
Future<KuksaConfig> readConfig() async {
String hostname = KuksaConfig.defaultHostname;
int port = KuksaConfig.defaultPort;
- bool use_tls = false;
- String ca_path = KuksaConfig.defaultCaCertPath;
- List<int> ca_cert = [];
- String tls_server_name = "";
+ bool useTls = false;
+ String caPath = KuksaConfig.defaultCaCertPath;
+ List<int> caCert = [];
+ String tlsServerName = "";
String token = "";
// Read build time configuration from bundle
@@ -179,16 +179,18 @@ class VehicleNotifier extends StateNotifier<Vehicle> {
if (yamlMap.containsKey('use-tls')) {
var value = yamlMap['use-tls'];
- if (value is bool) use_tls = value;
+ if (value is bool) {
+ useTls = value;
+ }
}
- if (use_tls) {
+ if (useTls) {
if (yamlMap.containsKey('ca-certificate')) {
- ca_path = yamlMap['ca-certificate'];
+ caPath = yamlMap['ca-certificate'];
}
if (yamlMap.containsKey('tls-server-name')) {
- tls_server_name = yamlMap['tls_server_name'];
+ tlsServerName = yamlMap['tls_server_name'];
}
}
@@ -217,24 +219,26 @@ class VehicleNotifier extends StateNotifier<Vehicle> {
if (yamlMap.containsKey('use-tls')) {
var value = yamlMap['use-tls'];
- if (value is bool) use_tls = value;
+ if (value is bool) {
+ useTls = value;
+ }
}
//debugPrint("Use TLS = $use_tls");
- if (use_tls) {
+ if (useTls) {
if (yamlMap.containsKey('ca-certificate')) {
- ca_path = yamlMap['ca-certificate'];
+ caPath = yamlMap['ca-certificate'];
}
try {
- ca_cert = File(ca_path).readAsBytesSync();
+ caCert = File(caPath).readAsBytesSync();
} on Exception catch (_) {
- print("ERROR: Could not read CA certificate file $ca_path");
- ca_cert = [];
+ print("ERROR: Could not read CA certificate file $caPath");
+ caCert = [];
}
//debugPrint("CA cert = $ca_cert");
if (yamlMap.containsKey('tls-server-name')) {
- tls_server_name = yamlMap['tls_server_name'];
+ tlsServerName = yamlMap['tls_server_name'];
}
}
@@ -262,9 +266,9 @@ class VehicleNotifier extends StateNotifier<Vehicle> {
hostname: hostname,
port: port,
authorization: token,
- use_tls: use_tls,
- ca_certificate: ca_cert,
- tls_server_name: tls_server_name);
+ use_tls: useTls,
+ ca_certificate: caCert,
+ tls_server_name: tlsServerName);
}
void startListen() async {
@@ -272,14 +276,15 @@ class VehicleNotifier extends StateNotifier<Vehicle> {
ChannelCredentials creds;
if (config.use_tls && config.ca_certificate.isNotEmpty) {
print("Using TLS");
- if (config.tls_server_name.isNotEmpty)
+ if (config.tls_server_name.isNotEmpty) {
creds = ChannelCredentials.secure(
certificates: config.ca_certificate,
authority: config.tls_server_name);
- else
+ } else {
creds = ChannelCredentials.secure(certificates: config.ca_certificate);
+ }
} else {
- creds = ChannelCredentials.insecure();
+ creds = const ChannelCredentials.insecure();
}
channel = ClientChannel(config.hostname,
port: config.port, options: ChannelOptions(credentials: creds));