@@ -389,6 +389,40 @@ def sendText(
389
389
channelIndex = channelIndex ,
390
390
)
391
391
392
+
393
+ def sendAlert (
394
+ self ,
395
+ text : str ,
396
+ destinationId : Union [int , str ] = BROADCAST_ADDR ,
397
+ onResponse : Optional [Callable [[dict ], Any ]] = None ,
398
+ channelIndex : int = 0 ,
399
+ ):
400
+ """Send an alert text to some other node. This is similar to a text message,
401
+ but carries a higher priority and is capable of generating special notifications
402
+ on certain clients.
403
+
404
+ Arguments:
405
+ text {string} -- The text of the alert to send
406
+
407
+ Keyword Arguments:
408
+ destinationId {nodeId or nodeNum} -- where to send this
409
+ message (default: {BROADCAST_ADDR})
410
+
411
+ Returns the sent packet. The id field will be populated in this packet
412
+ and can be used to track future message acks/naks.
413
+ """
414
+
415
+ return self .sendData (
416
+ text .encode ("utf-8" ),
417
+ destinationId ,
418
+ portNum = portnums_pb2 .PortNum .ALERT_APP ,
419
+ wantAck = False ,
420
+ wantResponse = False ,
421
+ onResponse = onResponse ,
422
+ channelIndex = channelIndex ,
423
+ priority = mesh_pb2 .MeshPacket .Priority .ALERT
424
+ )
425
+
392
426
def sendData (
393
427
self ,
394
428
data ,
@@ -402,6 +436,7 @@ def sendData(
402
436
hopLimit : Optional [int ]= None ,
403
437
pkiEncrypted : Optional [bool ]= False ,
404
438
publicKey : Optional [bytes ]= None ,
439
+ priority : mesh_pb2 .MeshPacket .Priority .ValueType = mesh_pb2 .MeshPacket .Priority .RELIABLE ,
405
440
): # pylint: disable=R0913
406
441
"""Send a data packet to some other node
407
442
@@ -453,6 +488,8 @@ def sendData(
453
488
meshPacket .decoded .portnum = portNum
454
489
meshPacket .decoded .want_response = wantResponse
455
490
meshPacket .id = self ._generatePacketId ()
491
+ if priority is not None :
492
+ meshPacket .priority = priority
456
493
457
494
if onResponse is not None :
458
495
logging .debug (f"Setting a response handler for requestId { meshPacket .id } " )
0 commit comments