@@ -351,6 +351,7 @@ def sendPosition(
351351 destinationId : Union [int , str ]= BROADCAST_ADDR ,
352352 wantAck : bool = False ,
353353 wantResponse : bool = False ,
354+ channelIndex : int = 0 ,
354355 ):
355356 """
356357 Send a position packet to some other node (normally a broadcast)
@@ -393,6 +394,7 @@ def sendPosition(
393394 wantAck = wantAck ,
394395 wantResponse = wantResponse ,
395396 onResponse = onResponse ,
397+ channelIndex = channelIndex ,
396398 )
397399 if wantResponse :
398400 self .waitForPosition ()
@@ -426,7 +428,7 @@ def onResponsePosition(self, p):
426428 if p ["decoded" ]["routing" ]["errorReason" ] == 'NO_RESPONSE' :
427429 our_exit ("No response from node. At least firmware 2.1.22 is required on the destination node." )
428430
429- def sendTraceRoute (self , dest : Union [int , str ], hopLimit : int ):
431+ def sendTraceRoute (self , dest : Union [int , str ], hopLimit : int , channelIndex : int = 0 ):
430432 """Send the trace route"""
431433 r = mesh_pb2 .RouteDiscovery ()
432434 self .sendData (
@@ -435,6 +437,7 @@ def sendTraceRoute(self, dest: Union[int, str], hopLimit: int):
435437 portNum = portnums_pb2 .PortNum .TRACEROUTE_APP ,
436438 wantResponse = True ,
437439 onResponse = self .onResponseTraceRoute ,
440+ channelIndex = channelIndex ,
438441 )
439442 # extend timeout based on number of nodes, limit by configured hopLimit
440443 waitFactor = min (len (self .nodes ) - 1 if self .nodes else 0 , hopLimit )
@@ -456,26 +459,27 @@ def onResponseTraceRoute(self, p):
456459
457460 self ._acknowledgment .receivedTraceRoute = True
458461
459- def sendTelemetry (self , destinationId = BROADCAST_ADDR , wantResponse = False ):
462+ def sendTelemetry (self , destinationId : Union [ int , str ] = BROADCAST_ADDR , wantResponse : bool = False , channelIndex : int = 0 ):
460463 """Send telemetry and optionally ask for a response"""
461464 r = telemetry_pb2 .Telemetry ()
462465
463- node = next (n for n in self .nodes .values () if n ["num" ] == self .localNode .nodeNum )
464- if node is not None :
465- metrics = node .get ("deviceMetrics" )
466- if metrics :
467- batteryLevel = metrics .get ("batteryLevel" )
468- if batteryLevel is not None :
469- r .device_metrics .battery_level = batteryLevel
470- voltage = metrics .get ("voltage" )
471- if voltage is not None :
472- r .device_metrics .voltage = voltage
473- channel_utilization = metrics .get ("channelUtilization" )
474- if channel_utilization is not None :
475- r .device_metrics .channel_utilization = channel_utilization
476- air_util_tx = metrics .get ("airUtilTx" )
477- if air_util_tx is not None :
478- r .device_metrics .air_util_tx = air_util_tx
466+ if self .nodes is not None :
467+ node = next (n for n in self .nodes .values () if n ["num" ] == self .localNode .nodeNum )
468+ if node is not None :
469+ metrics = node .get ("deviceMetrics" )
470+ if metrics :
471+ batteryLevel = metrics .get ("batteryLevel" )
472+ if batteryLevel is not None :
473+ r .device_metrics .battery_level = batteryLevel
474+ voltage = metrics .get ("voltage" )
475+ if voltage is not None :
476+ r .device_metrics .voltage = voltage
477+ channel_utilization = metrics .get ("channelUtilization" )
478+ if channel_utilization is not None :
479+ r .device_metrics .channel_utilization = channel_utilization
480+ air_util_tx = metrics .get ("airUtilTx" )
481+ if air_util_tx is not None :
482+ r .device_metrics .air_util_tx = air_util_tx
479483
480484 if wantResponse :
481485 onResponse = self .onResponseTelemetry
@@ -488,6 +492,7 @@ def sendTelemetry(self, destinationId=BROADCAST_ADDR, wantResponse=False):
488492 portNum = portnums_pb2 .PortNum .TELEMETRY_APP ,
489493 wantResponse = wantResponse ,
490494 onResponse = onResponse ,
495+ channelIndex = channelIndex ,
491496 )
492497 if wantResponse :
493498 self .waitForTelemetry ()
0 commit comments