@@ -371,13 +371,14 @@ def sendText(
371371 def sendData (
372372 self ,
373373 data ,
374- destinationId : Union [int , str ] = BROADCAST_ADDR ,
375- portNum : portnums_pb2 .PortNum .ValueType = portnums_pb2 .PortNum .PRIVATE_APP ,
376- wantAck : bool = False ,
377- wantResponse : bool = False ,
378- onResponse : Optional [Callable [[dict ], Any ]] = None ,
379- onResponseAckPermitted : bool = False ,
380- channelIndex : int = 0 ,
374+ destinationId : Union [int , str ]= BROADCAST_ADDR ,
375+ portNum : portnums_pb2 .PortNum .ValueType = portnums_pb2 .PortNum .PRIVATE_APP ,
376+ wantAck : bool = False ,
377+ wantResponse : bool = False ,
378+ onResponse : Optional [Callable [[dict ], Any ]]= None ,
379+ onResponseAckPermitted : bool = False ,
380+ channelIndex : int = 0 ,
381+ hopLimit : Optional [int ]= None ,
381382 ):
382383 """Send a data packet to some other node
383384
@@ -400,7 +401,8 @@ def sendData(
400401 for regular ACKs (True) or just data responses & NAKs (False)
401402 Note that if the onResponse callback is called 'onAckNak' this
402403 will implicitly be true.
403- channelIndex - channel number to use
404+ channelIndex -- channel number to use
405+ hopLimit -- hop limit to use
404406
405407 Returns the sent packet. The id field will be populated in this packet
406408 and can be used to track future message acks/naks.
@@ -431,10 +433,8 @@ def sendData(
431433
432434 if onResponse is not None :
433435 logging .debug (f"Setting a response handler for requestId { meshPacket .id } " )
434- self ._addResponseHandler (
435- meshPacket .id , onResponse , ackPermitted = onResponseAckPermitted
436- )
437- p = self ._sendPacket (meshPacket , destinationId , wantAck = wantAck )
436+ self ._addResponseHandler (meshPacket .id , onResponse , ackPermitted = onResponseAckPermitted )
437+ p = self ._sendPacket (meshPacket , destinationId , wantAck = wantAck , hopLimit = hopLimit )
438438 return p
439439
440440 def sendPosition (
@@ -539,6 +539,7 @@ def sendTraceRoute(
539539 wantResponse = True ,
540540 onResponse = self .onResponseTraceRoute ,
541541 channelIndex = channelIndex ,
542+ hopLimit = hopLimit ,
542543 )
543544 # extend timeout based on number of nodes, limit by configured hopLimit
544545 waitFactor = min (len (self .nodes ) - 1 if self .nodes else 0 , hopLimit )
@@ -645,8 +646,9 @@ def _addResponseHandler(
645646 def _sendPacket (
646647 self ,
647648 meshPacket : mesh_pb2 .MeshPacket ,
648- destinationId : Union [int , str ] = BROADCAST_ADDR ,
649- wantAck : bool = False ,
649+ destinationId : Union [int ,str ]= BROADCAST_ADDR ,
650+ wantAck : bool = False ,
651+ hopLimit : Optional [int ]= None
650652 ):
651653 """Send a MeshPacket to the specified node (or if unspecified, broadcast).
652654 You probably don't want this - use sendData instead.
@@ -688,9 +690,12 @@ def _sendPacket(
688690
689691 meshPacket .to = nodeNum
690692 meshPacket .want_ack = wantAck
691- loraConfig = getattr (self .localNode .localConfig , "lora" )
692- hopLimit = getattr (loraConfig , "hop_limit" )
693- meshPacket .hop_limit = hopLimit
693+
694+ if hopLimit is not None :
695+ meshPacket .hop_limit = hopLimit
696+ else :
697+ loraConfig = getattr (self .localNode .localConfig , "lora" )
698+ meshPacket .hop_limit = getattr (loraConfig , "hop_limit" )
694699
695700 # if the user hasn't set an ID for this packet (likely and recommended),
696701 # we should pick a new unique ID so the message can be tracked.
0 commit comments