Skip to content

Commit

Permalink
Tweak error messaging in the onReceive function for sendtext packets
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmcorvidae committed Dec 27, 2024
1 parent b8178d5 commit 6bab385
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions meshtastic/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def onReceive(packet, interface) -> None:
args
and args.sendtext
and packet["to"] == interface.myInfo.my_node_num
and d["portnum"] == portnums_pb2.PortNum.TEXT_MESSAGE_APP
and d.get("portnum", portnums_pb2.PortNum.UNKNOWN_APP) == portnums_pb2.PortNum.TEXT_MESSAGE_APP
):
interface.close() # after running command then exit

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

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


def onConnection(interface, topic=pub.AUTO_TOPIC) -> None: # pylint: disable=W0613
Expand Down
2 changes: 1 addition & 1 deletion meshtastic/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ def test_main_onReceive_empty(caplog, capsys):
assert re.search(r"in onReceive", caplog.text, re.MULTILINE)
out, err = capsys.readouterr()
assert re.search(
r"Warning: There is no field 'to' in the packet.", out, re.MULTILINE
r"Warning: Error processing received packet: 'to'.", out, re.MULTILINE
)
assert err == ""

Expand Down

0 comments on commit 6bab385

Please sign in to comment.