From 6b4bf0e31a4376ac82a9862871a72b45cdc3cf7b Mon Sep 17 00:00:00 2001 From: liamcottle Date: Sun, 5 Jan 2025 23:22:20 +1300 Subject: [PATCH] ignore lxmf messages if they are telemetry requests from sideband --- meshchat.py | 14 ++++++++++++++ src/backend/sideband_commands.py | 3 +++ 2 files changed, 17 insertions(+) create mode 100644 src/backend/sideband_commands.py diff --git a/meshchat.py b/meshchat.py index 6f1b9a9..3d4242f 100644 --- a/meshchat.py +++ b/meshchat.py @@ -27,6 +27,7 @@ from src.backend.colour_utils import ColourUtils from src.backend.interface_config_parser import InterfaceConfigParser from src.backend.lxmf_message_fields import LxmfImageField, LxmfFileAttachmentsField, LxmfFileAttachment, LxmfAudioField from src.backend.audio_call_manager import AudioCall, AudioCallManager +from src.backend.sideband_commands import SidebandCommands # NOTE: this is required to be able to pack our app with cxfreeze as an exe, otherwise it can't access bundled assets @@ -2327,6 +2328,19 @@ class ReticulumMeshChat: def on_lxmf_delivery(self, lxmf_message: LXMF.LXMessage): try: + # check if this lxmf message contains a telemetry request command from sideband + is_sideband_telemetry_request = False + lxmf_fields = lxmf_message.get_fields() + if LXMF.FIELD_COMMANDS in lxmf_fields: + for command in lxmf_fields[LXMF.FIELD_COMMANDS]: + if SidebandCommands.TELEMETRY_REQUEST in command: + is_sideband_telemetry_request = True + + # ignore telemetry requests from sideband + if is_sideband_telemetry_request: + print("Ignoring received LXMF message as it is a telemetry request command") + return + # upsert lxmf message to database self.db_upsert_lxmf_message(lxmf_message) diff --git a/src/backend/sideband_commands.py b/src/backend/sideband_commands.py new file mode 100644 index 0000000..d28d9f0 --- /dev/null +++ b/src/backend/sideband_commands.py @@ -0,0 +1,3 @@ +# https://github.com/markqvist/Sideband/blob/e515889e210037f881c201e0d627a7b09a48eb69/sbapp/sideband/sense.py#L11 +class SidebandCommands: + TELEMETRY_REQUEST = 0x01