More renaming plugin to module

This commit is contained in:
Jm Casler
2022-02-27 01:49:24 -08:00
parent 7a5ae40289
commit 3c5e49d8f4
14 changed files with 91 additions and 92 deletions

View File

@@ -83,7 +83,7 @@ int CannedMessageModule::splitConfiguredMessages()
messageIndex-1, this->messages[messageIndex-1]);
// hit our max messages, bail
if (messageIndex >= CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_COUNT)
if (messageIndex >= CANNED_MESSAGE_MODULE_MESSAGE_MAX_COUNT)
{
this->messagesCount = messageIndex;
return this->messagesCount;

View File

@@ -14,11 +14,11 @@ enum cannedMessageModuleRunState
};
#define CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_COUNT 50
#define CANNED_MESSAGE_MODULE_MESSAGE_MAX_COUNT 50
/**
* Sum of CannedMessageModuleConfig part sizes.
*/
#define CANNED_MESSAGE_PLUGIN_MESSAGES_SIZE 800
#define CANNED_MESSAGE_MODULE_MESSAGES_SIZE 800
class CannedMessageModule :
public SinglePortPlugin,
@@ -77,8 +77,8 @@ class CannedMessageModule :
int currentMessageIndex = -1;
cannedMessageModuleRunState runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
char messageStore[CANNED_MESSAGE_PLUGIN_MESSAGES_SIZE+1];
char *messages[CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_COUNT];
char messageStore[CANNED_MESSAGE_MODULE_MESSAGES_SIZE+1];
char *messages[CANNED_MESSAGE_MODULE_MESSAGE_MAX_COUNT];
int messagesCount = 0;
unsigned long lastTouchMillis = 0;
};

View File

