From f3f15717ac3fd8c6d66046bdd2a78352aacf5147 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Sat, 30 Nov 2024 12:42:39 +1300 Subject: [PATCH] add button to get firmware version and improve ui --- .../pages/settings/NodeSettingsList.vue | 109 +++++++++++++----- src/js/NodeAPI.js | 20 ++++ 2 files changed, 97 insertions(+), 32 deletions(-) diff --git a/src/components/pages/settings/NodeSettingsList.vue b/src/components/pages/settings/NodeSettingsList.vue index a2974e3..082f249 100644 --- a/src/components/pages/settings/NodeSettingsList.vue +++ b/src/components/pages/settings/NodeSettingsList.vue @@ -13,21 +13,80 @@
{{ getNodeHexId(nodeId) }} / {{ nodeId }}
-
+ +
- - -
+ +
+ +
Radio Configuration
+ + + +
+ + +
+ + + +
+ + +
User
+ + +
+ + + +
+ +
+
+ + + +
+ + +
+ + + +
+ + +
Channels
+ + +
+ + + +
+ +
+
+ +
+ + +
+ +
Commands
+ +
- +
-
User
+
Get Firmware Version
@@ -37,21 +96,18 @@
- - - -
+
- +
-
Channels
+
Reboot
@@ -61,26 +117,6 @@
- - -
- - -
- - - -
- - -
Reboot
- - -
- - - -
@@ -107,6 +143,15 @@ export default { getNodeLongName: (nodeId) => NodeUtils.getNodeLongName(nodeId), getNodeColour: (nodeId) => NodeUtils.getNodeColour(nodeId), getNodeTextColour: (nodeId) => NodeUtils.getNodeTextColour(nodeId), + async getDeviceFirmwareVersion(nodeId) { + try { + const response = await NodeAPI.remoteAdminGetDeviceMetadata(nodeId); + const firmwareVersion = response.firmwareVersion; + alert(firmwareVersion ?? "Unknown Firmware Version"); + } catch(e) { + DialogUtils.showErrorAlert(e); + } + }, async reboot(nodeId) { // confirm user wants to reboot node diff --git a/src/js/NodeAPI.js b/src/js/NodeAPI.js index e16bf5d..e084e30 100644 --- a/src/js/NodeAPI.js +++ b/src/js/NodeAPI.js @@ -481,6 +481,26 @@ class NodeAPI { } + /** + * Sends an admin request to get device metadata from the provided node id + * @param nodeId + * @returns {Promise<*>} + */ + static async remoteAdminGetDeviceMetadata(nodeId) { + + // create admin message packet + const adminMessageRequest = Protobuf.Admin.AdminMessage.fromJson({ + getDeviceMetadataRequest: true, + }); + + // send packet and wait for response + const adminMessageResponse = await this.sendAdminPacketAndWaitForResponse(nodeId, adminMessageRequest, true); + + // return device metadata from admin response + return adminMessageResponse.payloadVariant.value; + + } + } export default NodeAPI;