From 2246564279ad41265a2b5e8a51d14036b1bb479a Mon Sep 17 00:00:00 2001 From: Jm Date: Wed, 27 Jan 2021 20:06:39 -0800 Subject: [PATCH] #654 - Small changes. --- src/plugins/ExternalNotificationPlugin.cpp | 38 ++++++++++++++++++++-- src/plugins/ExternalNotificationPlugin.h | 3 ++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/plugins/ExternalNotificationPlugin.cpp b/src/plugins/ExternalNotificationPlugin.cpp index f2cee7cf7..fe5a57aeb 100644 --- a/src/plugins/ExternalNotificationPlugin.cpp +++ b/src/plugins/ExternalNotificationPlugin.cpp @@ -36,7 +36,7 @@ int32_t ExternalNotificationPlugin::runOnce() // radioConfig.preferences.externalnotificationplugin_enabled = 1; // radioConfig.preferences.externalnotificationplugin_mode = 1; - if (0) { + if (1) { if (firstTime) { @@ -46,6 +46,16 @@ int32_t ExternalNotificationPlugin::runOnce() firstTime = 0; + // Set the direction of a pin + pinMode(13, OUTPUT); + + // if ext_notification_plugin_active + if (1) { + setExternalOff(); + } else { + setExternalOn(); + } + } else { /* @@ -66,6 +76,27 @@ int32_t ExternalNotificationPlugin::runOnce() #endif } +void ExternalNotificationPlugin::setExternalOn() +{ + // if ext_notification_plugin_active + if (1) { + digitalWrite(13, true); + + } else { + digitalWrite(13, false); + } +} + +void ExternalNotificationPlugin::setExternalOff() +{ + // if ext_notification_plugin_active + if (1) { + digitalWrite(13, false); + } else { + digitalWrite(13, true); + } +} + // -------- MeshPacket *ExternalNotificationPluginRadio::allocReply() @@ -80,7 +111,7 @@ bool ExternalNotificationPluginRadio::handleReceived(const MeshPacket &mp) { #ifndef NO_ESP32 - if (0) { + if (1) { auto &p = mp.decoded.data; @@ -95,6 +126,9 @@ bool ExternalNotificationPluginRadio::handleReceived(const MeshPacket &mp) TODO: If ext_notification_plugin_alert_message is true, trigger an external notification. */ // TODO: On received packet, blink the LED. + externalNotificationPlugin->setExternalOn(); + delay(500); + externalNotificationPlugin->setExternalOff(); } diff --git a/src/plugins/ExternalNotificationPlugin.h b/src/plugins/ExternalNotificationPlugin.h index b8eeffe40..544748341 100644 --- a/src/plugins/ExternalNotificationPlugin.h +++ b/src/plugins/ExternalNotificationPlugin.h @@ -14,6 +14,9 @@ class ExternalNotificationPlugin : private concurrency::OSThread public: ExternalNotificationPlugin(); + void setExternalOn(); + void setExternalOff(); + protected: virtual int32_t runOnce(); };