From 4597ea18983bfeb89f0738645b401c156746c44f Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Mon, 20 Dec 2021 14:00:56 -0800 Subject: [PATCH] add channel index to send text --- meshtastic/__main__.py | 7 +++++-- meshtastic/tests/test_main.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index 10f4799..6345065 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -240,11 +240,14 @@ def onConnected(interface): if args.sendtext: closeNow = True + channelIndex = 0 + if args.ch_index is not None: + channelIndex = int(args.ch_index) print(f"Sending text message {args.sendtext} to {args.destOrAll}") - interface.sendText(args.sendtext, args.destOrAll, wantAck=True) + interface.sendText(args.sendtext, args.destOrAll, wantAck=True, channelIndex=channelIndex) if args.sendping: - print(f"Sending ping message {args.sendtext} to {args.destOrAll}") + print(f"Sending ping message {args.sendping} to {args.destOrAll}") payload = str.encode("test string") interface.sendData(payload, args.destOrAll, portNum=portnums_pb2.PortNum.REPLY_APP, wantAck=True, wantResponse=True) diff --git a/meshtastic/tests/test_main.py b/meshtastic/tests/test_main.py index edb5848..f8a6734 100644 --- a/meshtastic/tests/test_main.py +++ b/meshtastic/tests/test_main.py @@ -404,7 +404,7 @@ def test_main_sendtext(capsys, reset_globals): Globals.getInstance().set_args(sys.argv) iface = MagicMock(autospec=SerialInterface) - def mock_sendText(text, dest, wantAck): + def mock_sendText(text, dest, wantAck, channelIndex): print('inside mocked sendText') iface.sendText.side_effect = mock_sendText @@ -425,7 +425,7 @@ def test_main_sendtext_with_dest(capsys, reset_globals): Globals.getInstance().set_args(sys.argv) iface = MagicMock(autospec=SerialInterface) - def mock_sendText(text, dest, wantAck): + def mock_sendText(text, dest, wantAck, channelIndex): print('inside mocked sendText') iface.sendText.side_effect = mock_sendText