mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-28 18:47:40 +00:00
Merge pull request #1254 from mc-hamster/router
More renaming plugin to module
This commit is contained in:
commit
6f086bd3ba
@ -71,7 +71,7 @@ You probably don't care about this section - skip to the next one.
|
|||||||
* nrf52 should preserve local time across reset
|
* nrf52 should preserve local time across reset
|
||||||
* cdcacm bug on nrf52: emittx thinks it emitted but client sees nothing. works again later
|
* cdcacm bug on nrf52: emittx thinks it emitted but client sees nothing. works again later
|
||||||
* nrf52: segger logs have errors in formatting that should be impossible (because not going through serial, try stalling on segger)
|
* nrf52: segger logs have errors in formatting that should be impossible (because not going through serial, try stalling on segger)
|
||||||
* DONE call RouterPlugin for *all* packets - not just Router packets
|
* DONE call RouterModule for *all* packets - not just Router packets
|
||||||
* DONE generate channel hash from the name of the channel+the psk (not just one or the other)
|
* DONE generate channel hash from the name of the channel+the psk (not just one or the other)
|
||||||
* DONE send a hint that can be used to select which channel to try and hash against with each message
|
* DONE send a hint that can be used to select which channel to try and hash against with each message
|
||||||
* DONE remove deprecated
|
* DONE remove deprecated
|
||||||
@ -188,7 +188,7 @@ For app cleanup:
|
|||||||
* DONE test python side handle new position/user messages
|
* DONE test python side handle new position/user messages
|
||||||
* DONE make a gpio example. --gpiowrb 4 1, --gpiord 0x444, --gpiowatch 0x3ff
|
* DONE make a gpio example. --gpiowrb 4 1, --gpiord 0x444, --gpiowatch 0x3ff
|
||||||
* DONE fix position sending to use new module
|
* DONE fix position sending to use new module
|
||||||
* DONE Add SinglePortNumPlugin - as the new most useful baseclass
|
* DONE Add SinglePortNumModule - as the new most useful baseclass
|
||||||
* DONE move positions into regular data packets (use new app framework)
|
* DONE move positions into regular data packets (use new app framework)
|
||||||
* DONE move user info into regular data packets (use new app framework)
|
* DONE move user info into regular data packets (use new app framework)
|
||||||
* DONE test that positions, text messages and user info still work
|
* DONE test that positions, text messages and user info still work
|
||||||
|
@ -178,7 +178,7 @@ static void drawSleepScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int
|
|||||||
|
|
||||||
static void drawPluginFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
static void drawPluginFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
{
|
{
|
||||||
uint8_t plugin_frame;
|
uint8_t module_frame;
|
||||||
// there's a little but in the UI transition code
|
// there's a little but in the UI transition code
|
||||||
// where it invokes the function at the correct offset
|
// where it invokes the function at the correct offset
|
||||||
// in the array of "drawScreen" functions; however,
|
// in the array of "drawScreen" functions; however,
|
||||||
@ -187,14 +187,14 @@ static void drawPluginFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int
|
|||||||
if (state->frameState == IN_TRANSITION && state->transitionFrameRelationship == INCOMING) {
|
if (state->frameState == IN_TRANSITION && state->transitionFrameRelationship == INCOMING) {
|
||||||
// if we're transitioning from the end of the frame list back around to the first
|
// if we're transitioning from the end of the frame list back around to the first
|
||||||
// frame, then we want this to be `0`
|
// frame, then we want this to be `0`
|
||||||
plugin_frame = state->transitionFrameTarget;
|
module_frame = state->transitionFrameTarget;
|
||||||
} else {
|
} else {
|
||||||
// otherwise, just display the module frame that's aligned with the current frame
|
// otherwise, just display the module frame that's aligned with the current frame
|
||||||
plugin_frame = state->currentFrame;
|
module_frame = state->currentFrame;
|
||||||
// DEBUG_MSG("Screen is not in transition. Frame: %d\n\n", plugin_frame);
|
// DEBUG_MSG("Screen is not in transition. Frame: %d\n\n", module_frame);
|
||||||
}
|
}
|
||||||
// DEBUG_MSG("Drawing Plugin Frame %d\n\n", plugin_frame);
|
// DEBUG_MSG("Drawing Module Frame %d\n\n", module_frame);
|
||||||
MeshPlugin &pi = *pluginFrames.at(plugin_frame);
|
MeshPlugin &pi = *pluginFrames.at(module_frame);
|
||||||
pi.drawFrame(display, state, x, y);
|
pi.drawFrame(display, state, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -988,12 +988,12 @@ void Screen::setFrames()
|
|||||||
|
|
||||||
size_t numframes = 0;
|
size_t numframes = 0;
|
||||||
|
|
||||||
// put all of the plugin frames first.
|
// put all of the module frames first.
|
||||||
// this is a little bit of a dirty hack; since we're going to call
|
// this is a little bit of a dirty hack; since we're going to call
|
||||||
// the same drawPluginFrame handler here for all of these plugin frames
|
// the same drawModuleFrame handler here for all of these module frames
|
||||||
// and then we'll just assume that the state->currentFrame value
|
// and then we'll just assume that the state->currentFrame value
|
||||||
// is the same offset into the pluginFrames vector
|
// is the same offset into the moduleFrames vector
|
||||||
// so that we can invoke the plugin's callback
|
// so that we can invoke the module's callback
|
||||||
for (auto i = pluginFrames.begin(); i != pluginFrames.end(); ++i) {
|
for (auto i = pluginFrames.begin(); i != pluginFrames.end(); ++i) {
|
||||||
normalFrames[numframes++] = drawPluginFrame;
|
normalFrames[numframes++] = drawPluginFrame;
|
||||||
}
|
}
|
||||||
|
@ -538,7 +538,7 @@ void setup()
|
|||||||
service.init();
|
service.init();
|
||||||
|
|
||||||
// Now that the mesh service is created, create any modules
|
// Now that the mesh service is created, create any modules
|
||||||
setupPlugins();
|
setupModules();
|
||||||
|
|
||||||
// Do this after service.init (because that clears error_code)
|
// Do this after service.init (because that clears error_code)
|
||||||
#ifdef AXP192_SLAVE_ADDRESS
|
#ifdef AXP192_SLAVE_ADDRESS
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include "modules/RoutingModule.h"
|
#include "modules/RoutingModule.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
std::vector<MeshPlugin *> *MeshPlugin::plugins;
|
std::vector<MeshPlugin *> *MeshPlugin::modules;
|
||||||
|
|
||||||
const MeshPacket *MeshPlugin::currentRequest;
|
const MeshPacket *MeshPlugin::currentRequest;
|
||||||
|
|
||||||
@ -19,10 +19,10 @@ MeshPacket *MeshPlugin::currentReply;
|
|||||||
MeshPlugin::MeshPlugin(const char *_name) : name(_name)
|
MeshPlugin::MeshPlugin(const char *_name) : name(_name)
|
||||||
{
|
{
|
||||||
// Can't trust static initalizer order, so we check each time
|
// Can't trust static initalizer order, so we check each time
|
||||||
if (!plugins)
|
if (!modules)
|
||||||
plugins = new std::vector<MeshPlugin *>();
|
modules = new std::vector<MeshPlugin *>();
|
||||||
|
|
||||||
plugins->push_back(this);
|
modules->push_back(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshPlugin::setup() {}
|
void MeshPlugin::setup() {}
|
||||||
@ -80,7 +80,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src)
|
|||||||
auto ourNodeNum = nodeDB.getNodeNum();
|
auto ourNodeNum = nodeDB.getNodeNum();
|
||||||
bool toUs = mp.to == NODENUM_BROADCAST || mp.to == ourNodeNum;
|
bool toUs = mp.to == NODENUM_BROADCAST || mp.to == ourNodeNum;
|
||||||
|
|
||||||
for (auto i = plugins->begin(); i != plugins->end(); ++i) {
|
for (auto i = modules->begin(); i != modules->end(); ++i) {
|
||||||
auto &pi = **i;
|
auto &pi = **i;
|
||||||
|
|
||||||
pi.currentRequest = ∓
|
pi.currentRequest = ∓
|
||||||
@ -96,7 +96,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src)
|
|||||||
assert(!pi.myReply); // If it is !null it means we have a bug, because it should have been sent the previous time
|
assert(!pi.myReply); // If it is !null it means we have a bug, because it should have been sent the previous time
|
||||||
|
|
||||||
if (wantsPacket) {
|
if (wantsPacket) {
|
||||||
DEBUG_MSG("Plugin '%s' wantsPacket=%d\n", pi.name, wantsPacket);
|
DEBUG_MSG("Module '%s' wantsPacket=%d\n", pi.name, wantsPacket);
|
||||||
|
|
||||||
pluginFound = true;
|
pluginFound = true;
|
||||||
|
|
||||||
@ -137,9 +137,9 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src)
|
|||||||
// any other node.
|
// any other node.
|
||||||
if (mp.decoded.want_response && toUs && (getFrom(&mp) != ourNodeNum || mp.to == ourNodeNum) && !currentReply) {
|
if (mp.decoded.want_response && toUs && (getFrom(&mp) != ourNodeNum || mp.to == ourNodeNum) && !currentReply) {
|
||||||
pi.sendResponse(mp);
|
pi.sendResponse(mp);
|
||||||
DEBUG_MSG("Plugin '%s' sent a response\n", pi.name);
|
DEBUG_MSG("Module '%s' sent a response\n", pi.name);
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Plugin '%s' considered\n", pi.name);
|
DEBUG_MSG("Module '%s' considered\n", pi.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the requester didn't ask for a response we might need to discard unused replies to prevent memory leaks
|
// If the requester didn't ask for a response we might need to discard unused replies to prevent memory leaks
|
||||||
@ -150,7 +150,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (handled == ProcessMessage::STOP) {
|
if (handled == ProcessMessage::STOP) {
|
||||||
DEBUG_MSG("Plugin '%s' handled and skipped other processing\n", pi.name);
|
DEBUG_MSG("Module '%s' handled and skipped other processing\n", pi.name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -226,11 +226,11 @@ std::vector<MeshPlugin *> MeshPlugin::GetMeshPluginsWithUIFrames()
|
|||||||
{
|
{
|
||||||
|
|
||||||
std::vector<MeshPlugin *> pluginsWithUIFrames;
|
std::vector<MeshPlugin *> pluginsWithUIFrames;
|
||||||
if (plugins) {
|
if (modules) {
|
||||||
for (auto i = plugins->begin(); i != plugins->end(); ++i) {
|
for (auto i = modules->begin(); i != modules->end(); ++i) {
|
||||||
auto &pi = **i;
|
auto &pi = **i;
|
||||||
if (pi.wantUIFrame()) {
|
if (pi.wantUIFrame()) {
|
||||||
DEBUG_MSG("Plugin wants a UI Frame\n");
|
DEBUG_MSG("Module wants a UI Frame\n");
|
||||||
pluginsWithUIFrames.push_back(&pi);
|
pluginsWithUIFrames.push_back(&pi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -241,13 +241,13 @@ std::vector<MeshPlugin *> MeshPlugin::GetMeshPluginsWithUIFrames()
|
|||||||
void MeshPlugin::observeUIEvents(
|
void MeshPlugin::observeUIEvents(
|
||||||
Observer<const UIFrameEvent *> *observer)
|
Observer<const UIFrameEvent *> *observer)
|
||||||
{
|
{
|
||||||
if (plugins) {
|
if (modules) {
|
||||||
for (auto i = plugins->begin(); i != plugins->end(); ++i) {
|
for (auto i = modules->begin(); i != modules->end(); ++i) {
|
||||||
auto &pi = **i;
|
auto &pi = **i;
|
||||||
Observable<const UIFrameEvent *> *observable =
|
Observable<const UIFrameEvent *> *observable =
|
||||||
pi.getUIFrameObservable();
|
pi.getUIFrameObservable();
|
||||||
if (observable != NULL) {
|
if (observable != NULL) {
|
||||||
DEBUG_MSG("Plugin wants a UI Frame\n");
|
DEBUG_MSG("Module wants a UI Frame\n");
|
||||||
observer->observe(observable);
|
observer->observe(observable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -257,8 +257,8 @@ void MeshPlugin::observeUIEvents(
|
|||||||
AdminMessageHandleResult MeshPlugin::handleAdminMessageForAllPlugins(const MeshPacket &mp, AdminMessage *request, AdminMessage *response)
|
AdminMessageHandleResult MeshPlugin::handleAdminMessageForAllPlugins(const MeshPacket &mp, AdminMessage *request, AdminMessage *response)
|
||||||
{
|
{
|
||||||
AdminMessageHandleResult handled = AdminMessageHandleResult::NOT_HANDLED;
|
AdminMessageHandleResult handled = AdminMessageHandleResult::NOT_HANDLED;
|
||||||
if (plugins) {
|
if (modules) {
|
||||||
for (auto i = plugins->begin(); i != plugins->end(); ++i) {
|
for (auto i = modules->begin(); i != modules->end(); ++i) {
|
||||||
auto &pi = **i;
|
auto &pi = **i;
|
||||||
AdminMessageHandleResult h = pi.handleAdminMessageForPlugin(mp, request, response);
|
AdminMessageHandleResult h = pi.handleAdminMessageForPlugin(mp, request, response);
|
||||||
if (h == AdminMessageHandleResult::HANDLED_WITH_RESPONSE)
|
if (h == AdminMessageHandleResult::HANDLED_WITH_RESPONSE)
|
||||||
|
@ -54,7 +54,7 @@ typedef struct _UIFrameEvent {
|
|||||||
*/
|
*/
|
||||||
class MeshPlugin
|
class MeshPlugin
|
||||||
{
|
{
|
||||||
static std::vector<MeshPlugin *> *plugins;
|
static std::vector<MeshPlugin *> *modules;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Constructor
|
/** Constructor
|
||||||
@ -151,7 +151,7 @@ class MeshPlugin
|
|||||||
MeshPacket *allocErrorResponse(Routing_Error err, const MeshPacket *p);
|
MeshPacket *allocErrorResponse(Routing_Error err, const MeshPacket *p);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief An admin message arrived to AdminPlugin. Plugin was asked whether it want to handle the request.
|
* @brief An admin message arrived to AdminModule. Module was asked whether it want to handle the request.
|
||||||
*
|
*
|
||||||
* @param mp The mesh packet arrived.
|
* @param mp The mesh packet arrived.
|
||||||
* @param request The AdminMessage request extracted from the packet.
|
* @param request The AdminMessage request extracted from the packet.
|
||||||
@ -166,7 +166,7 @@ class MeshPlugin
|
|||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* If any of the current chain of modules has already sent a reply, it will be here. This is useful to allow
|
* If any of the current chain of modules has already sent a reply, it will be here. This is useful to allow
|
||||||
* the RoutingPlugin to avoid sending redundant acks
|
* the RoutingModule to avoid sending redundant acks
|
||||||
*/
|
*/
|
||||||
static MeshPacket *currentReply;
|
static MeshPacket *currentReply;
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ int CannedMessageModule::splitConfiguredMessages()
|
|||||||
messageIndex-1, this->messages[messageIndex-1]);
|
messageIndex-1, this->messages[messageIndex-1]);
|
||||||
|
|
||||||
// hit our max messages, bail
|
// hit our max messages, bail
|
||||||
if (messageIndex >= CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_COUNT)
|
if (messageIndex >= CANNED_MESSAGE_MODULE_MESSAGE_MAX_COUNT)
|
||||||
{
|
{
|
||||||
this->messagesCount = messageIndex;
|
this->messagesCount = messageIndex;
|
||||||
return this->messagesCount;
|
return this->messagesCount;
|
||||||
|
@ -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.
|
* Sum of CannedMessageModuleConfig part sizes.
|
||||||
*/
|
*/
|
||||||
#define CANNED_MESSAGE_PLUGIN_MESSAGES_SIZE 800
|
#define CANNED_MESSAGE_MODULE_MESSAGES_SIZE 800
|
||||||
|
|
||||||
class CannedMessageModule :
|
class CannedMessageModule :
|
||||||
public SinglePortPlugin,
|
public SinglePortPlugin,
|
||||||
@ -77,8 +77,8 @@ class CannedMessageModule :
|
|||||||
int currentMessageIndex = -1;
|
int currentMessageIndex = -1;
|
||||||
cannedMessageModuleRunState runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
|
cannedMessageModuleRunState runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
|
||||||
|
|
||||||
char messageStore[CANNED_MESSAGE_PLUGIN_MESSAGES_SIZE+1];
|
char messageStore[CANNED_MESSAGE_MODULE_MESSAGES_SIZE+1];
|
||||||
char *messages[CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_COUNT];
|
char *messages[CANNED_MESSAGE_MODULE_MESSAGE_MAX_COUNT];
|
||||||
int messagesCount = 0;
|
int messagesCount = 0;
|
||||||
unsigned long lastTouchMillis = 0;
|
unsigned long lastTouchMillis = 0;
|
||||||
};
|
};
|
||||||
|
@ -44,15 +44,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Default configurations
|
// Default configurations
|
||||||
#define EXT_NOTIFICATION_PLUGIN_OUTPUT EXT_NOTIFY_OUT
|
#define EXT_NOTIFICATION_MODULE_OUTPUT EXT_NOTIFY_OUT
|
||||||
#define EXT_NOTIFICATION_PLUGIN_OUTPUT_MS 1000
|
#define EXT_NOTIFICATION_MODULE_OUTPUT_MS 1000
|
||||||
|
|
||||||
#define ASCII_BELL 0x07
|
#define ASCII_BELL 0x07
|
||||||
|
|
||||||
bool externalCurrentState = 0;
|
bool externalCurrentState = 0;
|
||||||
uint32_t externalTurnedOn = 0;
|
uint32_t externalTurnedOn = 0;
|
||||||
|
|
||||||
int32_t ExternalNotificationPlugin::runOnce()
|
int32_t ExternalNotificationModule::runOnce()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Uncomment the preferences below if you want to use the module
|
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 the output is turned on, turn it back off after the given period of time.
|
||||||
if (externalTurnedOn + (radioConfig.preferences.ext_notification_module_output_ms
|
if (externalTurnedOn + (radioConfig.preferences.ext_notification_module_output_ms
|
||||||
? 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()) {
|
millis()) {
|
||||||
DEBUG_MSG("Turning off external notification\n");
|
DEBUG_MSG("Turning off external notification\n");
|
||||||
setExternalOff();
|
setExternalOff();
|
||||||
@ -82,34 +82,34 @@ int32_t ExternalNotificationPlugin::runOnce()
|
|||||||
return (25);
|
return (25);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExternalNotificationPlugin::setExternalOn()
|
void ExternalNotificationModule::setExternalOn()
|
||||||
{
|
{
|
||||||
#ifdef EXT_NOTIFY_OUT
|
#ifdef EXT_NOTIFY_OUT
|
||||||
externalCurrentState = 1;
|
externalCurrentState = 1;
|
||||||
externalTurnedOn = millis();
|
externalTurnedOn = millis();
|
||||||
|
|
||||||
digitalWrite((radioConfig.preferences.ext_notification_module_output ? radioConfig.preferences.ext_notification_module_output
|
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));
|
(radioConfig.preferences.ext_notification_module_active ? true : false));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExternalNotificationPlugin::setExternalOff()
|
void ExternalNotificationModule::setExternalOff()
|
||||||
{
|
{
|
||||||
#ifdef EXT_NOTIFY_OUT
|
#ifdef EXT_NOTIFY_OUT
|
||||||
externalCurrentState = 0;
|
externalCurrentState = 0;
|
||||||
|
|
||||||
digitalWrite((radioConfig.preferences.ext_notification_module_output ? radioConfig.preferences.ext_notification_module_output
|
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));
|
(radioConfig.preferences.ext_notification_module_active ? false : true));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------
|
// --------
|
||||||
|
|
||||||
ExternalNotificationPlugin::ExternalNotificationPlugin()
|
ExternalNotificationModule::ExternalNotificationModule()
|
||||||
: SinglePortPlugin("ExternalNotificationPlugin", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread(
|
: SinglePortPlugin("ExternalNotificationModule", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread(
|
||||||
"ExternalNotificationPlugin")
|
"ExternalNotificationModule")
|
||||||
{
|
{
|
||||||
// restrict to the admin channel for rx
|
// restrict to the admin channel for rx
|
||||||
boundChannel = Channels::gpioChannel;
|
boundChannel = Channels::gpioChannel;
|
||||||
@ -118,7 +118,7 @@ ExternalNotificationPlugin::ExternalNotificationPlugin()
|
|||||||
#ifdef EXT_NOTIFY_OUT
|
#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.
|
without having to configure it from the PythonAPI or WebUI.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -132,24 +132,24 @@ ExternalNotificationPlugin::ExternalNotificationPlugin()
|
|||||||
|
|
||||||
if (radioConfig.preferences.ext_notification_module_enabled) {
|
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
|
// Set the direction of a pin
|
||||||
pinMode((radioConfig.preferences.ext_notification_module_output ? radioConfig.preferences.ext_notification_module_output
|
pinMode((radioConfig.preferences.ext_notification_module_output ? radioConfig.preferences.ext_notification_module_output
|
||||||
: EXT_NOTIFICATION_PLUGIN_OUTPUT),
|
: EXT_NOTIFICATION_MODULE_OUTPUT),
|
||||||
OUTPUT);
|
OUTPUT);
|
||||||
|
|
||||||
// Turn off the pin
|
// Turn off the pin
|
||||||
setExternalOff();
|
setExternalOff();
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("External Notification Plugin Disabled\n");
|
DEBUG_MSG("External Notification Module Disabled\n");
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessMessage ExternalNotificationPlugin::handleReceived(const MeshPacket &mp)
|
ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp)
|
||||||
{
|
{
|
||||||
#ifndef NO_ESP32
|
#ifndef NO_ESP32
|
||||||
#ifdef EXT_NOTIFY_OUT
|
#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.
|
// Need to know if and how this could be a problem.
|
||||||
if (radioConfig.preferences.ext_notification_module_alert_bell) {
|
if (radioConfig.preferences.ext_notification_module_alert_bell) {
|
||||||
auto &p = mp.decoded;
|
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++) {
|
for (int i = 0; i < p.payload.size; i++) {
|
||||||
if (p.payload.bytes[i] == ASCII_BELL) {
|
if (p.payload.bytes[i] == ASCII_BELL) {
|
||||||
setExternalOn();
|
setExternalOn();
|
||||||
@ -171,13 +171,13 @@ ProcessMessage ExternalNotificationPlugin::handleReceived(const MeshPacket &mp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (radioConfig.preferences.ext_notification_module_alert_message) {
|
if (radioConfig.preferences.ext_notification_module_alert_message) {
|
||||||
DEBUG_MSG("externalNotificationPlugin - Notification Plugin\n");
|
DEBUG_MSG("externalNotificationModule - Notification Module\n");
|
||||||
setExternalOn();
|
setExternalOn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("External Notification Plugin Disabled\n");
|
DEBUG_MSG("External Notification Module Disabled\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -7,13 +7,13 @@
|
|||||||
#include <functional>
|
#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:
|
public:
|
||||||
ExternalNotificationPlugin();
|
ExternalNotificationModule();
|
||||||
|
|
||||||
void setExternalOn();
|
void setExternalOn();
|
||||||
void setExternalOff();
|
void setExternalOff();
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
/**
|
/**
|
||||||
* Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else)
|
* 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();
|
inputBroker = new InputBroker();
|
||||||
adminPlugin = new AdminPlugin();
|
adminPlugin = new AdminPlugin();
|
||||||
@ -48,12 +48,11 @@ void setupPlugins()
|
|||||||
Maintained by MC Hamster (Jm Casler) jm@casler.org
|
Maintained by MC Hamster (Jm Casler) jm@casler.org
|
||||||
*/
|
*/
|
||||||
new SerialPlugin();
|
new SerialPlugin();
|
||||||
new ExternalNotificationPlugin();
|
new ExternalNotificationModule();
|
||||||
|
|
||||||
// rangeTestPlugin = new RangeTestPlugin();
|
|
||||||
storeForwardPlugin = new StoreForwardPlugin();
|
storeForwardPlugin = new StoreForwardPlugin();
|
||||||
|
|
||||||
new RangeTestPlugin();
|
new RangeTestModule();
|
||||||
// new StoreForwardPlugin();
|
// new StoreForwardPlugin();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
/**
|
/**
|
||||||
* Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else)
|
* Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else)
|
||||||
*/
|
*/
|
||||||
void setupPlugins();
|
void setupModules();
|
@ -16,10 +16,10 @@
|
|||||||
As a receiver, I can receive packets from multiple senders. These packets can be saved to the Filesystem.
|
As a receiver, I can receive packets from multiple senders. These packets can be saved to the Filesystem.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RangeTestPlugin *rangeTestPlugin;
|
RangeTestModule *rangeTestModule;
|
||||||
RangeTestPluginRadio *rangeTestPluginRadio;
|
RangeTestModuleRadio *rangeTestModuleRadio;
|
||||||
|
|
||||||
RangeTestPlugin::RangeTestPlugin() : concurrency::OSThread("RangeTestPlugin") {}
|
RangeTestModule::RangeTestModule() : concurrency::OSThread("RangeTestModule") {}
|
||||||
|
|
||||||
uint32_t packetSequence = 0;
|
uint32_t packetSequence = 0;
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ uint32_t packetSequence = 0;
|
|||||||
#define SEC_PER_HOUR 3600
|
#define SEC_PER_HOUR 3600
|
||||||
#define SEC_PER_MIN 60
|
#define SEC_PER_MIN 60
|
||||||
|
|
||||||
int32_t RangeTestPlugin::runOnce()
|
int32_t RangeTestModule::runOnce()
|
||||||
{
|
{
|
||||||
#ifndef NO_ESP32
|
#ifndef NO_ESP32
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ int32_t RangeTestPlugin::runOnce()
|
|||||||
if (radioConfig.preferences.range_test_module_enabled) {
|
if (radioConfig.preferences.range_test_module_enabled) {
|
||||||
|
|
||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
rangeTestPluginRadio = new RangeTestPluginRadio();
|
rangeTestModuleRadio = new RangeTestModuleRadio();
|
||||||
|
|
||||||
firstTime = 0;
|
firstTime = 0;
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ int32_t RangeTestPlugin::runOnce()
|
|||||||
|
|
||||||
// Only send packets if the channel is less than 25% utilized.
|
// Only send packets if the channel is less than 25% utilized.
|
||||||
if (airTime->channelUtilizationPercent() < 25) {
|
if (airTime->channelUtilizationPercent() < 25) {
|
||||||
rangeTestPluginRadio->sendPayload();
|
rangeTestModuleRadio->sendPayload();
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("rangeTest - Channel utilization is >25 percent. Skipping this opportunity to send.\n");
|
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);
|
return (INT32_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshPacket *RangeTestPluginRadio::allocReply()
|
MeshPacket *RangeTestModuleRadio::allocReply()
|
||||||
{
|
{
|
||||||
|
|
||||||
auto reply = allocDataPacket(); // Allocate a packet for sending
|
auto reply = allocDataPacket(); // Allocate a packet for sending
|
||||||
@ -105,7 +105,7 @@ MeshPacket *RangeTestPluginRadio::allocReply()
|
|||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RangeTestPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
|
void RangeTestModuleRadio::sendPayload(NodeNum dest, bool wantReplies)
|
||||||
{
|
{
|
||||||
MeshPacket *p = allocReply();
|
MeshPacket *p = allocReply();
|
||||||
p->to = dest;
|
p->to = dest;
|
||||||
@ -127,7 +127,7 @@ void RangeTestPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
|
|||||||
powerFSM.trigger(EVENT_CONTACT_FROM_PHONE);
|
powerFSM.trigger(EVENT_CONTACT_FROM_PHONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessMessage RangeTestPluginRadio::handleReceived(const MeshPacket &mp)
|
ProcessMessage RangeTestModuleRadio::handleReceived(const MeshPacket &mp)
|
||||||
{
|
{
|
||||||
#ifndef NO_ESP32
|
#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
|
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;
|
auto &p = mp.decoded;
|
||||||
|
|
||||||
|
@ -6,29 +6,29 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
class RangeTestPlugin : private concurrency::OSThread
|
class RangeTestModule : private concurrency::OSThread
|
||||||
{
|
{
|
||||||
bool firstTime = 1;
|
bool firstTime = 1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RangeTestPlugin();
|
RangeTestModule();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int32_t runOnce() override;
|
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;
|
uint32_t lastRxID = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RangeTestPluginRadio() : SinglePortPlugin("RangeTestPluginRadio", PortNum_TEXT_MESSAGE_APP) {}
|
RangeTestModuleRadio() : SinglePortPlugin("RangeTestModuleRadio", PortNum_TEXT_MESSAGE_APP) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send our payload into the mesh
|
* Send our payload into the mesh
|
||||||
@ -55,4 +55,4 @@ class RangeTestPluginRadio : public SinglePortPlugin
|
|||||||
virtual ProcessMessage handleReceived(const MeshPacket &mp) override;
|
virtual ProcessMessage handleReceived(const MeshPacket &mp) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern RangeTestPluginRadio *rangeTestPluginRadio;
|
extern RangeTestModuleRadio *rangeTestModuleRadio;
|
||||||
|
@ -48,11 +48,11 @@
|
|||||||
|
|
||||||
#define RXD2 16
|
#define RXD2 16
|
||||||
#define TXD2 17
|
#define TXD2 17
|
||||||
#define SERIALPLUGIN_RX_BUFFER 128
|
#define SERIALMODULE_RX_BUFFER 128
|
||||||
#define SERIALPLUGIN_STRING_MAX Constants_DATA_PAYLOAD_LEN
|
#define SERIALMODULE_STRING_MAX Constants_DATA_PAYLOAD_LEN
|
||||||
#define SERIALPLUGIN_TIMEOUT 250
|
#define SERIALMODULE_TIMEOUT 250
|
||||||
#define SERIALPLUGIN_BAUD 38400
|
#define SERIALMODULE_BAUD 38400
|
||||||
#define SERIALPLUGIN_ACK 1
|
#define SERIALMODULE_ACK 1
|
||||||
|
|
||||||
SerialPlugin *serialPlugin;
|
SerialPlugin *serialPlugin;
|
||||||
SerialPluginRadio *serialPluginRadio;
|
SerialPluginRadio *serialPluginRadio;
|
||||||
@ -90,11 +90,11 @@ int32_t SerialPlugin::runOnce()
|
|||||||
DEBUG_MSG("Initializing serial peripheral interface\n");
|
DEBUG_MSG("Initializing serial peripheral interface\n");
|
||||||
|
|
||||||
if (radioConfig.preferences.serialmodule_rxd && radioConfig.preferences.serialmodule_txd) {
|
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);
|
radioConfig.preferences.serialmodule_txd);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Serial2.begin(SERIALPLUGIN_BAUD, SERIAL_8N1, RXD2, TXD2);
|
Serial2.begin(SERIALMODULE_BAUD, SERIAL_8N1, RXD2, TXD2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (radioConfig.preferences.serialmodule_timeout) {
|
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.
|
radioConfig.preferences.serialmodule_timeout); // Number of MS to wait to set the timeout for the string.
|
||||||
|
|
||||||
} else {
|
} 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();
|
serialPluginRadio = new SerialPluginRadio();
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ void SerialPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
|
|||||||
p->to = dest;
|
p->to = dest;
|
||||||
p->decoded.want_response = wantReplies;
|
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
|
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);
|
memcpy(p->decoded.payload.bytes, serialStringChar, p->decoded.payload.size);
|
||||||
|
Loading…
Reference in New Issue
Block a user