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.
This commit is contained in:
agessaman
2026-03-19 20:12:44 -07:00
parent 07a2db4ede
commit e5d0804069
+7 -1
View File
@@ -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: