mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-28 15:22:55 +00:00
Don't mute alerts
This commit is contained in:
parent
5579d87845
commit
e0890b2a13
@ -95,7 +95,7 @@ namespace graphics
|
|||||||
#define NUM_EXTRA_FRAMES 3 // text message and debug frame
|
#define NUM_EXTRA_FRAMES 3 // text message and debug frame
|
||||||
// if defined a pixel will blink to show redraws
|
// if defined a pixel will blink to show redraws
|
||||||
// #define SHOW_REDRAWS
|
// #define SHOW_REDRAWS
|
||||||
|
#define ASCII_BELL '\x07'
|
||||||
// A text message frame + debug frame + all the node infos
|
// A text message frame + debug frame + all the node infos
|
||||||
FrameCallback *normalFrames;
|
FrameCallback *normalFrames;
|
||||||
static uint32_t targetFramerate = IDLE_FRAMERATE;
|
static uint32_t targetFramerate = IDLE_FRAMERATE;
|
||||||
@ -1426,21 +1426,27 @@ int Screen::handleTextMessage(const meshtastic_MeshPacket *packet)
|
|||||||
|
|
||||||
char banner[256];
|
char banner[256];
|
||||||
|
|
||||||
// Check for bell character in message to determine alert type
|
|
||||||
bool isAlert = false;
|
bool isAlert = false;
|
||||||
for (size_t i = 0; i < packet->decoded.payload.size && i < 100; i++) {
|
|
||||||
if (msgRaw[i] == '\x07') {
|
|
||||||
isAlert = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (moduleConfig.external_notification.alert_bell || moduleConfig.external_notification.alert_bell_vibra ||
|
||||||
|
moduleConfig.external_notification.alert_bell_buzzer)
|
||||||
|
// Check for bell character to determine if this message is an alert
|
||||||
|
for (size_t i = 0; i < packet->decoded.payload.size && i < 100; i++) {
|
||||||
|
if (msgRaw[i] == ASCII_BELL) {
|
||||||
|
isAlert = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unlike generic messages, alerts (when enabled via the ext notif module) ignore any
|
||||||
|
// 'mute' preferences set to any specific node or channel.
|
||||||
if (isAlert) {
|
if (isAlert) {
|
||||||
if (longName && longName[0]) {
|
if (longName && longName[0]) {
|
||||||
snprintf(banner, sizeof(banner), "Alert Received from\n%s", longName);
|
snprintf(banner, sizeof(banner), "Alert Received from\n%s", longName);
|
||||||
} else {
|
} else {
|
||||||
strcpy(banner, "Alert Received");
|
strcpy(banner, "Alert Received");
|
||||||
}
|
}
|
||||||
|
screen->showSimpleBanner(banner, 3000);
|
||||||
} else if (!node->is_muted && !channel.settings.mute) {
|
} else if (!node->is_muted && !channel.settings.mute) {
|
||||||
if (longName && longName[0]) {
|
if (longName && longName[0]) {
|
||||||
snprintf(banner, sizeof(banner), "New Message from\n%s", longName);
|
snprintf(banner, sizeof(banner), "New Message from\n%s", longName);
|
||||||
|
|||||||
@ -451,7 +451,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
|
|||||||
// Check if the message contains a bell character. Don't do this loop for every pin, just once.
|
// Check if the message contains a bell character. Don't do this loop for every pin, just once.
|
||||||
auto &p = mp.decoded;
|
auto &p = mp.decoded;
|
||||||
bool containsBell = false;
|
bool containsBell = false;
|
||||||
for (int i = 0; i < p.payload.size; i++) {
|
for (size_t i = 0; i < p.payload.size; i++) {
|
||||||
if (p.payload.bytes[i] == ASCII_BELL) {
|
if (p.payload.bytes[i] == ASCII_BELL) {
|
||||||
containsBell = true;
|
containsBell = true;
|
||||||
}
|
}
|
||||||
@ -460,7 +460,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
|
|||||||
meshtastic_NodeInfoLite *sender = nodeDB->getMeshNode(mp.from);
|
meshtastic_NodeInfoLite *sender = nodeDB->getMeshNode(mp.from);
|
||||||
meshtastic_Channel ch = channels.getByIndex(sender->channel ? sender->channel : channels.getPrimaryIndex());
|
meshtastic_Channel ch = channels.getByIndex(sender->channel ? sender->channel : channels.getPrimaryIndex());
|
||||||
|
|
||||||
if (moduleConfig.external_notification.alert_bell && !sender->is_muted && !ch.settings.mute) {
|
if (moduleConfig.external_notification.alert_bell) {
|
||||||
if (containsBell) {
|
if (containsBell) {
|
||||||
LOG_INFO("externalNotificationModule - Notification Bell");
|
LOG_INFO("externalNotificationModule - Notification Bell");
|
||||||
isNagging = true;
|
isNagging = true;
|
||||||
@ -473,7 +473,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (moduleConfig.external_notification.alert_bell_vibra && !sender->is_muted && !ch.settings.mute) {
|
if (moduleConfig.external_notification.alert_bell_vibra) {
|
||||||
if (containsBell) {
|
if (containsBell) {
|
||||||
LOG_INFO("externalNotificationModule - Notification Bell (Vibra)");
|
LOG_INFO("externalNotificationModule - Notification Bell (Vibra)");
|
||||||
isNagging = true;
|
isNagging = true;
|
||||||
@ -486,7 +486,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (moduleConfig.external_notification.alert_bell_buzzer && canBuzz() && !sender->is_muted && !ch.settings.mute) {
|
if (moduleConfig.external_notification.alert_bell_buzzer && canBuzz()) {
|
||||||
if (containsBell) {
|
if (containsBell) {
|
||||||
LOG_INFO("externalNotificationModule - Notification Bell (Buzzer)");
|
LOG_INFO("externalNotificationModule - Notification Bell (Buzzer)");
|
||||||
isNagging = true;
|
isNagging = true;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user