mirror of
https://github.com/thingsboard/thingsboard-gateway
synced 2025-10-26 22:31:42 +08:00
Added passing config folder path to client.
This commit is contained in:
@@ -16,6 +16,7 @@ import time
|
||||
import threading
|
||||
import logging
|
||||
from ssl import SSLContext, PROTOCOL_TLSv1_2, CERT_REQUIRED
|
||||
from os import path
|
||||
|
||||
from thingsboard_gateway.tb_client.tb_gateway_mqtt import TBGatewayMqttClient
|
||||
|
||||
@@ -23,7 +24,7 @@ log = logging.getLogger("tb_connection")
|
||||
|
||||
|
||||
class TBClient(threading.Thread):
|
||||
def __init__(self, config):
|
||||
def __init__(self, config, config_folder_path):
|
||||
super().__init__()
|
||||
self.setName('Connection thread.')
|
||||
self.daemon = True
|
||||
@@ -45,9 +46,9 @@ class TBClient(threading.Thread):
|
||||
self.__token = str(credentials["accessToken"])
|
||||
self.client = TBGatewayMqttClient(self.__host, self.__port, self.__token, self, quality_of_service=self.__default_quality_of_service)
|
||||
if self.__tls:
|
||||
self.__ca_cert = credentials.get("caCert")
|
||||
self.__private_key = credentials.get("privateKey")
|
||||
self.__cert = credentials.get("cert")
|
||||
self.__ca_cert = config_folder_path + credentials.get("caCert") if credentials.get("caCert") is not None else None
|
||||
self.__private_key = config_folder_path + credentials.get("privateKey") if credentials.get("privateKey") is not None else None
|
||||
self.__cert = config_folder_path + credentials.get("cert") if credentials.get("cert") is not None else None
|
||||
self.client._client.tls_set(ca_certs=self.__ca_cert,
|
||||
certfile=self.__cert,
|
||||
keyfile=self.__private_key,
|
||||
|
||||
@@ -85,7 +85,7 @@ class TBGatewayService:
|
||||
self.__rpc_register_queue = Queue(-1)
|
||||
self.__rpc_requests_in_progress = {}
|
||||
self.__connected_devices_file = "connected_devices.json"
|
||||
self.tb_client = TBClient(self.__config["thingsboard"])
|
||||
self.tb_client = TBClient(self.__config["thingsboard"], self._config_dir)
|
||||
self.tb_client.connect()
|
||||
self.subscribe_to_required_topics()
|
||||
self.__subscribed_to_rpc_topics = True
|
||||
|
||||
Reference in New Issue
Block a user