Skip to content

Commit 5ce821c

Browse files
ford-jonesXaositekCopilotjp-bennett
authored
Mute specific nodes (#9209)
* Regen protobufs * Ensure mute state is set when node is ignored * Added mechanism for toggling muted state * Implement the ability to mute specific nodes * Switch boolean value for bitmask * Correctly toggle bitfield position 2 on-change to mute state * Dont push submodule refs * Log correct info * Trunk fmt * Update protobuf ref to master branch of base * Update src/modules/ExternalNotificationModule.cpp Co-authored-by: Copilot <[email protected]> * Re-sync generated files --------- Co-authored-by: Jason P <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Jonathan Bennett <[email protected]>
1 parent b6b1296 commit 5ce821c

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

src/mesh/NodeDB.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ extern meshtastic_CriticalErrorCode error_code;
378378
extern uint32_t error_address;
379379
#define NODEINFO_BITFIELD_IS_KEY_MANUALLY_VERIFIED_SHIFT 0
380380
#define NODEINFO_BITFIELD_IS_KEY_MANUALLY_VERIFIED_MASK (1 << NODEINFO_BITFIELD_IS_KEY_MANUALLY_VERIFIED_SHIFT)
381+
#define NODEINFO_BITFIELD_IS_MUTED_SHIFT 1
382+
#define NODEINFO_BITFIELD_IS_MUTED_MASK (1 << NODEINFO_BITFIELD_IS_MUTED_SHIFT)
381383

382384
#define Module_Config_size \
383385
(ModuleConfig_CannedMessageConfig_size + ModuleConfig_ExternalNotificationConfig_size + ModuleConfig_MQTTConfig_size + \

src/mesh/TypeConversions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ meshtastic_NodeInfo TypeConversions::ConvertToNodeInfo(const meshtastic_NodeInfo
1414
info.is_favorite = lite->is_favorite;
1515
info.is_ignored = lite->is_ignored;
1616
info.is_key_manually_verified = lite->bitfield & NODEINFO_BITFIELD_IS_KEY_MANUALLY_VERIFIED_MASK;
17+
info.is_muted = lite->bitfield & NODEINFO_BITFIELD_IS_MUTED_MASK;
1718

1819
if (lite->has_hops_away) {
1920
info.has_hops_away = true;

src/modules/AdminModule.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,16 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
383383
}
384384
break;
385385
}
386+
case meshtastic_AdminMessage_toggle_muted_node_tag: {
387+
LOG_INFO("Client received toggle_muted_node command");
388+
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(r->toggle_muted_node);
389+
if (node != NULL) {
390+
node->bitfield ^= (1 << NODEINFO_BITFIELD_IS_MUTED_SHIFT);
391+
saveChanges(SEGMENT_NODEDATABASE, false);
392+
}
393+
break;
394+
}
395+
386396
case meshtastic_AdminMessage_set_fixed_position_tag: {
387397
LOG_INFO("Client received set_fixed_position command");
388398
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeDB->getNodeNum());

src/modules/ExternalNotificationModule.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,13 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
459459
}
460460
}
461461

462+
meshtastic_NodeInfoLite *sender = nodeDB->getMeshNode(mp.from);
463+
bool mutedNode = false;
464+
if (sender) {
465+
mutedNode = (sender->bitfield & NODEINFO_BITFIELD_IS_MUTED_MASK);
466+
}
462467
meshtastic_Channel ch = channels.getByIndex(mp.channel ? mp.channel : channels.getPrimaryIndex());
468+
463469
if (moduleConfig.external_notification.alert_bell) {
464470
if (containsBell) {
465471
LOG_INFO("externalNotificationModule - Notification Bell");
@@ -510,7 +516,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
510516
}
511517
}
512518

513-
if (moduleConfig.external_notification.alert_message &&
519+
if (moduleConfig.external_notification.alert_message && !mutedNode &&
514520
(!ch.settings.has_module_settings || !ch.settings.module_settings.is_muted)) {
515521
LOG_INFO("externalNotificationModule - Notification Module");
516522
isNagging = true;
@@ -522,7 +528,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
522528
}
523529
}
524530

525-
if (moduleConfig.external_notification.alert_message_vibra &&
531+
if (moduleConfig.external_notification.alert_message_vibra && !mutedNode &&
526532
(!ch.settings.has_module_settings || !ch.settings.module_settings.is_muted)) {
527533
LOG_INFO("externalNotificationModule - Notification Module (Vibra)");
528534
isNagging = true;
@@ -534,7 +540,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
534540
}
535541
}
536542

537-
if (moduleConfig.external_notification.alert_message_buzzer &&
543+
if (moduleConfig.external_notification.alert_message_buzzer && !mutedNode &&
538544
(!ch.settings.has_module_settings || !ch.settings.module_settings.is_muted)) {
539545
LOG_INFO("externalNotificationModule - Notification Module (Buzzer)");
540546
if (config.device.buzzer_mode != meshtastic_Config_DeviceConfig_BuzzerMode_DIRECT_MSG_ONLY ||

0 commit comments

Comments
 (0)