@@ -332,13 +332,14 @@ void SensorMesh::applyContactPermissions(const uint8_t* pubkey, uint16_t perms)
332332 dirty_contacts_expiry = futureMillis (LAZY_CONTACTS_WRITE_DELAY); // trigger saveContacts()
333333}
334334
335- void SensorMesh::sendAlert (const char * text) {
335+ void SensorMesh::sendAlert (AlertPriority pri, const char * text) {
336336 int text_len = strlen (text);
337+ uint16_t pri_mask = (pri == HIGH_PRI_ALERT) ? PERM_RECV_ALERTS_HI : PERM_RECV_ALERTS_LO;
337338
338339 // send text message to all contacts with RECV_ALERT permission
339340 for (int i = 0 ; i < num_contacts; i++) {
340341 auto c = &contacts[i];
341- if ((c->permissions & PERM_RECV_ALERTS ) == 0 ) continue ; // contact does NOT want alerts
342+ if ((c->permissions & pri_mask ) == 0 ) continue ; // contact does NOT want alert
342343
343344 uint8_t data[MAX_PACKET_PAYLOAD];
344345 uint32_t now = getRTCClock ()->getCurrentTimeUnique (); // need different timestamp per packet
@@ -360,12 +361,12 @@ void SensorMesh::sendAlert(const char* text) {
360361 }
361362}
362363
363- void SensorMesh::alertIf (bool condition, Trigger& t, const char * text) {
364+ void SensorMesh::alertIf (bool condition, Trigger& t, AlertPriority pri, const char * text) {
364365 if (condition) {
365366 if (!t.triggered ) {
366367 t.triggered = true ;
367368 t.time = getRTCClock ()->getCurrentTime ();
368- sendAlert (text);
369+ sendAlert (pri, text);
369370 }
370371 } else {
371372 if (t.triggered ) {
@@ -422,7 +423,7 @@ uint8_t SensorMesh::handleLoginReq(const mesh::Identity& sender, const uint8_t*
422423 MESH_DEBUG_PRINTLN (" Login success!" );
423424 client->last_timestamp = sender_timestamp;
424425 client->last_activity = getRTCClock ()->getCurrentTime ();
425- client->permissions = PERM_IS_ADMIN | PERM_RECV_ALERTS;
426+ client->permissions = PERM_IS_ADMIN | PERM_RECV_ALERTS_HI | PERM_RECV_ALERTS_LO; // initially opt-in to receive alerts (can opt out)
426427 memcpy (client->shared_secret , secret, PUB_KEY_SIZE);
427428
428429 dirty_contacts_expiry = futureMillis (LAZY_CONTACTS_WRITE_DELAY);
0 commit comments