Skip to content

Commit 2494bb4

Browse files
authored
Merge pull request #828 from NekoCWD/nekocwd/hop-limits
FR: Add Hop Limits to send functions
2 parents 1e4822f + c7ee644 commit 2494bb4

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

meshtastic/mesh_interface.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ def sendText(
419419
channelIndex: int = 0,
420420
portNum: portnums_pb2.PortNum.ValueType = portnums_pb2.PortNum.TEXT_MESSAGE_APP,
421421
replyId: Optional[int]=None,
422+
hopLimit: Optional[int]=None,
422423
):
423424
"""Send a utf8 string to some other node, if the node has a display it
424425
will also be shown on the device.
@@ -436,6 +437,7 @@ def sendText(
436437
portNum -- the application portnum (similar to IP port numbers)
437438
of the destination, see portnums.proto for a list
438439
replyId -- the ID of the message that this packet is a response to
440+
hopLimit {int} -- hop limit to use
439441
440442
Returns the sent packet. The id field will be populated in this packet
441443
and can be used to track future message acks/naks.
@@ -449,7 +451,8 @@ def sendText(
449451
wantResponse=wantResponse,
450452
onResponse=onResponse,
451453
channelIndex=channelIndex,
452-
replyId=replyId
454+
replyId=replyId,
455+
hopLimit=hopLimit,
453456
)
454457

455458

@@ -459,6 +462,7 @@ def sendAlert(
459462
destinationId: Union[int, str] = BROADCAST_ADDR,
460463
onResponse: Optional[Callable[[dict], Any]] = None,
461464
channelIndex: int = 0,
465+
hopLimit: Optional[int]=None,
462466
):
463467
"""Send an alert text to some other node. This is similar to a text message,
464468
but carries a higher priority and is capable of generating special notifications
@@ -470,6 +474,7 @@ def sendAlert(
470474
Keyword Arguments:
471475
destinationId {nodeId or nodeNum} -- where to send this
472476
message (default: {BROADCAST_ADDR})
477+
hopLimit {int} -- hop limit to use
473478
474479
Returns the sent packet. The id field will be populated in this packet
475480
and can be used to track future message acks/naks.
@@ -483,7 +488,8 @@ def sendAlert(
483488
wantResponse=False,
484489
onResponse=onResponse,
485490
channelIndex=channelIndex,
486-
priority=mesh_pb2.MeshPacket.Priority.ALERT
491+
priority=mesh_pb2.MeshPacket.Priority.ALERT,
492+
hopLimit=hopLimit,
487493
)
488494

489495
def sendMqttClientProxyMessage(self, topic: str, data: bytes):
@@ -585,6 +591,7 @@ def sendPosition(
585591
wantAck: bool = False,
586592
wantResponse: bool = False,
587593
channelIndex: int = 0,
594+
hopLimit: Optional[int]=None,
588595
):
589596
"""
590597
Send a position packet to some other node (normally a broadcast)
@@ -621,6 +628,7 @@ def sendPosition(
621628
wantResponse=wantResponse,
622629
onResponse=onResponse,
623630
channelIndex=channelIndex,
631+
hopLimit=hopLimit,
624632
)
625633
if wantResponse:
626634
self.waitForPosition()
@@ -727,7 +735,8 @@ def sendTelemetry(
727735
destinationId: Union[int, str] = BROADCAST_ADDR,
728736
wantResponse: bool = False,
729737
channelIndex: int = 0,
730-
telemetryType: str = "device_metrics"
738+
telemetryType: str = "device_metrics",
739+
hopLimit: Optional[int]=None,
731740
):
732741
"""Send telemetry and optionally ask for a response"""
733742
r = telemetry_pb2.Telemetry()
@@ -774,6 +783,7 @@ def sendTelemetry(
774783
wantResponse=wantResponse,
775784
onResponse=onResponse,
776785
channelIndex=channelIndex,
786+
hopLimit=hopLimit,
777787
)
778788
if wantResponse:
779789
self.waitForTelemetry()
@@ -843,6 +853,7 @@ def sendWaypoint(
843853
wantAck: bool = True,
844854
wantResponse: bool = False,
845855
channelIndex: int = 0,
856+
hopLimit: Optional[int]=None,
846857
): # pylint: disable=R0913
847858
"""
848859
Send a waypoint packet to some other node (normally a broadcast)
@@ -883,6 +894,7 @@ def sendWaypoint(
883894
wantResponse=wantResponse,
884895
onResponse=onResponse,
885896
channelIndex=channelIndex,
897+
hopLimit=hopLimit,
886898
)
887899
if wantResponse:
888900
self.waitForWaypoint()
@@ -895,6 +907,7 @@ def deleteWaypoint(
895907
wantAck: bool = True,
896908
wantResponse: bool = False,
897909
channelIndex: int = 0,
910+
hopLimit: Optional[int]=None,
898911
):
899912
"""
900913
Send a waypoint deletion packet to some other node (normally a broadcast)
@@ -921,6 +934,7 @@ def deleteWaypoint(
921934
wantResponse=wantResponse,
922935
onResponse=onResponse,
923936
channelIndex=channelIndex,
937+
hopLimit=hopLimit,
924938
)
925939
if wantResponse:
926940
self.waitForWaypoint()

0 commit comments

Comments
 (0)