aboutsummaryrefslogtreecommitdiffstats
path: root/extras/Kuksa_Instance.py
diff options
context:
space:
mode:
authorsuchinton2001 <suchinton.2001@gmail.com>2023-10-09 16:00:58 +0530
committersuchinton2001 <suchinton.2001@gmail.com>2023-10-09 16:00:58 +0530
commitdb862e32df7f31e6453d7f05a6f011091b96ffab (patch)
tree6abcc3a2eceb79a43b7836d1d23a8594da375826 /extras/Kuksa_Instance.py
parent260bbf89836ff9ce98054e5166699a163a0d7c11 (diff)
agl-demo-control-panel: Add grpc support for databroker
- Add grpc support for databroker (set default protocol) - Add virtual car for script mode in IC app - Refine UI elements - Use specific grpc/ws jwt tokens - Simplify settings menu Bug-AGL: SPEC-4905 Signed-off-by: suchinton2001 <suchinton.2001@gmail.com> Change-Id: I59c4b1de80e280fe22993b2d2f7c92d6b41a89c7
Diffstat (limited to 'extras/Kuksa_Instance.py')
-rw-r--r--extras/Kuksa_Instance.py41
1 files changed, 24 insertions, 17 deletions
diff --git a/extras/Kuksa_Instance.py b/extras/Kuksa_Instance.py
index 49662bd..500e039 100644
--- a/extras/Kuksa_Instance.py
+++ b/extras/Kuksa_Instance.py
@@ -30,7 +30,7 @@ class KuksaClientSingleton:
Attributes:
_instance (Optional[KuksaClientSingleton]): The instance of the class.
_lock (threading.Lock): A lock to ensure thread-safety.
- config (dict): The configuration for KuksaClientThread.
+ kuksa_config (dict): The configuration for KuksaClientThread.
token (str): The path to the token file.
client (KuksaClientThread): The instance of KuksaClientThread.
@@ -73,12 +73,19 @@ class KuksaClientSingleton:
if KuksaClientSingleton._instance is not None:
raise Exception("This class is a singleton!")
- self.config = config.KUKSA_CONFIG
- self.token = config.TOKEN_PATH
+ self.kuksa_config = config.KUKSA_CONFIG
+ self.ws_token = config.WS_TOKEN
+ self.grpc_token = config.GRPC_TOKEN
+
+ if self.kuksa_config["protocol"] == 'ws':
+ self.token = self.ws_token
+ if self.kuksa_config["protocol"] == 'grpc':
+ self.token = self.grpc_token
try:
- self.client = kuksa.KuksaClientThread(self.config)
+ self.client = kuksa.KuksaClientThread(self.kuksa_config)
self.client.authorize(self.token)
+ self.client.start()
time.sleep(2)
if not self.client.checkConnection():
self.client = None
@@ -87,7 +94,7 @@ class KuksaClientSingleton:
KuksaClientSingleton._instance = self
- def reconnect(self, config, token):
+ def reconnect(self, config):
"""
Reconnects the client with the given configuration and token.
@@ -100,8 +107,17 @@ class KuksaClientSingleton:
"""
if self.client:
self.client.stop()
- self.client = kuksa.KuksaClientThread(config)
- self.client.authorize(token)
+
+ if self.kuksa_config["protocol"] == 'ws':
+ self.token = self.ws_token
+ self.kuksa_config["port"] = "8090"
+ if self.kuksa_config["protocol"] == 'grpc':
+ self.token = self.grpc_token
+ self.kuksa_config["port"] = "55555"
+
+ self.client = kuksa.KuksaClientThread(self.kuksa_config)
+ self.client.authorize(self.token)
+ self.client.start()
return self.client
def get_client(self):
@@ -123,16 +139,7 @@ class KuksaClientSingleton:
Returns:
dict: The configuration for KuksaClientThread.
"""
- return self.config
-
- def get_token(self):
- """
- Returns the path to the token file.
-
- Returns:
- str: The path to the token file.
- """
- return self.token
+ return self.kuksa_config
def status(self):
"""