From e5d0804069cd9a1976aa317965de5245dacff77a Mon Sep 17 00:00:00 2001 From: agessaman Date: Thu, 19 Mar 2026 20:12:44 -0700 Subject: [PATCH] Refactor contact addition in MessageHandler to streamline parameters - Updated the `add_contact` method call to only pass necessary fields (name and optional public_key), improving compatibility with device APIs. - Removed unnecessary RSSI/SNR values from `contact_data` to prevent issues with unsigned integer handling in some devices. --- modules/message_handler.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/message_handler.py b/modules/message_handler.py index 6a7bf58..0774bd9 100644 --- a/modules/message_handler.py +++ b/modules/message_handler.py @@ -2943,7 +2943,13 @@ class MessageHandler: # Add companion to device contact list try: - result = await self.bot.meshcore.commands.add_contact(contact_data) + # Only pass the fields required by `add_contact` (name + optional public_key). + # `contact_data` may include RSSI/SNR values (often negative in dBm) which some + # device APIs treat as unsigned integers. + if public_key: + result = await self.bot.meshcore.commands.add_contact(contact_name, public_key) + else: + result = await self.bot.meshcore.commands.add_contact(contact_name) if hasattr(result, 'type') and result.type.name == 'OK': self.logger.info(f"✅ Companion {contact_name} added to device contacts") else: