@@ -389,6 +389,40 @@ def sendText(
389389 channelIndex = channelIndex ,
390390 )
391391
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+
392426 def sendData (
393427 self ,
394428 data ,
@@ -402,6 +436,7 @@ def sendData(
402436 hopLimit : Optional [int ]= None ,
403437 pkiEncrypted : Optional [bool ]= False ,
404438 publicKey : Optional [bytes ]= None ,
439+ priority : mesh_pb2 .MeshPacket .Priority .ValueType = mesh_pb2 .MeshPacket .Priority .RELIABLE ,
405440 ): # pylint: disable=R0913
406441 """Send a data packet to some other node
407442
@@ -453,6 +488,8 @@ def sendData(
453488 meshPacket .decoded .portnum = portNum
454489 meshPacket .decoded .want_response = wantResponse
455490 meshPacket .id = self ._generatePacketId ()
491+ if priority is not None :
492+ meshPacket .priority = priority
456493
457494 if onResponse is not None :
458495 logging .debug (f"Setting a response handler for requestId { meshPacket .id } " )
0 commit comments