fix: accept PKI direct messages without channel

This commit is contained in:
2026-09-07 21:59:18 -07:00
parent d7aa18682b
commit facf1742ef
3 changed files with 51 additions and 5 deletions
+12 -4
View File
@@ -214,13 +214,21 @@ def get_adapter_class():
"""Handle incoming text packet from Meshtastic pubsub (worker thread)."""
try:
ch = packet.get("channel", 0)
if self.channel_index is not None and ch != self.channel_index:
my_info = getattr(interface, "myInfo", None)
my_node_num = getattr(my_info, "my_node_num", 0)
is_direct_to_me = packet.get("to") == my_node_num
is_pki_dm = is_direct_to_me and packet.get("pkiEncrypted", False)
if (
self.channel_index is not None
and ch != self.channel_index
and not is_pki_dm
):
# Ignore packets from different channels (e.g. public channel 0).
# PKI direct messages omit the channel field and decode as
# channel 0 even when sent from a secondary channel.
return
from_id = packet.get("fromId") or f"!{packet.get('from', 0):08x}"
my_info = getattr(interface, "myInfo", None)
my_node_num = getattr(my_info, "my_node_num", 0)
if packet.get("from") == my_node_num:
# Prevent self-message loops.
return
@@ -237,7 +245,7 @@ def get_adapter_class():
return
to_id = packet.get("toId")
is_dm = to_id != "^all" and packet.get("to") == my_node_num
is_dm = to_id != "^all" and is_direct_to_me
chat_id = from_id if is_dm else f"channel_{ch}"
chat_type = "dm" if is_dm else "channel"