Skip to content

Commit 6bab385

Browse files
committed
Tweak error messaging in the onReceive function for sendtext packets
1 parent b8178d5 commit 6bab385

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

meshtastic/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def onReceive(packet, interface) -> None:
7474
args
7575
and args.sendtext
7676
and packet["to"] == interface.myInfo.my_node_num
77-
and d["portnum"] == portnums_pb2.PortNum.TEXT_MESSAGE_APP
77+
and d.get("portnum", portnums_pb2.PortNum.UNKNOWN_APP) == portnums_pb2.PortNum.TEXT_MESSAGE_APP
7878
):
7979
interface.close() # after running command then exit
8080

@@ -90,7 +90,7 @@ def onReceive(packet, interface) -> None:
9090
interface.sendText(reply)
9191

9292
except Exception as ex:
93-
print(f"Warning: There is no field {ex} in the packet.")
93+
print(f"Warning: Error processing received packet: {ex}.")
9494

9595

9696
def onConnection(interface, topic=pub.AUTO_TOPIC) -> None: # pylint: disable=W0613

meshtastic/tests/test_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ def test_main_onReceive_empty(caplog, capsys):
16081608
assert re.search(r"in onReceive", caplog.text, re.MULTILINE)
16091609
out, err = capsys.readouterr()
16101610
assert re.search(
1611-
r"Warning: There is no field 'to' in the packet.", out, re.MULTILINE
1611+
r"Warning: Error processing received packet: 'to'.", out, re.MULTILINE
16121612
)
16131613
assert err == ""
16141614

0 commit comments

Comments
 (0)