mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-08-06 18:59:37 +00:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user