Add --sendping for reply testing

This commit is contained in:
Kevin Hester
2020-12-13 12:55:18 +08:00
parent 0b1340cce1
commit 11f8c33e88
3 changed files with 26 additions and 8 deletions

View File

@@ -5,7 +5,7 @@ from . import SerialInterface, TCPInterface, BLEInterface, test, remote_hardware
import logging
import sys
from pubsub import pub
from . import mesh_pb2
from . import mesh_pb2, portnums_pb2
import google.protobuf.json_format
import pyqrcode
import traceback
@@ -124,10 +124,10 @@ def setRouter(interface, on):
def onConnected(interface):
"""Callback invoked when we connect to a radio"""
global args
print("Connected to radio")
closeNow = False # Should we drop the connection after we finish?
try:
global args
print("Connected to radio")
prefs = interface.radioConfig.preferences
if args.settime or args.setlat or args.setlon or args.setalt:
@@ -166,6 +166,12 @@ def onConnected(interface):
closeNow = True
print(f"Sending text message {args.sendtext} to {args.destOrAll}")
interface.sendText(args.sendtext, args.destOrAll,
wantAck=True)
if args.sendping:
print(f"Sending ping message {args.sendtext} to {args.destOrAll}")
payload = str.encode("test string")
interface.sendData(payload, args.destOrAll, portNum=portnums_pb2.PortNum.REPLY_APP,
wantAck=True, wantResponse=True)
if args.gpiowrb or args.gpiord:
@@ -308,6 +314,12 @@ def main():
parser.add_argument(
"--sendtext", help="Send a text message")
parser.add_argument(
"--sendping", help="Send a ping message (which requests a reply)", action="store_true")
#parser.add_argument(
# "--repeat", help="Normally the send commands send only one message, use this option to request repeated sends")
parser.add_argument(
"--reply", help="Reply to received messages",
action="store_true")

View File

@@ -20,7 +20,7 @@ DESCRIPTOR = _descriptor.FileDescriptor(
syntax='proto3',
serialized_options=b'\n\023com.geeksville.meshB\010PortnumsH\003',
create_key=_descriptor._internal_create_key,
serialized_pb=b'\n\x0eportnums.proto*\x93\x01\n\x07PortNum\x12\x0f\n\x0bUNKNOWN_APP\x10\x00\x12\x14\n\x10TEXT_MESSAGE_APP\x10\x01\x12\x17\n\x13REMOTE_HARDWARE_APP\x10\x02\x12\x10\n\x0cPOSITION_APP\x10\x03\x12\x10\n\x0cNODEINFO_APP\x10\x04\x12\x10\n\x0bPRIVATE_APP\x10\x80\x02\x12\x12\n\rIP_TUNNEL_APP\x10\x80\x08\x42!\n\x13\x63om.geeksville.meshB\x08PortnumsH\x03\x62\x06proto3'
serialized_pb=b'\n\x0eportnums.proto*\xa2\x01\n\x07PortNum\x12\x0f\n\x0bUNKNOWN_APP\x10\x00\x12\x14\n\x10TEXT_MESSAGE_APP\x10\x01\x12\x17\n\x13REMOTE_HARDWARE_APP\x10\x02\x12\x10\n\x0cPOSITION_APP\x10\x03\x12\x10\n\x0cNODEINFO_APP\x10\x04\x12\r\n\tREPLY_APP\x10 \x12\x10\n\x0bPRIVATE_APP\x10\x80\x02\x12\x12\n\rIP_TUNNEL_APP\x10\x80\x08\x42!\n\x13\x63om.geeksville.meshB\x08PortnumsH\x03\x62\x06proto3'
)
_PORTNUM = _descriptor.EnumDescriptor(
@@ -56,12 +56,17 @@ _PORTNUM = _descriptor.EnumDescriptor(
type=None,
create_key=_descriptor._internal_create_key),
_descriptor.EnumValueDescriptor(
name='PRIVATE_APP', index=5, number=256,
name='REPLY_APP', index=5, number=32,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key),
_descriptor.EnumValueDescriptor(
name='IP_TUNNEL_APP', index=6, number=1024,
name='PRIVATE_APP', index=6, number=256,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key),
_descriptor.EnumValueDescriptor(
name='IP_TUNNEL_APP', index=7, number=1024,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key),
@@ -69,7 +74,7 @@ _PORTNUM = _descriptor.EnumDescriptor(
containing_type=None,
serialized_options=None,
serialized_start=19,
serialized_end=166,
serialized_end=181,
)
_sym_db.RegisterEnumDescriptor(_PORTNUM)
@@ -79,6 +84,7 @@ TEXT_MESSAGE_APP = 1
REMOTE_HARDWARE_APP = 2
POSITION_APP = 3
NODEINFO_APP = 4
REPLY_APP = 32
PRIVATE_APP = 256
IP_TUNNEL_APP = 1024

2
proto

Submodule proto updated: ebd18145ca...8729bad7f6