diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 33500830d..23411979b 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -863,6 +863,10 @@ void NodeDB::installDefaultModuleConfig() moduleConfig.external_notification.nag_timeout = default_ringtone_nag_secs; #endif #endif +#if ARCH_PORTDUINO + moduleConfig.external_notification.enabled = true; + moduleConfig.external_notification.alert_message = true; +#endif #ifdef NANO_G2_ULTRA moduleConfig.external_notification.enabled = true; moduleConfig.external_notification.alert_message = true; diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 16ccdd744..5da375074 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -408,6 +408,9 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP if (genericShouldAlert) { LOG_INFO("externalNotificationModule - Generic alert"); setExternalState(0, true); +#if ARCH_PORTDUINO + portduinoNotify(mp); +#endif } if (vibraShouldAlert) { @@ -521,3 +524,26 @@ int ExternalNotificationModule::handleInputEvent(const InputEvent *event) } return 0; } + +#if ARCH_PORTDUINO +void ExternalNotificationModule::portduinoNotify(const meshtastic_MeshPacket &mp) +{ + std::string senderName; + const meshtastic_NodeInfoLite *sender = nodeDB->getMeshNode(mp.from); + if (sender && sender->has_user) { + if (sender->user.long_name[0] != '\0') { + senderName = sender->user.long_name; + } else { + senderName = sender->user.short_name; + } + } else { + senderName = std::to_string(mp.from); + } + std::string notificationSummary = "From: " + senderName; + std::string notificationBody = std::string((char *)mp.decoded.payload.bytes, mp.decoded.payload.size); + std::string command = "notify-send -a Meshtasticd -i org.meshtastic.meshtasticd.png "; + command += "\"" + notificationSummary + "\" \"" + notificationBody + "\""; + LOG_INFO("Executing command: %s", command.c_str()); + exec(command.c_str()); +} +#endif \ No newline at end of file diff --git a/src/modules/ExternalNotificationModule.h b/src/modules/ExternalNotificationModule.h index 94b021360..1d9c207ad 100644 --- a/src/modules/ExternalNotificationModule.h +++ b/src/modules/ExternalNotificationModule.h @@ -77,6 +77,10 @@ class ExternalNotificationModule : public SinglePortModule, private concurrency: virtual AdminMessageHandleResult handleAdminMessageForModule(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *request, meshtastic_AdminMessage *response) override; + +#if ARCH_PORTDUINO + void portduinoNotify(const meshtastic_MeshPacket &mp); +#endif }; extern ExternalNotificationModule *externalNotificationModule; \ No newline at end of file