mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-05 04:10:07 +00:00
109 lines
2.6 KiB
C++
109 lines
2.6 KiB
C++
|
#include "ExternalNotificationPlugin.h"
|
||
|
#include "MeshService.h"
|
||
|
#include "NodeDB.h"
|
||
|
#include "RTC.h"
|
||
|
#include "Router.h"
|
||
|
#include "configuration.h"
|
||
|
#include <Arduino.h>
|
||
|
|
||
|
#include <assert.h>
|
||
|
|
||
|
/*
|
||
|
|
||
|
bool ext_notification_plugin_enabled = 126;
|
||
|
uint32 ext_notification_plugin_output_ms = 127;
|
||
|
uint32 ext_notification_plugin_output = 128;
|
||
|
bool ext_notification_plugin_active = 129;
|
||
|
bool ext_notification_plugin_alert_message = 130;
|
||
|
bool ext_notification_plugin_alert_bell = 131;
|
||
|
|
||
|
*/
|
||
|
|
||
|
ExternalNotificationPlugin *externalNotificationPlugin;
|
||
|
ExternalNotificationPluginRadio *externalNotificationPluginRadio;
|
||
|
|
||
|
ExternalNotificationPlugin::ExternalNotificationPlugin() : concurrency::OSThread("ExternalNotificationPlugin") {}
|
||
|
|
||
|
int32_t ExternalNotificationPlugin::runOnce()
|
||
|
{
|
||
|
#ifndef NO_ESP32
|
||
|
|
||
|
/*
|
||
|
Uncomment the preferences below if you want to use the plugin
|
||
|
without having to configure it from the PythonAPI or WebUI.
|
||
|
*/
|
||
|
|
||
|
// radioConfig.preferences.externalnotificationplugin_enabled = 1;
|
||
|
// radioConfig.preferences.externalnotificationplugin_mode = 1;
|
||
|
|
||
|
if (0) {
|
||
|
|
||
|
if (firstTime) {
|
||
|
|
||
|
DEBUG_MSG("Initializing External Notification Plugin\n");
|
||
|
|
||
|
externalNotificationPluginRadio = new ExternalNotificationPluginRadio();
|
||
|
|
||
|
firstTime = 0;
|
||
|
|
||
|
} else {
|
||
|
/*
|
||
|
|
||
|
1) If GPIO is turned on ...
|
||
|
2) Check the timer. If the timer has elapsed more time than
|
||
|
our set limit, turn the GPIO off.
|
||
|
|
||
|
*/
|
||
|
}
|
||
|
|
||
|
return (25);
|
||
|
} else {
|
||
|
DEBUG_MSG("External Notification Plugin Disabled\n");
|
||
|
|
||
|
return (INT32_MAX);
|
||
|
}
|
||
|
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
// --------
|
||
|
|
||
|
MeshPacket *ExternalNotificationPluginRadio::allocReply()
|
||
|
{
|
||
|
|
||
|
auto reply = allocDataPacket(); // Allocate a packet for sending
|
||
|
|
||
|
return reply;
|
||
|
}
|
||
|
|
||
|
bool ExternalNotificationPluginRadio::handleReceived(const MeshPacket &mp)
|
||
|
{
|
||
|
#ifndef NO_ESP32
|
||
|
|
||
|
if (0) {
|
||
|
|
||
|
auto &p = mp.decoded.data;
|
||
|
|
||
|
if (mp.from != nodeDB.getNodeNum()) {
|
||
|
|
||
|
/*
|
||
|
TODO: If ext_notification_plugin_alert_bell is true and we see a bell character, trigger an external notification.
|
||
|
*/
|
||
|
// TODO: Check p.payload.bytes to see if it contains a bell character. If it does, trigger an external notifcation.
|
||
|
|
||
|
/*
|
||
|
TODO: If ext_notification_plugin_alert_message is true, trigger an external notification.
|
||
|
*/
|
||
|
// TODO: On received packet, blink the LED.
|
||
|
|
||
|
}
|
||
|
|
||
|
} else {
|
||
|
DEBUG_MSG("External Notification Plugin Disabled\n");
|
||
|
}
|
||
|
|
||
|
#endif
|
||
|
|
||
|
return true; // Let others look at this message also if they want
|
||
|
}
|