From cea8dd8eacc772d4cc60a8036a28d6778c909062 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 12 Oct 2025 18:00:59 +0000 Subject: [PATCH] Release and Render --- software/release/all/config.py | 4 ++-- software/release/all/ssp_networking.py | 28 +++++++++++++++++++++++--- software/release/am1/config.py | 5 ++--- software/release/am1/ssp_networking.py | 28 +++++++++++++++++++++++--- software/release/hm3/config.py | 4 ++-- software/release/hm3/ssp_networking.py | 28 +++++++++++++++++++++++--- software/release/mm1/config.py | 4 ++-- software/release/mm1/ssp_networking.py | 28 +++++++++++++++++++++++--- software/release/sl1/config.py | 4 ++-- software/release/sl1/ssp_networking.py | 28 +++++++++++++++++++++++--- software/release/sp1/config.py | 4 ++-- software/release/sp1/ssp_networking.py | 28 +++++++++++++++++++++++--- 12 files changed, 162 insertions(+), 31 deletions(-) diff --git a/software/release/all/config.py b/software/release/all/config.py index 8282c57..6bbab1c 100644 --- a/software/release/all/config.py +++ b/software/release/all/config.py @@ -3,7 +3,7 @@ 'adxl345.py': 3, 'am1.py': 1, 'hm1.py': 1, - 'ssp_networking.py': 3, + 'ssp_networking.py': 4, 'files.py': 2, 'icons.py': 2, 'prefs.py': 2, @@ -13,7 +13,7 @@ 'sm3.py': 1, 'sl1.py': 1, 'smartlight.py': 1, - 'networking.py': 5, + 'networking.py': 6, 'main.py': 2, 'boot.py': 0 } diff --git a/software/release/all/ssp_networking.py b/software/release/all/ssp_networking.py index 51abd78..0c2b5ba 100644 --- a/software/release/all/ssp_networking.py +++ b/software/release/all/ssp_networking.py @@ -127,6 +127,10 @@ def hive_configure(self, mac, hive_config, channel=None, ifidx=None, sudo=False) self.networking.dprint("net.cmd.hive_configure") self.send_custom("Hive-Configure", mac, f"{hive_config}", channel, ifidx, sudo) + def hive_file(self, mac, file_name, hive_file, channel=None, ifidx=None, sudo=False): + self.networking.dprint("net.cmd.hive_file") + self.send_custom("Hive-File", mac, f"{[file_name, hive_file]}", channel, ifidx, sudo) + def firmware_update(self, mac, channel=None, ifidx=None, sudo=False): self.networking.dprint("net.cmd.firmware_update") self.send_custom("Firmware-Update", mac, None, channel, ifidx, sudo) @@ -265,7 +269,7 @@ def custom_cmd_handler(data): if __check_authorisation(sender_mac, payload): try: from config import hive_config - new_config = payload[0] + new_config = eval(payload[0]) hive_config.update(new_config) file_path = "config.py" with open(file_path, "r") as f: @@ -283,6 +287,24 @@ def custom_cmd_handler(data): __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, e) else: __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, "Not authorised") + elif (msg_subkey := "Hive-File") and subtype == msg_subcodes[msg_key][msg_subkey]: # File-Hive + self.master.networking.iprint(f"{msg_subkey} ({subtype}) command received from {sender_mac} ({self.master.networking.aen.peer_name(sender_mac)})") + if __check_authorisation(sender_mac, payload): + try: + # Insert write file logic here + file_path = eval(payload[0]) + file_hive = eval(payload[1]) + if isinstance(file_hive, str): + file_hive = [file_hive] + with open(file_path, "w") as f: + f.write(f"{file_hive}\n") + self.master.networking.iprint("No file-hive logic written just yet") + __send_confirmation("Success", sender_mac, f"{msg_subkey} ({subtype})", payload) + except Exception as e: + self.master.networking.eprint(f"Error: {e} with payload: {payload}") + __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, e) + else: + __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, "Not authorised") elif (msg_subkey := "Firmware-Update") and subtype == msg_subcodes[msg_key][msg_subkey]: # Firmware-Update self.master.networking.iprint(f"{msg_subkey} ({subtype}) command received from {sender_mac} ({self.master.networking.aen.peer_name(sender_mac)})") if __check_authorisation(sender_mac, payload): @@ -390,7 +412,8 @@ def custom_cmd_handler(data): f"{msg_subkey} ({subtype}) command received from {sender_mac} ({self.master.networking.aen.peer_name(sender_mac)})") if __check_authorisation(sender_mac, payload): try: - self.master.config.update(payload[0]) + new_config = eval(payload[0]) + self.master.config.update(new_config) if payload[1]: file_path = "config.py" with open(file_path, "r") as f: @@ -619,4 +642,3 @@ def custom_ack_handler(data): self.master.networking.aen.cmd(custom_cmd_handler) self.master.networking.aen.inf(custom_inf_handler) self.master.networking.aen.ack(custom_ack_handler) - diff --git a/software/release/am1/config.py b/software/release/am1/config.py index c383426..ef35e2f 100644 --- a/software/release/am1/config.py +++ b/software/release/am1/config.py @@ -1,9 +1,9 @@ -config = {'ap_channel': 1, 'id': None, 'name': 'Nick', 'sta_mac': None, 'ap_mac': None, 'configuration': None, 'sta_channel': 1, 'version': '2025-10-12-155152'} +config = {'ap_channel': 1, 'id': None, 'name': 'Nick', 'sta_mac': None, 'ap_mac': None, 'configuration': None, 'sta_channel': 1, 'version': '2025-10-12-175607'} version = { 'adxl345.py': 3, 'am1.py': 1, 'hm1.py': 1, - 'ssp_networking.py': 3, + 'ssp_networking.py': 4, 'files.py': 2, 'icons.py': 2, 'prefs.py': 2, @@ -39,7 +39,6 @@ "Resend": 0x16, "Hive-Set": 0x17, "Hive-Configure": 0x18, - "Hive-File": 0x19, "Web-Repl": 0x20, "WiFi-Connect": 0x21, "WiFi-Disconnect": 0x22, diff --git a/software/release/am1/ssp_networking.py b/software/release/am1/ssp_networking.py index 51abd78..0c2b5ba 100644 --- a/software/release/am1/ssp_networking.py +++ b/software/release/am1/ssp_networking.py @@ -127,6 +127,10 @@ def hive_configure(self, mac, hive_config, channel=None, ifidx=None, sudo=False) self.networking.dprint("net.cmd.hive_configure") self.send_custom("Hive-Configure", mac, f"{hive_config}", channel, ifidx, sudo) + def hive_file(self, mac, file_name, hive_file, channel=None, ifidx=None, sudo=False): + self.networking.dprint("net.cmd.hive_file") + self.send_custom("Hive-File", mac, f"{[file_name, hive_file]}", channel, ifidx, sudo) + def firmware_update(self, mac, channel=None, ifidx=None, sudo=False): self.networking.dprint("net.cmd.firmware_update") self.send_custom("Firmware-Update", mac, None, channel, ifidx, sudo) @@ -265,7 +269,7 @@ def custom_cmd_handler(data): if __check_authorisation(sender_mac, payload): try: from config import hive_config - new_config = payload[0] + new_config = eval(payload[0]) hive_config.update(new_config) file_path = "config.py" with open(file_path, "r") as f: @@ -283,6 +287,24 @@ def custom_cmd_handler(data): __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, e) else: __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, "Not authorised") + elif (msg_subkey := "Hive-File") and subtype == msg_subcodes[msg_key][msg_subkey]: # File-Hive + self.master.networking.iprint(f"{msg_subkey} ({subtype}) command received from {sender_mac} ({self.master.networking.aen.peer_name(sender_mac)})") + if __check_authorisation(sender_mac, payload): + try: + # Insert write file logic here + file_path = eval(payload[0]) + file_hive = eval(payload[1]) + if isinstance(file_hive, str): + file_hive = [file_hive] + with open(file_path, "w") as f: + f.write(f"{file_hive}\n") + self.master.networking.iprint("No file-hive logic written just yet") + __send_confirmation("Success", sender_mac, f"{msg_subkey} ({subtype})", payload) + except Exception as e: + self.master.networking.eprint(f"Error: {e} with payload: {payload}") + __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, e) + else: + __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, "Not authorised") elif (msg_subkey := "Firmware-Update") and subtype == msg_subcodes[msg_key][msg_subkey]: # Firmware-Update self.master.networking.iprint(f"{msg_subkey} ({subtype}) command received from {sender_mac} ({self.master.networking.aen.peer_name(sender_mac)})") if __check_authorisation(sender_mac, payload): @@ -390,7 +412,8 @@ def custom_cmd_handler(data): f"{msg_subkey} ({subtype}) command received from {sender_mac} ({self.master.networking.aen.peer_name(sender_mac)})") if __check_authorisation(sender_mac, payload): try: - self.master.config.update(payload[0]) + new_config = eval(payload[0]) + self.master.config.update(new_config) if payload[1]: file_path = "config.py" with open(file_path, "r") as f: @@ -619,4 +642,3 @@ def custom_ack_handler(data): self.master.networking.aen.cmd(custom_cmd_handler) self.master.networking.aen.inf(custom_inf_handler) self.master.networking.aen.ack(custom_ack_handler) - diff --git a/software/release/hm3/config.py b/software/release/hm3/config.py index 8e97aff..ef35e2f 100644 --- a/software/release/hm3/config.py +++ b/software/release/hm3/config.py @@ -1,9 +1,9 @@ -config = {'ap_channel': 1, 'id': None, 'name': 'Nick', 'sta_mac': None, 'ap_mac': None, 'configuration': None, 'sta_channel': 1, 'version': '2025-10-12-155152'} +config = {'ap_channel': 1, 'id': None, 'name': 'Nick', 'sta_mac': None, 'ap_mac': None, 'configuration': None, 'sta_channel': 1, 'version': '2025-10-12-175607'} version = { 'adxl345.py': 3, 'am1.py': 1, 'hm1.py': 1, - 'ssp_networking.py': 3, + 'ssp_networking.py': 4, 'files.py': 2, 'icons.py': 2, 'prefs.py': 2, diff --git a/software/release/hm3/ssp_networking.py b/software/release/hm3/ssp_networking.py index 51abd78..0c2b5ba 100644 --- a/software/release/hm3/ssp_networking.py +++ b/software/release/hm3/ssp_networking.py @@ -127,6 +127,10 @@ def hive_configure(self, mac, hive_config, channel=None, ifidx=None, sudo=False) self.networking.dprint("net.cmd.hive_configure") self.send_custom("Hive-Configure", mac, f"{hive_config}", channel, ifidx, sudo) + def hive_file(self, mac, file_name, hive_file, channel=None, ifidx=None, sudo=False): + self.networking.dprint("net.cmd.hive_file") + self.send_custom("Hive-File", mac, f"{[file_name, hive_file]}", channel, ifidx, sudo) + def firmware_update(self, mac, channel=None, ifidx=None, sudo=False): self.networking.dprint("net.cmd.firmware_update") self.send_custom("Firmware-Update", mac, None, channel, ifidx, sudo) @@ -265,7 +269,7 @@ def custom_cmd_handler(data): if __check_authorisation(sender_mac, payload): try: from config import hive_config - new_config = payload[0] + new_config = eval(payload[0]) hive_config.update(new_config) file_path = "config.py" with open(file_path, "r") as f: @@ -283,6 +287,24 @@ def custom_cmd_handler(data): __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, e) else: __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, "Not authorised") + elif (msg_subkey := "Hive-File") and subtype == msg_subcodes[msg_key][msg_subkey]: # File-Hive + self.master.networking.iprint(f"{msg_subkey} ({subtype}) command received from {sender_mac} ({self.master.networking.aen.peer_name(sender_mac)})") + if __check_authorisation(sender_mac, payload): + try: + # Insert write file logic here + file_path = eval(payload[0]) + file_hive = eval(payload[1]) + if isinstance(file_hive, str): + file_hive = [file_hive] + with open(file_path, "w") as f: + f.write(f"{file_hive}\n") + self.master.networking.iprint("No file-hive logic written just yet") + __send_confirmation("Success", sender_mac, f"{msg_subkey} ({subtype})", payload) + except Exception as e: + self.master.networking.eprint(f"Error: {e} with payload: {payload}") + __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, e) + else: + __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, "Not authorised") elif (msg_subkey := "Firmware-Update") and subtype == msg_subcodes[msg_key][msg_subkey]: # Firmware-Update self.master.networking.iprint(f"{msg_subkey} ({subtype}) command received from {sender_mac} ({self.master.networking.aen.peer_name(sender_mac)})") if __check_authorisation(sender_mac, payload): @@ -390,7 +412,8 @@ def custom_cmd_handler(data): f"{msg_subkey} ({subtype}) command received from {sender_mac} ({self.master.networking.aen.peer_name(sender_mac)})") if __check_authorisation(sender_mac, payload): try: - self.master.config.update(payload[0]) + new_config = eval(payload[0]) + self.master.config.update(new_config) if payload[1]: file_path = "config.py" with open(file_path, "r") as f: @@ -619,4 +642,3 @@ def custom_ack_handler(data): self.master.networking.aen.cmd(custom_cmd_handler) self.master.networking.aen.inf(custom_inf_handler) self.master.networking.aen.ack(custom_ack_handler) - diff --git a/software/release/mm1/config.py b/software/release/mm1/config.py index 8e97aff..ef35e2f 100644 --- a/software/release/mm1/config.py +++ b/software/release/mm1/config.py @@ -1,9 +1,9 @@ -config = {'ap_channel': 1, 'id': None, 'name': 'Nick', 'sta_mac': None, 'ap_mac': None, 'configuration': None, 'sta_channel': 1, 'version': '2025-10-12-155152'} +config = {'ap_channel': 1, 'id': None, 'name': 'Nick', 'sta_mac': None, 'ap_mac': None, 'configuration': None, 'sta_channel': 1, 'version': '2025-10-12-175607'} version = { 'adxl345.py': 3, 'am1.py': 1, 'hm1.py': 1, - 'ssp_networking.py': 3, + 'ssp_networking.py': 4, 'files.py': 2, 'icons.py': 2, 'prefs.py': 2, diff --git a/software/release/mm1/ssp_networking.py b/software/release/mm1/ssp_networking.py index 51abd78..0c2b5ba 100644 --- a/software/release/mm1/ssp_networking.py +++ b/software/release/mm1/ssp_networking.py @@ -127,6 +127,10 @@ def hive_configure(self, mac, hive_config, channel=None, ifidx=None, sudo=False) self.networking.dprint("net.cmd.hive_configure") self.send_custom("Hive-Configure", mac, f"{hive_config}", channel, ifidx, sudo) + def hive_file(self, mac, file_name, hive_file, channel=None, ifidx=None, sudo=False): + self.networking.dprint("net.cmd.hive_file") + self.send_custom("Hive-File", mac, f"{[file_name, hive_file]}", channel, ifidx, sudo) + def firmware_update(self, mac, channel=None, ifidx=None, sudo=False): self.networking.dprint("net.cmd.firmware_update") self.send_custom("Firmware-Update", mac, None, channel, ifidx, sudo) @@ -265,7 +269,7 @@ def custom_cmd_handler(data): if __check_authorisation(sender_mac, payload): try: from config import hive_config - new_config = payload[0] + new_config = eval(payload[0]) hive_config.update(new_config) file_path = "config.py" with open(file_path, "r") as f: @@ -283,6 +287,24 @@ def custom_cmd_handler(data): __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, e) else: __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, "Not authorised") + elif (msg_subkey := "Hive-File") and subtype == msg_subcodes[msg_key][msg_subkey]: # File-Hive + self.master.networking.iprint(f"{msg_subkey} ({subtype}) command received from {sender_mac} ({self.master.networking.aen.peer_name(sender_mac)})") + if __check_authorisation(sender_mac, payload): + try: + # Insert write file logic here + file_path = eval(payload[0]) + file_hive = eval(payload[1]) + if isinstance(file_hive, str): + file_hive = [file_hive] + with open(file_path, "w") as f: + f.write(f"{file_hive}\n") + self.master.networking.iprint("No file-hive logic written just yet") + __send_confirmation("Success", sender_mac, f"{msg_subkey} ({subtype})", payload) + except Exception as e: + self.master.networking.eprint(f"Error: {e} with payload: {payload}") + __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, e) + else: + __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, "Not authorised") elif (msg_subkey := "Firmware-Update") and subtype == msg_subcodes[msg_key][msg_subkey]: # Firmware-Update self.master.networking.iprint(f"{msg_subkey} ({subtype}) command received from {sender_mac} ({self.master.networking.aen.peer_name(sender_mac)})") if __check_authorisation(sender_mac, payload): @@ -390,7 +412,8 @@ def custom_cmd_handler(data): f"{msg_subkey} ({subtype}) command received from {sender_mac} ({self.master.networking.aen.peer_name(sender_mac)})") if __check_authorisation(sender_mac, payload): try: - self.master.config.update(payload[0]) + new_config = eval(payload[0]) + self.master.config.update(new_config) if payload[1]: file_path = "config.py" with open(file_path, "r") as f: @@ -619,4 +642,3 @@ def custom_ack_handler(data): self.master.networking.aen.cmd(custom_cmd_handler) self.master.networking.aen.inf(custom_inf_handler) self.master.networking.aen.ack(custom_ack_handler) - diff --git a/software/release/sl1/config.py b/software/release/sl1/config.py index 8e97aff..ef35e2f 100644 --- a/software/release/sl1/config.py +++ b/software/release/sl1/config.py @@ -1,9 +1,9 @@ -config = {'ap_channel': 1, 'id': None, 'name': 'Nick', 'sta_mac': None, 'ap_mac': None, 'configuration': None, 'sta_channel': 1, 'version': '2025-10-12-155152'} +config = {'ap_channel': 1, 'id': None, 'name': 'Nick', 'sta_mac': None, 'ap_mac': None, 'configuration': None, 'sta_channel': 1, 'version': '2025-10-12-175607'} version = { 'adxl345.py': 3, 'am1.py': 1, 'hm1.py': 1, - 'ssp_networking.py': 3, + 'ssp_networking.py': 4, 'files.py': 2, 'icons.py': 2, 'prefs.py': 2, diff --git a/software/release/sl1/ssp_networking.py b/software/release/sl1/ssp_networking.py index 51abd78..0c2b5ba 100644 --- a/software/release/sl1/ssp_networking.py +++ b/software/release/sl1/ssp_networking.py @@ -127,6 +127,10 @@ def hive_configure(self, mac, hive_config, channel=None, ifidx=None, sudo=False) self.networking.dprint("net.cmd.hive_configure") self.send_custom("Hive-Configure", mac, f"{hive_config}", channel, ifidx, sudo) + def hive_file(self, mac, file_name, hive_file, channel=None, ifidx=None, sudo=False): + self.networking.dprint("net.cmd.hive_file") + self.send_custom("Hive-File", mac, f"{[file_name, hive_file]}", channel, ifidx, sudo) + def firmware_update(self, mac, channel=None, ifidx=None, sudo=False): self.networking.dprint("net.cmd.firmware_update") self.send_custom("Firmware-Update", mac, None, channel, ifidx, sudo) @@ -265,7 +269,7 @@ def custom_cmd_handler(data): if __check_authorisation(sender_mac, payload): try: from config import hive_config - new_config = payload[0] + new_config = eval(payload[0]) hive_config.update(new_config) file_path = "config.py" with open(file_path, "r") as f: @@ -283,6 +287,24 @@ def custom_cmd_handler(data): __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, e) else: __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, "Not authorised") + elif (msg_subkey := "Hive-File") and subtype == msg_subcodes[msg_key][msg_subkey]: # File-Hive + self.master.networking.iprint(f"{msg_subkey} ({subtype}) command received from {sender_mac} ({self.master.networking.aen.peer_name(sender_mac)})") + if __check_authorisation(sender_mac, payload): + try: + # Insert write file logic here + file_path = eval(payload[0]) + file_hive = eval(payload[1]) + if isinstance(file_hive, str): + file_hive = [file_hive] + with open(file_path, "w") as f: + f.write(f"{file_hive}\n") + self.master.networking.iprint("No file-hive logic written just yet") + __send_confirmation("Success", sender_mac, f"{msg_subkey} ({subtype})", payload) + except Exception as e: + self.master.networking.eprint(f"Error: {e} with payload: {payload}") + __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, e) + else: + __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, "Not authorised") elif (msg_subkey := "Firmware-Update") and subtype == msg_subcodes[msg_key][msg_subkey]: # Firmware-Update self.master.networking.iprint(f"{msg_subkey} ({subtype}) command received from {sender_mac} ({self.master.networking.aen.peer_name(sender_mac)})") if __check_authorisation(sender_mac, payload): @@ -390,7 +412,8 @@ def custom_cmd_handler(data): f"{msg_subkey} ({subtype}) command received from {sender_mac} ({self.master.networking.aen.peer_name(sender_mac)})") if __check_authorisation(sender_mac, payload): try: - self.master.config.update(payload[0]) + new_config = eval(payload[0]) + self.master.config.update(new_config) if payload[1]: file_path = "config.py" with open(file_path, "r") as f: @@ -619,4 +642,3 @@ def custom_ack_handler(data): self.master.networking.aen.cmd(custom_cmd_handler) self.master.networking.aen.inf(custom_inf_handler) self.master.networking.aen.ack(custom_ack_handler) - diff --git a/software/release/sp1/config.py b/software/release/sp1/config.py index 8e97aff..ef35e2f 100644 --- a/software/release/sp1/config.py +++ b/software/release/sp1/config.py @@ -1,9 +1,9 @@ -config = {'ap_channel': 1, 'id': None, 'name': 'Nick', 'sta_mac': None, 'ap_mac': None, 'configuration': None, 'sta_channel': 1, 'version': '2025-10-12-155152'} +config = {'ap_channel': 1, 'id': None, 'name': 'Nick', 'sta_mac': None, 'ap_mac': None, 'configuration': None, 'sta_channel': 1, 'version': '2025-10-12-175607'} version = { 'adxl345.py': 3, 'am1.py': 1, 'hm1.py': 1, - 'ssp_networking.py': 3, + 'ssp_networking.py': 4, 'files.py': 2, 'icons.py': 2, 'prefs.py': 2, diff --git a/software/release/sp1/ssp_networking.py b/software/release/sp1/ssp_networking.py index 51abd78..0c2b5ba 100644 --- a/software/release/sp1/ssp_networking.py +++ b/software/release/sp1/ssp_networking.py @@ -127,6 +127,10 @@ def hive_configure(self, mac, hive_config, channel=None, ifidx=None, sudo=False) self.networking.dprint("net.cmd.hive_configure") self.send_custom("Hive-Configure", mac, f"{hive_config}", channel, ifidx, sudo) + def hive_file(self, mac, file_name, hive_file, channel=None, ifidx=None, sudo=False): + self.networking.dprint("net.cmd.hive_file") + self.send_custom("Hive-File", mac, f"{[file_name, hive_file]}", channel, ifidx, sudo) + def firmware_update(self, mac, channel=None, ifidx=None, sudo=False): self.networking.dprint("net.cmd.firmware_update") self.send_custom("Firmware-Update", mac, None, channel, ifidx, sudo) @@ -265,7 +269,7 @@ def custom_cmd_handler(data): if __check_authorisation(sender_mac, payload): try: from config import hive_config - new_config = payload[0] + new_config = eval(payload[0]) hive_config.update(new_config) file_path = "config.py" with open(file_path, "r") as f: @@ -283,6 +287,24 @@ def custom_cmd_handler(data): __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, e) else: __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, "Not authorised") + elif (msg_subkey := "Hive-File") and subtype == msg_subcodes[msg_key][msg_subkey]: # File-Hive + self.master.networking.iprint(f"{msg_subkey} ({subtype}) command received from {sender_mac} ({self.master.networking.aen.peer_name(sender_mac)})") + if __check_authorisation(sender_mac, payload): + try: + # Insert write file logic here + file_path = eval(payload[0]) + file_hive = eval(payload[1]) + if isinstance(file_hive, str): + file_hive = [file_hive] + with open(file_path, "w") as f: + f.write(f"{file_hive}\n") + self.master.networking.iprint("No file-hive logic written just yet") + __send_confirmation("Success", sender_mac, f"{msg_subkey} ({subtype})", payload) + except Exception as e: + self.master.networking.eprint(f"Error: {e} with payload: {payload}") + __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, e) + else: + __send_confirmation("Fail", sender_mac, f"{msg_subkey} ({subtype})", payload, "Not authorised") elif (msg_subkey := "Firmware-Update") and subtype == msg_subcodes[msg_key][msg_subkey]: # Firmware-Update self.master.networking.iprint(f"{msg_subkey} ({subtype}) command received from {sender_mac} ({self.master.networking.aen.peer_name(sender_mac)})") if __check_authorisation(sender_mac, payload): @@ -390,7 +412,8 @@ def custom_cmd_handler(data): f"{msg_subkey} ({subtype}) command received from {sender_mac} ({self.master.networking.aen.peer_name(sender_mac)})") if __check_authorisation(sender_mac, payload): try: - self.master.config.update(payload[0]) + new_config = eval(payload[0]) + self.master.config.update(new_config) if payload[1]: file_path = "config.py" with open(file_path, "r") as f: @@ -619,4 +642,3 @@ def custom_ack_handler(data): self.master.networking.aen.cmd(custom_cmd_handler) self.master.networking.aen.inf(custom_inf_handler) self.master.networking.aen.ack(custom_ack_handler) -