@@ -44,15 +44,15 @@
*/
// Default configurations
#define EXT_NOTIFICATION_PLUGIN_OUTPUT EXT_NOTIFY_OUT
#define EXT_NOTIFICATION_PLUGIN_OUTPUT_MS 1000
#define EXT_NOTIFICATION_MODULE_OUTPUT EXT_NOTIFY_OUT
#define EXT_NOTIFICATION_MODULE_OUTPUT_MS 1000
#define ASCII_BELL 0x07
bool externalCurrentState = 0;
uint32_t externalTurnedOn = 0;
int32_t ExternalNotificationPlugin::runOnce()
int32_t ExternalNotificationModule::runOnce()
{
/*
Uncomment the preferences below if you want to use the module
@@ -72,7 +72,7 @@ int32_t ExternalNotificationPlugin::runOnce()
// If the output is turned on, turn it back off after the given period of time.
if (externalTurnedOn + (radioConfig.preferences.ext_notification_module_output_ms
? radioConfig.preferences.ext_notification_module_output_ms
: EXT_NOTIFICATION_PLUGIN_OUTPUT_MS) <
: EXT_NOTIFICATION_MODULE_OUTPUT_MS) <
millis()) {
DEBUG_MSG("Turning off external notification\n");
setExternalOff();
@@ -82,34 +82,34 @@ int32_t ExternalNotificationPlugin::runOnce()
return (25);
}
void ExternalNotificationPlugin::setExternalOn()
void ExternalNotificationModule::setExternalOn()
{
#ifdef EXT_NOTIFY_OUT
externalCurrentState = 1;
externalTurnedOn = millis();
digitalWrite((radioConfig.preferences.ext_notification_module_output ? radioConfig.preferences.ext_notification_module_output
: EXT_NOTIFICATION_PLUGIN_OUTPUT),
: EXT_NOTIFICATION_MODULE_OUTPUT),
(radioConfig.preferences.ext_notification_module_active ? true : false));
#endif
}
void ExternalNotificationPlugin::setExternalOff()
void ExternalNotificationModule::setExternalOff()
{
#ifdef EXT_NOTIFY_OUT
externalCurrentState = 0;
digitalWrite((radioConfig.preferences.ext_notification_module_output ? radioConfig.preferences.ext_notification_module_output
: EXT_NOTIFICATION_PLUGIN_OUTPUT),
: EXT_NOTIFICATION_MODULE_OUTPUT),
(radioConfig.preferences.ext_notification_module_active ? false : true));
#endif
}
// --------
ExternalNotificationPlugin::ExternalNotificationPlugin()
: SinglePortPlugin("ExternalNotificationPlugin", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread(
"ExternalNotificationPlugin")
ExternalNotificationModule::ExternalNotificationModule()
: SinglePortPlugin("ExternalNotificationModule", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread(
"ExternalNotificationModule")
{
// restrict to the admin channel for rx
boundChannel = Channels::gpioChannel;
@@ -118,7 +118,7 @@ ExternalNotificationPlugin::ExternalNotificationPlugin()
#ifdef EXT_NOTIFY_OUT
/*
Uncomment the preferences below if you want to use the plugin
Uncomment the preferences below if you want to use the module
without having to configure it from the PythonAPI or WebUI.
*/
@@ -132,24 +132,24 @@ ExternalNotificationPlugin::ExternalNotificationPlugin()
if (radioConfig.preferences.ext_notification_module_enabled) {
DEBUG_MSG("Initializing External Notification Plugin\n");
DEBUG_MSG("Initializing External Notification Module\n");
// Set the direction of a pin
pinMode((radioConfig.preferences.ext_notification_module_output ? radioConfig.preferences.ext_notification_module_output
: EXT_NOTIFICATION_PLUGIN_OUTPUT),
: EXT_NOTIFICATION_MODULE_OUTPUT),
OUTPUT);
// Turn off the pin
setExternalOff();
} else {
DEBUG_MSG("External Notification Plugin Disabled\n");
DEBUG_MSG("External Notification Module Disabled\n");
enabled = false;
}
#endif
#endif
}
ProcessMessage ExternalNotificationPlugin::handleReceived(const MeshPacket &mp)
ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp)
{
#ifndef NO_ESP32
#ifdef EXT_NOTIFY_OUT
@@ -162,7 +162,7 @@ ProcessMessage ExternalNotificationPlugin::handleReceived(const MeshPacket &mp)
// Need to know if and how this could be a problem.
if (radioConfig.preferences.ext_notification_module_alert_bell) {
auto &p = mp.decoded;
DEBUG_MSG("externalNotificationPlugin - Notification Bell\n");
DEBUG_MSG("externalNotificationModule - Notification Bell\n");
for (int i = 0; i < p.payload.size; i++) {
if (p.payload.bytes[i] == ASCII_BELL) {
setExternalOn();
@@ -171,13 +171,13 @@ ProcessMessage ExternalNotificationPlugin::handleReceived(const MeshPacket &mp)
}
if (radioConfig.preferences.ext_notification_module_alert_message) {
DEBUG_MSG("externalNotificationPlugin - Notification Plugin\n");
DEBUG_MSG("externalNotificationModule - Notification Module\n");
setExternalOn();
}
}
} else {
DEBUG_MSG("External Notification Plugin Disabled\n");
DEBUG_MSG("External Notification Module Disabled\n");
}
#endif

View File

@@ -7,13 +7,13 @@
#include <functional>
/*
* Radio interface for ExternalNotificationPlugin
* Radio interface for ExternalNotificationModule
*
*/
class ExternalNotificationPlugin : public SinglePortPlugin, private concurrency::OSThread
class ExternalNotificationModule : public SinglePortPlugin, private concurrency::OSThread
{
public:
ExternalNotificationPlugin();
ExternalNotificationModule();
void setExternalOn();
void setExternalOff();

View File

@@ -22,7 +22,7 @@
/**
* Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else)
*/
void setupPlugins()
void setupModules()
{
inputBroker = new InputBroker();
adminPlugin = new AdminPlugin();
@@ -48,12 +48,11 @@ void setupPlugins()
Maintained by MC Hamster (Jm Casler) jm@casler.org
*/
new SerialPlugin();
new ExternalNotificationPlugin();
new ExternalNotificationModule();
// rangeTestPlugin = new RangeTestPlugin();
storeForwardPlugin = new StoreForwardPlugin();
new RangeTestPlugin();
new RangeTestModule();
// new StoreForwardPlugin();
#endif

View File

@@ -3,4 +3,4 @@
/**
* Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else)
*/
void setupPlugins();
void setupModules();

View File

@@ -16,10 +16,10 @@
As a receiver, I can receive packets from multiple senders. These packets can be saved to the Filesystem.
*/
RangeTestPlugin *rangeTestPlugin;
RangeTestPluginRadio *rangeTestPluginRadio;
RangeTestModule *rangeTestModule;
RangeTestModuleRadio *rangeTestModuleRadio;
RangeTestPlugin::RangeTestPlugin() : concurrency::OSThread("RangeTestPlugin") {}
RangeTestModule::RangeTestModule() : concurrency::OSThread("RangeTestModule") {}
uint32_t packetSequence = 0;
@@ -27,7 +27,7 @@ uint32_t packetSequence = 0;
#define SEC_PER_HOUR 3600
#define SEC_PER_MIN 60
int32_t RangeTestPlugin::runOnce()
int32_t RangeTestModule::runOnce()
{
#ifndef NO_ESP32
@@ -48,7 +48,7 @@ int32_t RangeTestPlugin::runOnce()
if (radioConfig.preferences.range_test_module_enabled) {
if (firstTime) {
rangeTestPluginRadio = new RangeTestPluginRadio();
rangeTestModuleRadio = new RangeTestModuleRadio();
firstTime = 0;
@@ -75,7 +75,7 @@ int32_t RangeTestPlugin::runOnce()
// Only send packets if the channel is less than 25% utilized.
if (airTime->channelUtilizationPercent() < 25) {
rangeTestPluginRadio->sendPayload();
rangeTestModuleRadio->sendPayload();
} else {
DEBUG_MSG("rangeTest - Channel utilization is >25 percent. Skipping this opportunity to send.\n");
}
@@ -97,7 +97,7 @@ int32_t RangeTestPlugin::runOnce()
return (INT32_MAX);
}
MeshPacket *RangeTestPluginRadio::allocReply()
MeshPacket *RangeTestModuleRadio::allocReply()
{
auto reply = allocDataPacket(); // Allocate a packet for sending
@@ -105,7 +105,7 @@ MeshPacket *RangeTestPluginRadio::allocReply()
return reply;
}
void RangeTestPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
void RangeTestModuleRadio::sendPayload(NodeNum dest, bool wantReplies)
{
MeshPacket *p = allocReply();
p->to = dest;
@@ -127,7 +127,7 @@ void RangeTestPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
powerFSM.trigger(EVENT_CONTACT_FROM_PHONE);
}
ProcessMessage RangeTestPluginRadio::handleReceived(const MeshPacket &mp)
ProcessMessage RangeTestModuleRadio::handleReceived(const MeshPacket &mp)
{
#ifndef NO_ESP32
@@ -183,7 +183,7 @@ ProcessMessage RangeTestPluginRadio::handleReceived(const MeshPacket &mp)
return ProcessMessage::CONTINUE; // Let others look at this message also if they want
}
bool RangeTestPluginRadio::appendFile(const MeshPacket &mp)
bool RangeTestModuleRadio::appendFile(const MeshPacket &mp)
{
auto &p = mp.decoded;

View File

@@ -6,29 +6,29 @@
#include <Arduino.h>
#include <functional>
class RangeTestPlugin : private concurrency::OSThread
class RangeTestModule : private concurrency::OSThread
{
bool firstTime = 1;
public:
RangeTestPlugin();
RangeTestModule();
protected:
virtual int32_t runOnce() override;
};
extern RangeTestPlugin *rangeTestPlugin;
extern RangeTestModule *rangeTestModule;
/*
* Radio interface for RangeTestPlugin
* Radio interface for RangeTestModule
*
*/
class RangeTestPluginRadio : public SinglePortPlugin
class RangeTestModuleRadio : public SinglePortPlugin
{
uint32_t lastRxID = 0;
public:
RangeTestPluginRadio() : SinglePortPlugin("RangeTestPluginRadio", PortNum_TEXT_MESSAGE_APP) {}
RangeTestModuleRadio() : SinglePortPlugin("RangeTestModuleRadio", PortNum_TEXT_MESSAGE_APP) {}
/**
* Send our payload into the mesh
@@ -55,4 +55,4 @@ class RangeTestPluginRadio : public SinglePortPlugin
virtual ProcessMessage handleReceived(const MeshPacket &mp) override;
};
extern RangeTestPluginRadio *rangeTestPluginRadio;
extern RangeTestModuleRadio *rangeTestModuleRadio;

View File

@@ -48,11 +48,11 @@
#define RXD2 16
#define TXD2 17
#define SERIALPLUGIN_RX_BUFFER 128
#define SERIALPLUGIN_STRING_MAX Constants_DATA_PAYLOAD_LEN
#define SERIALPLUGIN_TIMEOUT 250
#define SERIALPLUGIN_BAUD 38400
#define SERIALPLUGIN_ACK 1
#define SERIALMODULE_RX_BUFFER 128
#define SERIALMODULE_STRING_MAX Constants_DATA_PAYLOAD_LEN
#define SERIALMODULE_TIMEOUT 250
#define SERIALMODULE_BAUD 38400
#define SERIALMODULE_ACK 1
SerialPlugin *serialPlugin;
SerialPluginRadio *serialPluginRadio;
@@ -90,11 +90,11 @@ int32_t SerialPlugin::runOnce()
DEBUG_MSG("Initializing serial peripheral interface\n");
if (radioConfig.preferences.serialmodule_rxd && radioConfig.preferences.serialmodule_txd) {
Serial2.begin(SERIALPLUGIN_BAUD, SERIAL_8N1, radioConfig.preferences.serialmodule_rxd,
Serial2.begin(SERIALMODULE_BAUD, SERIAL_8N1, radioConfig.preferences.serialmodule_rxd,
radioConfig.preferences.serialmodule_txd);
} else {
Serial2.begin(SERIALPLUGIN_BAUD, SERIAL_8N1, RXD2, TXD2);
Serial2.begin(SERIALMODULE_BAUD, SERIAL_8N1, RXD2, TXD2);
}
if (radioConfig.preferences.serialmodule_timeout) {
@@ -102,10 +102,10 @@ int32_t SerialPlugin::runOnce()
radioConfig.preferences.serialmodule_timeout); // Number of MS to wait to set the timeout for the string.
} else {
Serial2.setTimeout(SERIALPLUGIN_TIMEOUT); // Number of MS to wait to set the timeout for the string.
Serial2.setTimeout(SERIALMODULE_TIMEOUT); // Number of MS to wait to set the timeout for the string.
}
Serial2.setRxBufferSize(SERIALPLUGIN_RX_BUFFER);
Serial2.setRxBufferSize(SERIALMODULE_RX_BUFFER);
serialPluginRadio = new SerialPluginRadio();
@@ -149,7 +149,7 @@ void SerialPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
p->to = dest;
p->decoded.want_response = wantReplies;
p->want_ack = SERIALPLUGIN_ACK;
p->want_ack = SERIALMODULE_ACK;
p->decoded.payload.size = strlen(serialStringChar); // You must specify how many bytes are in the reply
memcpy(p->decoded.payload.bytes, serialStringChar, p->decoded.payload.size);