Skip to content

Commit 2c76c0c

Browse files
committed
Remove setting hopLimit to default
Instead set is to config of device
1 parent 82977e9 commit 2c76c0c

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

meshtastic/mesh_interface.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ def __init__(self, debugOut=None, noProto=False):
5353
self.currentPacketId = random.randint(0, 0xffffffff)
5454
self.nodesByNum = None
5555
self.configId = None
56-
self.defaultHopLimit = 3
5756
self.gotResponse = False # used in gpio read
5857
self.mask = None # used in gpio read and gpio watch
5958

@@ -176,7 +175,6 @@ def sendText(self, text: AnyStr,
176175
destinationId=BROADCAST_ADDR,
177176
wantAck=False,
178177
wantResponse=False,
179-
hopLimit=None,
180178
onResponse=None,
181179
channelIndex=0):
182180
"""Send a utf8 string to some other node, if the node has a display it
@@ -198,21 +196,17 @@ def sendText(self, text: AnyStr,
198196
Returns the sent packet. The id field will be populated in this packet
199197
and can be used to track future message acks/naks.
200198
"""
201-
if hopLimit is None:
202-
hopLimit = self.defaultHopLimit
203199

204200
return self.sendData(text.encode("utf-8"), destinationId,
205201
portNum=portnums_pb2.PortNum.TEXT_MESSAGE_APP,
206202
wantAck=wantAck,
207203
wantResponse=wantResponse,
208-
hopLimit=hopLimit,
209204
onResponse=onResponse,
210205
channelIndex=channelIndex)
211206

212207
def sendData(self, data, destinationId=BROADCAST_ADDR,
213208
portNum=portnums_pb2.PortNum.PRIVATE_APP, wantAck=False,
214209
wantResponse=False,
215-
hopLimit=None,
216210
onResponse=None,
217211
channelIndex=0):
218212
"""Send a data packet to some other node
@@ -237,8 +231,6 @@ def sendData(self, data, destinationId=BROADCAST_ADDR,
237231
Returns the sent packet. The id field will be populated in this packet
238232
and can be used to track future message acks/naks.
239233
"""
240-
if hopLimit is None:
241-
hopLimit = self.defaultHopLimit
242234

243235
if getattr(data, "SerializeToString", None):
244236
logging.debug(f"Serializing protobuf as data: {stripnl(data)}")
@@ -261,8 +253,7 @@ def sendData(self, data, destinationId=BROADCAST_ADDR,
261253

262254
if onResponse is not None:
263255
self._addResponseHandler(meshPacket.id, onResponse)
264-
p = self._sendPacket(meshPacket, destinationId,
265-
wantAck=wantAck, hopLimit=hopLimit)
256+
p = self._sendPacket(meshPacket, destinationId, wantAck=wantAck)
266257
return p
267258

268259
def sendPosition(self, latitude=0.0, longitude=0.0, altitude=0, timeSec=0,
@@ -306,15 +297,13 @@ def _addResponseHandler(self, requestId, callback):
306297

307298
def _sendPacket(self, meshPacket,
308299
destinationId=BROADCAST_ADDR,
309-
wantAck=False, hopLimit=None):
300+
wantAck=False):
310301
"""Send a MeshPacket to the specified node (or if unspecified, broadcast).
311302
You probably don't want this - use sendData instead.
312303
313304
Returns the sent packet. The id field will be populated in this packet and
314305
can be used to track future message acks/naks.
315306
"""
316-
if hopLimit is None:
317-
hopLimit = self.defaultHopLimit
318307

319308
# We allow users to talk to the local node before we've completed the full connection flow...
320309
if(self.myInfo is not None and destinationId != self.myInfo.my_node_num):
@@ -348,6 +337,8 @@ def _sendPacket(self, meshPacket,
348337

349338
meshPacket.to = nodeNum
350339
meshPacket.want_ack = wantAck
340+
loraConfig = getattr(self.localNode.localConfig, 'lora')
341+
hopLimit = getattr(loraConfig, 'hop_limit')
351342
meshPacket.hop_limit = hopLimit
352343

353344
# if the user hasn't set an ID for this packet (likely and recommended),

0 commit comments

Comments
 (0)