From d57162375acb2c3223d8a75c7a9b142fb7715cc0 Mon Sep 17 00:00:00 2001 From: Florent Date: Mon, 2 Feb 2026 13:18:44 -0400 Subject: [PATCH] autoadd_config --- src/meshcore/commands/contact.py | 9 +++++++++ src/meshcore/events.py | 1 + src/meshcore/packets.py | 1 + src/meshcore/reader.py | 7 +++++++ 4 files changed, 18 insertions(+) diff --git a/src/meshcore/commands/contact.py b/src/meshcore/commands/contact.py index 9786ecd..d4c7187 100644 --- a/src/meshcore/commands/contact.py +++ b/src/meshcore/commands/contact.py @@ -143,3 +143,12 @@ class ContactCommands(CommandHandlerBase): async def change_contact_flags(self, contact, flags) -> Event: return await self.update_contact(contact, flags=flags) + + async def set_autoadd_config(self, flag : int) -> Event: + data = b"\x3A" + flag.to_bytes(1, "little", signed=False) + return await self.send(data, [EventType.OK, EventType.ERROR]) + + async def get_autoadd_config(self) -> Event: + data = b"\x3B" + return await self.send(data, [EventType.AUTOADD_CONFIG, EventType.ERROR]) + diff --git a/src/meshcore/events.py b/src/meshcore/events.py index 0012939..f11694d 100644 --- a/src/meshcore/events.py +++ b/src/meshcore/events.py @@ -22,6 +22,7 @@ class EventType(Enum): MSG_SENT = "message_sent" NEW_CONTACT = "new_contact" NEXT_CONTACT = "next_contact" + AUTOADD_CONFIG = "autoadd_config" # Push notifications ADVERTISEMENT = "advertisement" diff --git a/src/meshcore/packets.py b/src/meshcore/packets.py index 8eb707f..28412e8 100644 --- a/src/meshcore/packets.py +++ b/src/meshcore/packets.py @@ -42,6 +42,7 @@ class PacketType(Enum): SIGNATURE = 20 CUSTOM_VARS = 21 STATS = 24 + AUTOADD_CONFIG = 25 BINARY_REQ = 50 FACTORY_RESET = 51 PATH_DISCOVERY = 52 diff --git a/src/meshcore/reader.py b/src/meshcore/reader.py index 1b11d22..cc781ae 100644 --- a/src/meshcore/reader.py +++ b/src/meshcore/reader.py @@ -378,6 +378,13 @@ class MessageReader: logger.error(f"Unknown stats type: {stats_type}, data: {data.hex()}") await self.dispatcher.dispatch(Event(EventType.ERROR, {"reason": f"unknown_stats_type: {stats_type}"})) + elif packet_type_value == PacketType.AUTOADD_CONFIG.value: + logger.debug(f"received autoadd config response: {data.hex()}") + + res = {} + res["config"] = dbuf.read(1)[0] + await self.dispatcher.dispatch(Event(EventType.AUTOADD_CONFIG, res, res)) + elif packet_type_value == PacketType.CHANNEL_INFO.value: logger.debug(f"received channel info response: {data.hex()}") res = {}