1
0
mirror of https://github.com/thingsboard/thingsboard-gateway synced 2025-10-26 22:31:42 +08:00

Added gateway RPC request "gateway_version" to check current and the latest version of the gateway

This commit is contained in:
zbeacon
2020-07-14 09:34:59 +03:00
parent bc20118690
commit bf4d4fe7d9
2 changed files with 14 additions and 2 deletions

View File

@@ -112,6 +112,7 @@ class TBGatewayService:
"stats": self.__form_statistics,
"devices": self.__rpc_devices,
"update": self.__rpc_update,
"version": self.__rpc_version,
}
self.__sheduled_rpc_calls = []
self.__self_rpc_sheduled_methods_functions = {
@@ -523,6 +524,17 @@ class TBGatewayService:
}
return result
def __rpc_version(self, *args):
try:
result = {"resp": self.__updater.get_version(),
"code": 200,
}
except Exception as e:
result = {"error": str(e),
"code": 500
}
return result
def rpc_with_reply_processing(self, topic, content):
req_id = self.__rpc_requests_in_progress[topic][0]["data"]["id"]
device = self.__rpc_requests_in_progress[topic][0]["device"]

View File

@@ -33,7 +33,7 @@ class TBUpdater(Thread):
def __init__(self):
super().__init__()
self.__version = {"current_version": get_distribution('thingsboard_gateway').version,
"latest_version": None}
"latest_version": get_distribution('thingsboard_gateway').version}
self.__instance_id = str(uuid1())
self.__platform = "deb"
self.__os_version = platform()
@@ -94,7 +94,7 @@ class TBUpdater(Thread):
return request_args
def update(self):
if self.__version["latest_version"] is not None:
if self.__version["latest_version"] != self.__version["current_version"]:
result = TBUtility.install_package("thingsboard-gateway", self.__version["latest_version"])
else:
result = "Congratulations! You have the latest version."