mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-08 05:31:25 +00:00
more rename plugin to module
This commit is contained in:
parent
3c5e49d8f4
commit
e53abbfb2b
@ -69,7 +69,7 @@ uint32_t dopThresholds[5] = {2000, 1000, 500, 200, 100};
|
|||||||
|
|
||||||
// At some point, we're going to ask all of the modules if they would like to display a screen frame
|
// At some point, we're going to ask all of the modules if they would like to display a screen frame
|
||||||
// we'll need to hold onto pointers for the modules that can draw a frame.
|
// we'll need to hold onto pointers for the modules that can draw a frame.
|
||||||
std::vector<MeshPlugin *> pluginFrames;
|
std::vector<MeshPlugin *> moduleFrames;
|
||||||
|
|
||||||
// Stores the last 4 of our hardware ID, to make finding the device for pairing easier
|
// Stores the last 4 of our hardware ID, to make finding the device for pairing easier
|
||||||
static char ourId[5];
|
static char ourId[5];
|
||||||
@ -194,7 +194,7 @@ static void drawPluginFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int
|
|||||||
// DEBUG_MSG("Screen is not in transition. Frame: %d\n\n", module_frame);
|
// DEBUG_MSG("Screen is not in transition. Frame: %d\n\n", module_frame);
|
||||||
}
|
}
|
||||||
// DEBUG_MSG("Drawing Module Frame %d\n\n", module_frame);
|
// DEBUG_MSG("Drawing Module Frame %d\n\n", module_frame);
|
||||||
MeshPlugin &pi = *pluginFrames.at(module_frame);
|
MeshPlugin &pi = *moduleFrames.at(module_frame);
|
||||||
pi.drawFrame(display, state, x, y);
|
pi.drawFrame(display, state, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -824,8 +824,8 @@ void Screen::setup()
|
|||||||
powerStatusObserver.observe(&powerStatus->onNewStatus);
|
powerStatusObserver.observe(&powerStatus->onNewStatus);
|
||||||
gpsStatusObserver.observe(&gpsStatus->onNewStatus);
|
gpsStatusObserver.observe(&gpsStatus->onNewStatus);
|
||||||
nodeStatusObserver.observe(&nodeStatus->onNewStatus);
|
nodeStatusObserver.observe(&nodeStatus->onNewStatus);
|
||||||
if (textMessagePlugin)
|
if (textMessageModule)
|
||||||
textMessageObserver.observe(textMessagePlugin);
|
textMessageObserver.observe(textMessageModule);
|
||||||
|
|
||||||
// Modules can notify screen about refresh
|
// Modules can notify screen about refresh
|
||||||
MeshPlugin::observeUIEvents(&uiFrameEventObserver);
|
MeshPlugin::observeUIEvents(&uiFrameEventObserver);
|
||||||
@ -976,9 +976,9 @@ void Screen::setFrames()
|
|||||||
DEBUG_MSG("showing standard frames\n");
|
DEBUG_MSG("showing standard frames\n");
|
||||||
showingNormalScreen = true;
|
showingNormalScreen = true;
|
||||||
|
|
||||||
pluginFrames = MeshPlugin::GetMeshPluginsWithUIFrames();
|
moduleFrames = MeshPlugin::GetMeshPluginsWithUIFrames();
|
||||||
DEBUG_MSG("Showing %d module frames\n", pluginFrames.size());
|
DEBUG_MSG("Showing %d module frames\n", moduleFrames.size());
|
||||||
int totalFrameCount = MAX_NUM_NODES + NUM_EXTRA_FRAMES + pluginFrames.size();
|
int totalFrameCount = MAX_NUM_NODES + NUM_EXTRA_FRAMES + moduleFrames.size();
|
||||||
DEBUG_MSG("Total frame count: %d\n", totalFrameCount);
|
DEBUG_MSG("Total frame count: %d\n", totalFrameCount);
|
||||||
|
|
||||||
// We don't show the node info our our node (if we have it yet - we should)
|
// We don't show the node info our our node (if we have it yet - we should)
|
||||||
@ -994,7 +994,7 @@ void Screen::setFrames()
|
|||||||
// 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 moduleFrames vector
|
// is the same offset into the moduleFrames vector
|
||||||
// so that we can invoke the module's callback
|
// so that we can invoke the module's callback
|
||||||
for (auto i = pluginFrames.begin(); i != pluginFrames.end(); ++i) {
|
for (auto i = moduleFrames.begin(); i != moduleFrames.end(); ++i) {
|
||||||
normalFrames[numframes++] = drawPluginFrame;
|
normalFrames[numframes++] = drawPluginFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ MeshPacket *MeshPlugin::allocErrorResponse(Routing_Error err, const MeshPacket *
|
|||||||
void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src)
|
void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src)
|
||||||
{
|
{
|
||||||
// DEBUG_MSG("In call modules\n");
|
// DEBUG_MSG("In call modules\n");
|
||||||
bool pluginFound = false;
|
bool moduleFound = false;
|
||||||
|
|
||||||
// We now allow **encrypted** packets to pass through the modules
|
// We now allow **encrypted** packets to pass through the modules
|
||||||
bool isDecoded = mp.which_payloadVariant == MeshPacket_decoded_tag;
|
bool isDecoded = mp.which_payloadVariant == MeshPacket_decoded_tag;
|
||||||
@ -98,7 +98,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src)
|
|||||||
if (wantsPacket) {
|
if (wantsPacket) {
|
||||||
DEBUG_MSG("Module '%s' wantsPacket=%d\n", pi.name, wantsPacket);
|
DEBUG_MSG("Module '%s' wantsPacket=%d\n", pi.name, wantsPacket);
|
||||||
|
|
||||||
pluginFound = true;
|
moduleFound = true;
|
||||||
|
|
||||||
/// received channel (or NULL if not decoded)
|
/// received channel (or NULL if not decoded)
|
||||||
Channel *ch = isDecoded ? &channels.getByIndex(mp.channel) : NULL;
|
Channel *ch = isDecoded ? &channels.getByIndex(mp.channel) : NULL;
|
||||||
@ -173,11 +173,11 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src)
|
|||||||
// SECURITY NOTE! I considered sending back a different error code if we didn't find the psk (i.e. !isDecoded)
|
// SECURITY NOTE! I considered sending back a different error code if we didn't find the psk (i.e. !isDecoded)
|
||||||
// but opted NOT TO. Because it is not a good idea to let remote nodes 'probe' to find out which PSKs were "good" vs
|
// but opted NOT TO. Because it is not a good idea to let remote nodes 'probe' to find out which PSKs were "good" vs
|
||||||
// bad.
|
// bad.
|
||||||
routingPlugin->sendAckNak(Routing_Error_NO_RESPONSE, getFrom(&mp), mp.id, mp.channel);
|
routingModule->sendAckNak(Routing_Error_NO_RESPONSE, getFrom(&mp), mp.id, mp.channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pluginFound)
|
if (!moduleFound)
|
||||||
DEBUG_MSG("No modules interested in portnum=%d, src=%s\n",
|
DEBUG_MSG("No modules interested in portnum=%d, src=%s\n",
|
||||||
mp.decoded.portnum,
|
mp.decoded.portnum,
|
||||||
(src == RX_SRC_LOCAL) ? "LOCAL":"REMOTE");
|
(src == RX_SRC_LOCAL) ? "LOCAL":"REMOTE");
|
||||||
@ -225,17 +225,17 @@ void setReplyTo(MeshPacket *p, const MeshPacket &to)
|
|||||||
std::vector<MeshPlugin *> MeshPlugin::GetMeshPluginsWithUIFrames()
|
std::vector<MeshPlugin *> MeshPlugin::GetMeshPluginsWithUIFrames()
|
||||||
{
|
{
|
||||||
|
|
||||||
std::vector<MeshPlugin *> pluginsWithUIFrames;
|
std::vector<MeshPlugin *> modulesWithUIFrames;
|
||||||
if (modules) {
|
if (modules) {
|
||||||
for (auto i = modules->begin(); i != modules->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("Module wants a UI Frame\n");
|
DEBUG_MSG("Module wants a UI Frame\n");
|
||||||
pluginsWithUIFrames.push_back(&pi);
|
modulesWithUIFrames.push_back(&pi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pluginsWithUIFrames;
|
return modulesWithUIFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshPlugin::observeUIEvents(
|
void MeshPlugin::observeUIEvents(
|
||||||
@ -260,7 +260,7 @@ AdminMessageHandleResult MeshPlugin::handleAdminMessageForAllPlugins(const MeshP
|
|||||||
if (modules) {
|
if (modules) {
|
||||||
for (auto i = modules->begin(); i != modules->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.handleAdminMessageForModule(mp, request, response);
|
||||||
if (h == AdminMessageHandleResult::HANDLED_WITH_RESPONSE)
|
if (h == AdminMessageHandleResult::HANDLED_WITH_RESPONSE)
|
||||||
{
|
{
|
||||||
// In case we have a response it always has priority.
|
// In case we have a response it always has priority.
|
||||||
|
@ -160,7 +160,7 @@ class MeshPlugin
|
|||||||
* HANDLED if message was handled
|
* HANDLED if message was handled
|
||||||
* HANDLED_WITH_RESPONSE if a response is also prepared and to be sent.
|
* HANDLED_WITH_RESPONSE if a response is also prepared and to be sent.
|
||||||
*/
|
*/
|
||||||
virtual AdminMessageHandleResult handleAdminMessageForPlugin(
|
virtual AdminMessageHandleResult handleAdminMessageForModule(
|
||||||
const MeshPacket &mp, AdminMessage *request, AdminMessage *response) { return AdminMessageHandleResult::NOT_HANDLED; };
|
const MeshPacket &mp, AdminMessage *request, AdminMessage *response) { return AdminMessageHandleResult::NOT_HANDLED; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -115,10 +115,10 @@ void MeshService::reloadOwner()
|
|||||||
// DEBUG_MSG("reloadOwner()\n");
|
// DEBUG_MSG("reloadOwner()\n");
|
||||||
// update our local data directly
|
// update our local data directly
|
||||||
nodeDB.updateUser(nodeDB.getNodeNum(), owner);
|
nodeDB.updateUser(nodeDB.getNodeNum(), owner);
|
||||||
assert(nodeInfoPlugin);
|
assert(nodeInfoModule);
|
||||||
// update everyone else
|
// update everyone else
|
||||||
if (nodeInfoPlugin)
|
if (nodeInfoModule)
|
||||||
nodeInfoPlugin->sendOurNodeInfo();
|
nodeInfoModule->sendOurNodeInfo();
|
||||||
nodeDB.saveToDisk();
|
nodeDB.saveToDisk();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,14 +175,14 @@ void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies)
|
|||||||
assert(node);
|
assert(node);
|
||||||
|
|
||||||
if (node->has_position) {
|
if (node->has_position) {
|
||||||
if (positionPlugin) {
|
if (positionModule) {
|
||||||
DEBUG_MSG("Sending position ping to 0x%x, wantReplies=%d\n", dest, wantReplies);
|
DEBUG_MSG("Sending position ping to 0x%x, wantReplies=%d\n", dest, wantReplies);
|
||||||
positionPlugin->sendOurPosition(dest, wantReplies);
|
positionModule->sendOurPosition(dest, wantReplies);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (nodeInfoPlugin) {
|
if (nodeInfoModule) {
|
||||||
DEBUG_MSG("Sending nodeinfo ping to 0x%x, wantReplies=%d\n", dest, wantReplies);
|
DEBUG_MSG("Sending nodeinfo ping to 0x%x, wantReplies=%d\n", dest, wantReplies);
|
||||||
nodeInfoPlugin->sendOurNodeInfo(dest, wantReplies);
|
nodeInfoModule->sendOurNodeInfo(dest, wantReplies);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ class MeshService
|
|||||||
/// Handle a packet that just arrived from the radio. This method does _ReliableRouternot_ free the provided packet. If it
|
/// Handle a packet that just arrived from the radio. This method does _ReliableRouternot_ free the provided packet. If it
|
||||||
/// needs to keep the packet around it makes a copy
|
/// needs to keep the packet around it makes a copy
|
||||||
int handleFromRadio(const MeshPacket *p);
|
int handleFromRadio(const MeshPacket *p);
|
||||||
friend class RoutingPlugin;
|
friend class RoutingModule;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MeshService service;
|
extern MeshService service;
|
||||||
|
@ -132,7 +132,7 @@ MeshPacket *Router::allocForSending()
|
|||||||
*/
|
*/
|
||||||
void Router::sendAckNak(Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex)
|
void Router::sendAckNak(Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex)
|
||||||
{
|
{
|
||||||
routingPlugin->sendAckNak(err, to, idFrom, chIndex);
|
routingModule->sendAckNak(err, to, idFrom, chIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Router::abortSendAndNak(Routing_Error err, MeshPacket *p)
|
void Router::abortSendAndNak(Routing_Error err, MeshPacket *p)
|
||||||
|
@ -71,7 +71,7 @@ class Router : protected concurrency::OSThread
|
|||||||
void enqueueReceivedMessage(MeshPacket *p);
|
void enqueueReceivedMessage(MeshPacket *p);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class RoutingPlugin;
|
friend class RoutingModule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a packet on a suitable interface. This routine will
|
* Send a packet on a suitable interface. This routine will
|
||||||
@ -85,7 +85,7 @@ class Router : protected concurrency::OSThread
|
|||||||
/**
|
/**
|
||||||
* Should this incoming filter be dropped?
|
* Should this incoming filter be dropped?
|
||||||
*
|
*
|
||||||
* FIXME, move this into the new RoutingPlugin and do the filtering there using the regular module logic
|
* FIXME, move this into the new RoutingModule and do the filtering there using the regular module logic
|
||||||
*
|
*
|
||||||
* Called immedately on receiption, before any further processing.
|
* Called immedately on receiption, before any further processing.
|
||||||
* @return true to abandon the packet
|
* @return true to abandon the packet
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "unistd.h"
|
#include "unistd.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
AdminPlugin *adminPlugin;
|
AdminModule *adminModule;
|
||||||
|
|
||||||
/// A special reserved string to indicate strings we can not share with external nodes. We will use this 'reserved' word instead.
|
/// A special reserved string to indicate strings we can not share with external nodes. We will use this 'reserved' word instead.
|
||||||
/// Also, to make setting work correctly, if someone tries to set a string to this reserved value we assume they don't really want a change.
|
/// Also, to make setting work correctly, if someone tries to set a string to this reserved value we assume they don't really want a change.
|
||||||
@ -30,7 +30,7 @@ static void writeSecret(char *buf, const char *currentVal) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdminPlugin::handleGetChannel(const MeshPacket &req, uint32_t channelIndex)
|
void AdminModule::handleGetChannel(const MeshPacket &req, uint32_t channelIndex)
|
||||||
{
|
{
|
||||||
if (req.decoded.want_response) {
|
if (req.decoded.want_response) {
|
||||||
// We create the reply here
|
// We create the reply here
|
||||||
@ -41,7 +41,7 @@ void AdminPlugin::handleGetChannel(const MeshPacket &req, uint32_t channelIndex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdminPlugin::handleGetRadio(const MeshPacket &req)
|
void AdminModule::handleGetRadio(const MeshPacket &req)
|
||||||
{
|
{
|
||||||
if (req.decoded.want_response) {
|
if (req.decoded.want_response) {
|
||||||
// We create the reply here
|
// We create the reply here
|
||||||
@ -61,7 +61,7 @@ void AdminPlugin::handleGetRadio(const MeshPacket &req)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AdminPlugin::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
|
bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
|
||||||
{
|
{
|
||||||
// if handled == false, then let others look at this message also if they want
|
// if handled == false, then let others look at this message also if they want
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
@ -143,7 +143,7 @@ bool AdminPlugin::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
|
|||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdminPlugin::handleSetOwner(const User &o)
|
void AdminModule::handleSetOwner(const User &o)
|
||||||
{
|
{
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ void AdminPlugin::handleSetOwner(const User &o)
|
|||||||
service.reloadOwner();
|
service.reloadOwner();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdminPlugin::handleSetChannel(const Channel &cc)
|
void AdminModule::handleSetChannel(const Channel &cc)
|
||||||
{
|
{
|
||||||
channels.setChannel(cc);
|
channels.setChannel(cc);
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ void AdminPlugin::handleSetChannel(const Channel &cc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdminPlugin::handleSetRadio(RadioConfig &r)
|
void AdminModule::handleSetRadio(RadioConfig &r)
|
||||||
{
|
{
|
||||||
writeSecret(r.preferences.wifi_password, radioConfig.preferences.wifi_password);
|
writeSecret(r.preferences.wifi_password, radioConfig.preferences.wifi_password);
|
||||||
radioConfig = r;
|
radioConfig = r;
|
||||||
@ -195,7 +195,7 @@ void AdminPlugin::handleSetRadio(RadioConfig &r)
|
|||||||
service.reloadConfig();
|
service.reloadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
AdminPlugin::AdminPlugin() : ProtobufPlugin("Admin", PortNum_ADMIN_APP, AdminMessage_fields)
|
AdminModule::AdminModule() : ProtobufPlugin("Admin", PortNum_ADMIN_APP, AdminMessage_fields)
|
||||||
{
|
{
|
||||||
// restrict to the admin channel for rx
|
// restrict to the admin channel for rx
|
||||||
boundChannel = Channels::adminChannel;
|
boundChannel = Channels::adminChannel;
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
#include "ProtobufPlugin.h"
|
#include "ProtobufPlugin.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Routing plugin for router control messages
|
* Routing module for router control messages
|
||||||
*/
|
*/
|
||||||
class AdminPlugin : public ProtobufPlugin<AdminMessage>
|
class AdminModule : public ProtobufPlugin<AdminMessage>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Constructor
|
/** Constructor
|
||||||
* name is for debugging output
|
* name is for debugging output
|
||||||
*/
|
*/
|
||||||
AdminPlugin();
|
AdminModule();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Called to handle a particular incoming message
|
/** Called to handle a particular incoming message
|
||||||
@ -28,4 +28,4 @@ class AdminPlugin : public ProtobufPlugin<AdminMessage>
|
|||||||
void handleGetRadio(const MeshPacket &req);
|
void handleGetRadio(const MeshPacket &req);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern AdminPlugin *adminPlugin;
|
extern AdminModule *adminModule;
|
||||||
|
@ -28,10 +28,10 @@ CannedMessageModule::CannedMessageModule()
|
|||||||
{
|
{
|
||||||
if (radioConfig.preferences.canned_message_module_enabled)
|
if (radioConfig.preferences.canned_message_module_enabled)
|
||||||
{
|
{
|
||||||
this->loadProtoForPlugin();
|
this->loadProtoForModule();
|
||||||
if(this->splitConfiguredMessages() <= 0)
|
if(this->splitConfiguredMessages() <= 0)
|
||||||
{
|
{
|
||||||
DEBUG_MSG("CannedMessageModule: No messages are configured. Plugin is disabled\n");
|
DEBUG_MSG("CannedMessageModule: No messages are configured. Module is disabled\n");
|
||||||
this->runState = CANNED_MESSAGE_RUN_STATE_DISABLED;
|
this->runState = CANNED_MESSAGE_RUN_STATE_DISABLED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -313,7 +313,7 @@ void CannedMessageModule::drawFrame(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CannedMessageModule::loadProtoForPlugin()
|
void CannedMessageModule::loadProtoForModule()
|
||||||
{
|
{
|
||||||
if (!loadProto(cannedMessagesConfigFile, CannedMessageModuleConfig_size, sizeof(cannedMessagesConfigFile), CannedMessageModuleConfig_fields, &cannedMessageModuleConfig)) {
|
if (!loadProto(cannedMessagesConfigFile, CannedMessageModuleConfig_size, sizeof(cannedMessagesConfigFile), CannedMessageModuleConfig_fields, &cannedMessageModuleConfig)) {
|
||||||
installDefaultCannedMessageModuleConfig();
|
installDefaultCannedMessageModuleConfig();
|
||||||
@ -326,7 +326,7 @@ void CannedMessageModule::loadProtoForPlugin()
|
|||||||
* @return true On success.
|
* @return true On success.
|
||||||
* @return false On error.
|
* @return false On error.
|
||||||
*/
|
*/
|
||||||
bool CannedMessageModule::saveProtoForPlugin()
|
bool CannedMessageModule::saveProtoForModule()
|
||||||
{
|
{
|
||||||
bool okay = true;
|
bool okay = true;
|
||||||
|
|
||||||
@ -351,7 +351,7 @@ void CannedMessageModule::installDefaultCannedMessageModuleConfig()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief An admin message arrived to AdminPlugin. We are asked whether we want to handle that.
|
* @brief An admin message arrived to AdminModule. We are asked whether we want to handle that.
|
||||||
*
|
*
|
||||||
* @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.
|
||||||
@ -359,7 +359,7 @@ void CannedMessageModule::installDefaultCannedMessageModuleConfig()
|
|||||||
* @return AdminMessageHandleResult HANDLED if message was handled
|
* @return AdminMessageHandleResult HANDLED if message was handled
|
||||||
* HANDLED_WITH_RESULT if a result is also prepared.
|
* HANDLED_WITH_RESULT if a result is also prepared.
|
||||||
*/
|
*/
|
||||||
AdminMessageHandleResult CannedMessageModule::handleAdminMessageForPlugin(
|
AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(
|
||||||
const MeshPacket &mp, AdminMessage *request, AdminMessage *response)
|
const MeshPacket &mp, AdminMessage *request, AdminMessage *response)
|
||||||
{
|
{
|
||||||
AdminMessageHandleResult result;
|
AdminMessageHandleResult result;
|
||||||
@ -485,7 +485,7 @@ void CannedMessageModule::handleSetCannedMessageModulePart1(const char *from_msg
|
|||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
this->saveProtoForPlugin();
|
this->saveProtoForModule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,7 +501,7 @@ void CannedMessageModule::handleSetCannedMessageModulePart2(const char *from_msg
|
|||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
this->saveProtoForPlugin();
|
this->saveProtoForModule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -517,7 +517,7 @@ void CannedMessageModule::handleSetCannedMessageModulePart3(const char *from_msg
|
|||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
this->saveProtoForPlugin();
|
this->saveProtoForModule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,6 +533,6 @@ void CannedMessageModule::handleSetCannedMessageModulePart4(const char *from_msg
|
|||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
this->saveProtoForPlugin();
|
this->saveProtoForModule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,11 +66,11 @@ class CannedMessageModule :
|
|||||||
virtual Observable<const UIFrameEvent *>* getUIFrameObservable() override { return this; }
|
virtual Observable<const UIFrameEvent *>* getUIFrameObservable() override { return this; }
|
||||||
virtual void drawFrame(
|
virtual void drawFrame(
|
||||||
OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) override;
|
OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) override;
|
||||||
virtual AdminMessageHandleResult handleAdminMessageForPlugin(
|
virtual AdminMessageHandleResult handleAdminMessageForModule(
|
||||||
const MeshPacket &mp, AdminMessage *request, AdminMessage *response) override;
|
const MeshPacket &mp, AdminMessage *request, AdminMessage *response) override;
|
||||||
|
|
||||||
void loadProtoForPlugin();
|
void loadProtoForModule();
|
||||||
bool saveProtoForPlugin();
|
bool saveProtoForModule();
|
||||||
|
|
||||||
void installDefaultCannedMessageModuleConfig();
|
void installDefaultCannedMessageModuleConfig();
|
||||||
|
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Enable development more for StoreForwardPlugin
|
// Enable development more for StoreForwardModule
|
||||||
bool StoreForward_Dev = false;
|
bool StoreForward_Dev = false;
|
@ -25,21 +25,21 @@
|
|||||||
void setupModules()
|
void setupModules()
|
||||||
{
|
{
|
||||||
inputBroker = new InputBroker();
|
inputBroker = new InputBroker();
|
||||||
adminPlugin = new AdminPlugin();
|
adminModule = new AdminModule();
|
||||||
nodeInfoPlugin = new NodeInfoPlugin();
|
nodeInfoModule = new NodeInfoModule();
|
||||||
positionPlugin = new PositionPlugin();
|
positionModule = new PositionModule();
|
||||||
textMessagePlugin = new TextMessagePlugin();
|
textMessageModule = new TextMessageModule();
|
||||||
|
|
||||||
// Note: if the rest of meshtastic doesn't need to explicitly use your module, you do not need to assign the instance
|
// Note: if the rest of meshtastic doesn't need to explicitly use your module, you do not need to assign the instance
|
||||||
// to a global variable.
|
// to a global variable.
|
||||||
|
|
||||||
new RemoteHardwarePlugin();
|
new RemoteHardwareModule();
|
||||||
new ReplyPlugin();
|
new ReplyModule();
|
||||||
rotaryEncoderInterruptImpl1 = new RotaryEncoderInterruptImpl1();
|
rotaryEncoderInterruptImpl1 = new RotaryEncoderInterruptImpl1();
|
||||||
rotaryEncoderInterruptImpl1->init();
|
rotaryEncoderInterruptImpl1->init();
|
||||||
cannedMessageModule = new CannedMessageModule();
|
cannedMessageModule = new CannedMessageModule();
|
||||||
#ifndef PORTDUINO
|
#ifndef PORTDUINO
|
||||||
new TelemetryPlugin();
|
new TelemetryModule();
|
||||||
#endif
|
#endif
|
||||||
#ifndef NO_ESP32
|
#ifndef NO_ESP32
|
||||||
// Only run on an esp32 based device.
|
// Only run on an esp32 based device.
|
||||||
@ -47,15 +47,14 @@ void setupModules()
|
|||||||
/*
|
/*
|
||||||
Maintained by MC Hamster (Jm Casler) jm@casler.org
|
Maintained by MC Hamster (Jm Casler) jm@casler.org
|
||||||
*/
|
*/
|
||||||
new SerialPlugin();
|
new SerialModule();
|
||||||
new ExternalNotificationModule();
|
new ExternalNotificationModule();
|
||||||
|
|
||||||
storeForwardPlugin = new StoreForwardPlugin();
|
storeForwardModule = new StoreForwardModule();
|
||||||
|
|
||||||
new RangeTestModule();
|
new RangeTestModule();
|
||||||
// new StoreForwardPlugin();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra acks
|
// NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra acks
|
||||||
routingPlugin = new RoutingPlugin();
|
routingModule = new RoutingModule();
|
||||||
}
|
}
|
@ -6,9 +6,9 @@
|
|||||||
#include "Router.h"
|
#include "Router.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
NodeInfoPlugin *nodeInfoPlugin;
|
NodeInfoModule *nodeInfoModule;
|
||||||
|
|
||||||
bool NodeInfoPlugin::handleReceivedProtobuf(const MeshPacket &mp, User *pptr)
|
bool NodeInfoModule::handleReceivedProtobuf(const MeshPacket &mp, User *pptr)
|
||||||
{
|
{
|
||||||
auto p = *pptr;
|
auto p = *pptr;
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ bool NodeInfoPlugin::handleReceivedProtobuf(const MeshPacket &mp, User *pptr)
|
|||||||
return false; // Let others look at this message also if they want
|
return false; // Let others look at this message also if they want
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeInfoPlugin::sendOurNodeInfo(NodeNum dest, bool wantReplies)
|
void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies)
|
||||||
{
|
{
|
||||||
// cancel any not yet sent (now stale) position packets
|
// cancel any not yet sent (now stale) position packets
|
||||||
if (prevPacketId) // if we wrap around to zero, we'll simply fail to cancel in that rare case (no big deal)
|
if (prevPacketId) // if we wrap around to zero, we'll simply fail to cancel in that rare case (no big deal)
|
||||||
@ -42,7 +42,7 @@ void NodeInfoPlugin::sendOurNodeInfo(NodeNum dest, bool wantReplies)
|
|||||||
service.sendToMesh(p);
|
service.sendToMesh(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshPacket *NodeInfoPlugin::allocReply()
|
MeshPacket *NodeInfoModule::allocReply()
|
||||||
{
|
{
|
||||||
User &u = owner;
|
User &u = owner;
|
||||||
|
|
||||||
@ -50,15 +50,15 @@ MeshPacket *NodeInfoPlugin::allocReply()
|
|||||||
return allocDataProtobuf(u);
|
return allocDataProtobuf(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeInfoPlugin::NodeInfoPlugin()
|
NodeInfoModule::NodeInfoModule()
|
||||||
: ProtobufPlugin("nodeinfo", PortNum_NODEINFO_APP, User_fields), concurrency::OSThread("NodeInfoPlugin")
|
: ProtobufPlugin("nodeinfo", PortNum_NODEINFO_APP, User_fields), concurrency::OSThread("NodeInfoModule")
|
||||||
{
|
{
|
||||||
isPromiscuous = true; // We always want to update our nodedb, even if we are sniffing on others
|
isPromiscuous = true; // We always want to update our nodedb, even if we are sniffing on others
|
||||||
setIntervalFromNow(30 *
|
setIntervalFromNow(30 *
|
||||||
1000); // Send our initial owner announcement 30 seconds after we start (to give network time to setup)
|
1000); // Send our initial owner announcement 30 seconds after we start (to give network time to setup)
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t NodeInfoPlugin::runOnce()
|
int32_t NodeInfoModule::runOnce()
|
||||||
{
|
{
|
||||||
static uint32_t currentGeneration;
|
static uint32_t currentGeneration;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
/**
|
/**
|
||||||
* NodeInfo module for sending/receiving NodeInfos into the mesh
|
* NodeInfo module for sending/receiving NodeInfos into the mesh
|
||||||
*/
|
*/
|
||||||
class NodeInfoPlugin : public ProtobufPlugin<User>, private concurrency::OSThread
|
class NodeInfoModule : public ProtobufPlugin<User>, private concurrency::OSThread
|
||||||
{
|
{
|
||||||
/// The id of the last packet we sent, to allow us to cancel it if we make something fresher
|
/// The id of the last packet we sent, to allow us to cancel it if we make something fresher
|
||||||
PacketId prevPacketId = 0;
|
PacketId prevPacketId = 0;
|
||||||
@ -14,7 +14,7 @@ class NodeInfoPlugin : public ProtobufPlugin<User>, private concurrency::OSThrea
|
|||||||
/** Constructor
|
/** Constructor
|
||||||
* name is for debugging output
|
* name is for debugging output
|
||||||
*/
|
*/
|
||||||
NodeInfoPlugin();
|
NodeInfoModule();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send our NodeInfo into the mesh
|
* Send our NodeInfo into the mesh
|
||||||
@ -36,4 +36,4 @@ class NodeInfoPlugin : public ProtobufPlugin<User>, private concurrency::OSThrea
|
|||||||
virtual int32_t runOnce() override;
|
virtual int32_t runOnce() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern NodeInfoPlugin *nodeInfoPlugin;
|
extern NodeInfoModule *nodeInfoModule;
|
||||||
|
@ -7,16 +7,16 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "gps/GeoCoord.h"
|
#include "gps/GeoCoord.h"
|
||||||
|
|
||||||
PositionPlugin *positionPlugin;
|
PositionModule *positionModule;
|
||||||
|
|
||||||
PositionPlugin::PositionPlugin()
|
PositionModule::PositionModule()
|
||||||
: ProtobufPlugin("position", PortNum_POSITION_APP, Position_fields), concurrency::OSThread("PositionPlugin")
|
: ProtobufPlugin("position", PortNum_POSITION_APP, Position_fields), concurrency::OSThread("PositionModule")
|
||||||
{
|
{
|
||||||
isPromiscuous = true; // We always want to update our nodedb, even if we are sniffing on others
|
isPromiscuous = true; // We always want to update our nodedb, even if we are sniffing on others
|
||||||
setIntervalFromNow(60 * 1000); // Send our initial position 60 seconds after we start (to give GPS time to setup)
|
setIntervalFromNow(60 * 1000); // Send our initial position 60 seconds after we start (to give GPS time to setup)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PositionPlugin::handleReceivedProtobuf(const MeshPacket &mp, Position *pptr)
|
bool PositionModule::handleReceivedProtobuf(const MeshPacket &mp, Position *pptr)
|
||||||
{
|
{
|
||||||
auto p = *pptr;
|
auto p = *pptr;
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ bool PositionPlugin::handleReceivedProtobuf(const MeshPacket &mp, Position *pptr
|
|||||||
return false; // Let others look at this message also if they want
|
return false; // Let others look at this message also if they want
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshPacket *PositionPlugin::allocReply()
|
MeshPacket *PositionModule::allocReply()
|
||||||
{
|
{
|
||||||
NodeInfo *node = service.refreshMyNodeInfo(); // should guarantee there is now a position
|
NodeInfo *node = service.refreshMyNodeInfo(); // should guarantee there is now a position
|
||||||
assert(node->has_position);
|
assert(node->has_position);
|
||||||
@ -109,7 +109,7 @@ MeshPacket *PositionPlugin::allocReply()
|
|||||||
return allocDataProtobuf(p);
|
return allocDataProtobuf(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PositionPlugin::sendOurPosition(NodeNum dest, bool wantReplies)
|
void PositionModule::sendOurPosition(NodeNum dest, bool wantReplies)
|
||||||
{
|
{
|
||||||
// cancel any not yet sent (now stale) position packets
|
// cancel any not yet sent (now stale) position packets
|
||||||
if (prevPacketId) // if we wrap around to zero, we'll simply fail to cancel in that rare case (no big deal)
|
if (prevPacketId) // if we wrap around to zero, we'll simply fail to cancel in that rare case (no big deal)
|
||||||
@ -124,7 +124,7 @@ void PositionPlugin::sendOurPosition(NodeNum dest, bool wantReplies)
|
|||||||
service.sendToMesh(p);
|
service.sendToMesh(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t PositionPlugin::runOnce()
|
int32_t PositionModule::runOnce()
|
||||||
{
|
{
|
||||||
NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum());
|
NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum());
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
/**
|
/**
|
||||||
* Position module for sending/receiving positions into the mesh
|
* Position module for sending/receiving positions into the mesh
|
||||||
*/
|
*/
|
||||||
class PositionPlugin : public ProtobufPlugin<Position>, private concurrency::OSThread
|
class PositionModule : public ProtobufPlugin<Position>, private concurrency::OSThread
|
||||||
{
|
{
|
||||||
/// The id of the last packet we sent, to allow us to cancel it if we make something fresher
|
/// The id of the last packet we sent, to allow us to cancel it if we make something fresher
|
||||||
PacketId prevPacketId = 0;
|
PacketId prevPacketId = 0;
|
||||||
@ -24,7 +24,7 @@ class PositionPlugin : public ProtobufPlugin<Position>, private concurrency::OST
|
|||||||
/** Constructor
|
/** Constructor
|
||||||
* name is for debugging output
|
* name is for debugging output
|
||||||
*/
|
*/
|
||||||
PositionPlugin();
|
PositionModule();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send our position into the mesh
|
* Send our position into the mesh
|
||||||
@ -47,4 +47,4 @@ class PositionPlugin : public ProtobufPlugin<Position>, private concurrency::OST
|
|||||||
virtual int32_t runOnce() override;
|
virtual int32_t runOnce() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern PositionPlugin *positionPlugin;
|
extern PositionModule *positionModule;
|
||||||
|
@ -46,13 +46,13 @@ static uint64_t digitalReads(uint64_t mask)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteHardwarePlugin::RemoteHardwarePlugin()
|
RemoteHardwareModule::RemoteHardwareModule()
|
||||||
: ProtobufPlugin("remotehardware", PortNum_REMOTE_HARDWARE_APP, HardwareMessage_fields), concurrency::OSThread(
|
: ProtobufPlugin("remotehardware", PortNum_REMOTE_HARDWARE_APP, HardwareMessage_fields), concurrency::OSThread(
|
||||||
"remotehardware")
|
"remotehardware")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemoteHardwarePlugin::handleReceivedProtobuf(const MeshPacket &req, HardwareMessage *pptr)
|
bool RemoteHardwareModule::handleReceivedProtobuf(const MeshPacket &req, HardwareMessage *pptr)
|
||||||
{
|
{
|
||||||
auto p = *pptr;
|
auto p = *pptr;
|
||||||
DEBUG_MSG("Received RemoteHardware typ=%d\n", p.typ);
|
DEBUG_MSG("Received RemoteHardware typ=%d\n", p.typ);
|
||||||
@ -111,7 +111,7 @@ bool RemoteHardwarePlugin::handleReceivedProtobuf(const MeshPacket &req, Hardwar
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t RemoteHardwarePlugin::runOnce()
|
int32_t RemoteHardwareModule::runOnce()
|
||||||
{
|
{
|
||||||
if (watchGpios) {
|
if (watchGpios) {
|
||||||
uint32_t now = millis();
|
uint32_t now = millis();
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/**
|
/**
|
||||||
* A module that provides easy low-level remote access to device hardware.
|
* A module that provides easy low-level remote access to device hardware.
|
||||||
*/
|
*/
|
||||||
class RemoteHardwarePlugin : public ProtobufPlugin<HardwareMessage>, private concurrency::OSThread
|
class RemoteHardwareModule : public ProtobufPlugin<HardwareMessage>, private concurrency::OSThread
|
||||||
{
|
{
|
||||||
/// The current set of GPIOs we've been asked to watch for changes
|
/// The current set of GPIOs we've been asked to watch for changes
|
||||||
uint64_t watchGpios = 0;
|
uint64_t watchGpios = 0;
|
||||||
@ -20,7 +20,7 @@ class RemoteHardwarePlugin : public ProtobufPlugin<HardwareMessage>, private con
|
|||||||
/** Constructor
|
/** Constructor
|
||||||
* name is for debugging output
|
* name is for debugging output
|
||||||
*/
|
*/
|
||||||
RemoteHardwarePlugin();
|
RemoteHardwareModule();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Called to handle a particular incoming message
|
/** Called to handle a particular incoming message
|
||||||
@ -40,4 +40,4 @@ class RemoteHardwarePlugin : public ProtobufPlugin<HardwareMessage>, private con
|
|||||||
virtual int32_t runOnce() override;
|
virtual int32_t runOnce() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern RemoteHardwarePlugin remoteHardwarePlugin;
|
extern RemoteHardwareModule remoteHardwareModule;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
MeshPacket *ReplyPlugin::allocReply()
|
MeshPacket *ReplyModule::allocReply()
|
||||||
{
|
{
|
||||||
assert(currentRequest); // should always be !NULL
|
assert(currentRequest); // should always be !NULL
|
||||||
auto req = *currentRequest;
|
auto req = *currentRequest;
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
/**
|
/**
|
||||||
* A simple example module that just replies with "Message received" to any message it receives.
|
* A simple example module that just replies with "Message received" to any message it receives.
|
||||||
*/
|
*/
|
||||||
class ReplyPlugin : public SinglePortPlugin
|
class ReplyModule : public SinglePortPlugin
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Constructor
|
/** Constructor
|
||||||
* name is for debugging output
|
* name is for debugging output
|
||||||
*/
|
*/
|
||||||
ReplyPlugin() : SinglePortPlugin("reply", PortNum_REPLY_APP) {}
|
ReplyModule() : SinglePortPlugin("reply", PortNum_REPLY_APP) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
#include "Router.h"
|
#include "Router.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
RoutingPlugin *routingPlugin;
|
RoutingModule *routingModule;
|
||||||
|
|
||||||
bool RoutingPlugin::handleReceivedProtobuf(const MeshPacket &mp, Routing *r)
|
bool RoutingModule::handleReceivedProtobuf(const MeshPacket &mp, Routing *r)
|
||||||
{
|
{
|
||||||
printPacket("Routing sniffing", &mp);
|
printPacket("Routing sniffing", &mp);
|
||||||
router->sniffReceived(&mp, r);
|
router->sniffReceived(&mp, r);
|
||||||
@ -22,7 +22,7 @@ bool RoutingPlugin::handleReceivedProtobuf(const MeshPacket &mp, Routing *r)
|
|||||||
return false; // Let others look at this message also if they want
|
return false; // Let others look at this message also if they want
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshPacket *RoutingPlugin::allocReply()
|
MeshPacket *RoutingModule::allocReply()
|
||||||
{
|
{
|
||||||
assert(currentRequest);
|
assert(currentRequest);
|
||||||
|
|
||||||
@ -34,14 +34,14 @@ MeshPacket *RoutingPlugin::allocReply()
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RoutingPlugin::sendAckNak(Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex)
|
void RoutingModule::sendAckNak(Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex)
|
||||||
{
|
{
|
||||||
auto p = allocAckNak(err, to, idFrom, chIndex);
|
auto p = allocAckNak(err, to, idFrom, chIndex);
|
||||||
|
|
||||||
router->sendLocal(p); // we sometimes send directly to the local node
|
router->sendLocal(p); // we sometimes send directly to the local node
|
||||||
}
|
}
|
||||||
|
|
||||||
RoutingPlugin::RoutingPlugin() : ProtobufPlugin("routing", PortNum_ROUTING_APP, Routing_fields)
|
RoutingModule::RoutingModule() : ProtobufPlugin("routing", PortNum_ROUTING_APP, Routing_fields)
|
||||||
{
|
{
|
||||||
isPromiscuous = true;
|
isPromiscuous = true;
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
/**
|
/**
|
||||||
* Routing module for router control messages
|
* Routing module for router control messages
|
||||||
*/
|
*/
|
||||||
class RoutingPlugin : public ProtobufPlugin<Routing>
|
class RoutingModule : public ProtobufPlugin<Routing>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Constructor
|
/** Constructor
|
||||||
* name is for debugging output
|
* name is for debugging output
|
||||||
*/
|
*/
|
||||||
RoutingPlugin();
|
RoutingModule();
|
||||||
|
|
||||||
void sendAckNak(Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex);
|
void sendAckNak(Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex);
|
||||||
|
|
||||||
@ -32,4 +32,4 @@ class RoutingPlugin : public ProtobufPlugin<Routing>
|
|||||||
virtual bool wantPacket(const MeshPacket *p) override { return true; }
|
virtual bool wantPacket(const MeshPacket *p) override { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
extern RoutingPlugin *routingPlugin;
|
extern RoutingModule *routingModule;
|
||||||
|
@ -42,7 +42,7 @@ MCP9808Sensor mcp9808Sensor;
|
|||||||
#define FONT_HEIGHT_MEDIUM fontHeight(FONT_MEDIUM)
|
#define FONT_HEIGHT_MEDIUM fontHeight(FONT_MEDIUM)
|
||||||
|
|
||||||
|
|
||||||
int32_t TelemetryPlugin::runOnce()
|
int32_t TelemetryModule::runOnce()
|
||||||
{
|
{
|
||||||
#ifndef PORTDUINO
|
#ifndef PORTDUINO
|
||||||
/*
|
/*
|
||||||
@ -155,7 +155,7 @@ int32_t TelemetryPlugin::runOnce()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TelemetryPlugin::wantUIFrame()
|
bool TelemetryModule::wantUIFrame()
|
||||||
{
|
{
|
||||||
return radioConfig.preferences.telemetry_module_screen_enabled;
|
return radioConfig.preferences.telemetry_module_screen_enabled;
|
||||||
}
|
}
|
||||||
@ -185,12 +185,12 @@ uint32_t GetTimeSinceMeshPacket(const MeshPacket *mp)
|
|||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
float TelemetryPlugin::CelsiusToFarenheit(float c)
|
float TelemetryModule::CelsiusToFarenheit(float c)
|
||||||
{
|
{
|
||||||
return (c * 9) / 5 + 32;
|
return (c * 9) / 5 + 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPlugin::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
void TelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
{
|
{
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(FONT_MEDIUM);
|
display->setFont(FONT_MEDIUM);
|
||||||
@ -225,7 +225,7 @@ void TelemetryPlugin::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state,
|
|||||||
display->drawString(x, y += fontHeight(FONT_SMALL),"Press: " + String(lastMeasurement.barometric_pressure, 0) + "hPA");
|
display->drawString(x, y += fontHeight(FONT_SMALL),"Press: " + String(lastMeasurement.barometric_pressure, 0) + "hPA");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TelemetryPlugin::handleReceivedProtobuf(const MeshPacket &mp, Telemetry *p)
|
bool TelemetryModule::handleReceivedProtobuf(const MeshPacket &mp, Telemetry *p)
|
||||||
{
|
{
|
||||||
if (!(radioConfig.preferences.telemetry_module_measurement_enabled ||
|
if (!(radioConfig.preferences.telemetry_module_measurement_enabled ||
|
||||||
radioConfig.preferences.telemetry_module_screen_enabled)) {
|
radioConfig.preferences.telemetry_module_screen_enabled)) {
|
||||||
@ -246,7 +246,7 @@ bool TelemetryPlugin::handleReceivedProtobuf(const MeshPacket &mp, Telemetry *p)
|
|||||||
return false; // Let others look at this message also if they want
|
return false; // Let others look at this message also if they want
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TelemetryPlugin::sendOurTelemetry(NodeNum dest, bool wantReplies)
|
bool TelemetryModule::sendOurTelemetry(NodeNum dest, bool wantReplies)
|
||||||
{
|
{
|
||||||
Telemetry m;
|
Telemetry m;
|
||||||
m.barometric_pressure = 0;
|
m.barometric_pressure = 0;
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
#include <OLEDDisplay.h>
|
#include <OLEDDisplay.h>
|
||||||
#include <OLEDDisplayUi.h>
|
#include <OLEDDisplayUi.h>
|
||||||
|
|
||||||
class TelemetryPlugin : private concurrency::OSThread, public ProtobufPlugin<Telemetry>
|
class TelemetryModule : private concurrency::OSThread, public ProtobufPlugin<Telemetry>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TelemetryPlugin()
|
TelemetryModule()
|
||||||
: concurrency::OSThread("TelemetryPlugin"),
|
: concurrency::OSThread("TelemetryModule"),
|
||||||
ProtobufPlugin("Telemetry", PortNum_TELEMETRY_APP, &Telemetry_msg)
|
ProtobufPlugin("Telemetry", PortNum_TELEMETRY_APP, &Telemetry_msg)
|
||||||
{
|
{
|
||||||
lastMeasurementPacket = nullptr;
|
lastMeasurementPacket = nullptr;
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "PowerFSM.h"
|
#include "PowerFSM.h"
|
||||||
|
|
||||||
TextMessagePlugin *textMessagePlugin;
|
TextMessageModule *textMessageModule;
|
||||||
|
|
||||||
ProcessMessage TextMessagePlugin::handleReceived(const MeshPacket &mp)
|
ProcessMessage TextMessageModule::handleReceived(const MeshPacket &mp)
|
||||||
{
|
{
|
||||||
auto &p = mp.decoded;
|
auto &p = mp.decoded;
|
||||||
DEBUG_MSG("Received text msg from=0x%0x, id=0x%x, msg=%.*s\n", mp.from, mp.id, p.payload.size, p.payload.bytes);
|
DEBUG_MSG("Received text msg from=0x%0x, id=0x%x, msg=%.*s\n", mp.from, mp.id, p.payload.size, p.payload.bytes);
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
/**
|
/**
|
||||||
* Text message handling for meshtastic - draws on the OLED display the most recent received message
|
* Text message handling for meshtastic - draws on the OLED display the most recent received message
|
||||||
*/
|
*/
|
||||||
class TextMessagePlugin : public SinglePortPlugin, public Observable<const MeshPacket *>
|
class TextMessageModule : public SinglePortPlugin, public Observable<const MeshPacket *>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Constructor
|
/** Constructor
|
||||||
* name is for debugging output
|
* name is for debugging output
|
||||||
*/
|
*/
|
||||||
TextMessagePlugin() : SinglePortPlugin("text", PortNum_TEXT_MESSAGE_APP) {}
|
TextMessageModule() : SinglePortPlugin("text", PortNum_TEXT_MESSAGE_APP) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -22,4 +22,4 @@ class TextMessagePlugin : public SinglePortPlugin, public Observable<const MeshP
|
|||||||
virtual ProcessMessage handleReceived(const MeshPacket &mp) override;
|
virtual ProcessMessage handleReceived(const MeshPacket &mp) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern TextMessagePlugin *textMessagePlugin;
|
extern TextMessageModule *textMessageModule;
|
||||||
|
@ -64,7 +64,7 @@ int32_t RangeTestModule::runOnce()
|
|||||||
|
|
||||||
if (radioConfig.preferences.range_test_module_sender) {
|
if (radioConfig.preferences.range_test_module_sender) {
|
||||||
// If sender
|
// If sender
|
||||||
DEBUG_MSG("Range Test Plugin - Sending heartbeat every %d ms\n", (senderHeartbeat));
|
DEBUG_MSG("Range Test Module - Sending heartbeat every %d ms\n", (senderHeartbeat));
|
||||||
|
|
||||||
DEBUG_MSG("gpsStatus->getLatitude() %d\n", gpsStatus->getLatitude());
|
DEBUG_MSG("gpsStatus->getLatitude() %d\n", gpsStatus->getLatitude());
|
||||||
DEBUG_MSG("gpsStatus->getLongitude() %d\n", gpsStatus->getLongitude());
|
DEBUG_MSG("gpsStatus->getLongitude() %d\n", gpsStatus->getLongitude());
|
||||||
@ -90,7 +90,7 @@ int32_t RangeTestModule::runOnce()
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Range Test Plugin - Disabled\n");
|
DEBUG_MSG("Range Test Module - Disabled\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -175,7 +175,7 @@ ProcessMessage RangeTestModuleRadio::handleReceived(const MeshPacket &mp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Range Test Plugin Disabled\n");
|
DEBUG_MSG("Range Test Module Disabled\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SerialPlugin
|
SerialModule
|
||||||
A simple interface to send messages over the mesh network by sending strings
|
A simple interface to send messages over the mesh network by sending strings
|
||||||
over a serial port.
|
over a serial port.
|
||||||
|
|
||||||
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
Basic Usage:
|
Basic Usage:
|
||||||
|
|
||||||
1) Enable the module by setting serialplugin_enabled to 1.
|
1) Enable the module by setting serialmodule_enabled to 1.
|
||||||
2) Set the pins (serialmodule_rxd / serialmodule_rxd) for your preferred RX and TX GPIO pins.
|
2) Set the pins (serialmodule_rxd / serialmodule_rxd) for your preferred RX and TX GPIO pins.
|
||||||
On tbeam, recommend to use:
|
On tbeam, recommend to use:
|
||||||
RXD 35
|
RXD 35
|
||||||
@ -54,20 +54,20 @@
|
|||||||
#define SERIALMODULE_BAUD 38400
|
#define SERIALMODULE_BAUD 38400
|
||||||
#define SERIALMODULE_ACK 1
|
#define SERIALMODULE_ACK 1
|
||||||
|
|
||||||
SerialPlugin *serialPlugin;
|
SerialModule *serialModule;
|
||||||
SerialPluginRadio *serialPluginRadio;
|
SerialModuleRadio *serialModuleRadio;
|
||||||
|
|
||||||
SerialPlugin::SerialPlugin() : concurrency::OSThread("SerialPlugin") {}
|
SerialModule::SerialModule() : concurrency::OSThread("SerialModule") {}
|
||||||
|
|
||||||
char serialStringChar[Constants_DATA_PAYLOAD_LEN];
|
char serialStringChar[Constants_DATA_PAYLOAD_LEN];
|
||||||
|
|
||||||
SerialPluginRadio::SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_SERIAL_APP)
|
SerialModuleRadio::SerialModuleRadio() : SinglePortPlugin("SerialModuleRadio", PortNum_SERIAL_APP)
|
||||||
{
|
{
|
||||||
// restrict to the admin channel for rx
|
// restrict to the admin channel for rx
|
||||||
boundChannel = Channels::serialChannel;
|
boundChannel = Channels::serialChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t SerialPlugin::runOnce()
|
int32_t SerialModule::runOnce()
|
||||||
{
|
{
|
||||||
#ifndef NO_ESP32
|
#ifndef NO_ESP32
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ int32_t SerialPlugin::runOnce()
|
|||||||
|
|
||||||
Serial2.setRxBufferSize(SERIALMODULE_RX_BUFFER);
|
Serial2.setRxBufferSize(SERIALMODULE_RX_BUFFER);
|
||||||
|
|
||||||
serialPluginRadio = new SerialPluginRadio();
|
serialModuleRadio = new SerialModuleRadio();
|
||||||
|
|
||||||
firstTime = 0;
|
firstTime = 0;
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ int32_t SerialPlugin::runOnce()
|
|||||||
serialString = Serial2.readString();
|
serialString = Serial2.readString();
|
||||||
serialString.toCharArray(serialStringChar, Constants_DATA_PAYLOAD_LEN);
|
serialString.toCharArray(serialStringChar, Constants_DATA_PAYLOAD_LEN);
|
||||||
|
|
||||||
serialPluginRadio->sendPayload();
|
serialModuleRadio->sendPayload();
|
||||||
|
|
||||||
DEBUG_MSG("Received: %s\n", serialStringChar);
|
DEBUG_MSG("Received: %s\n", serialStringChar);
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ int32_t SerialPlugin::runOnce()
|
|||||||
|
|
||||||
return (10);
|
return (10);
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Serial Plugin Disabled\n");
|
DEBUG_MSG("Serial Module Disabled\n");
|
||||||
|
|
||||||
return (INT32_MAX);
|
return (INT32_MAX);
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ int32_t SerialPlugin::runOnce()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshPacket *SerialPluginRadio::allocReply()
|
MeshPacket *SerialModuleRadio::allocReply()
|
||||||
{
|
{
|
||||||
|
|
||||||
auto reply = allocDataPacket(); // Allocate a packet for sending
|
auto reply = allocDataPacket(); // Allocate a packet for sending
|
||||||
@ -143,7 +143,7 @@ MeshPacket *SerialPluginRadio::allocReply()
|
|||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SerialPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
|
void SerialModuleRadio::sendPayload(NodeNum dest, bool wantReplies)
|
||||||
{
|
{
|
||||||
MeshPacket *p = allocReply();
|
MeshPacket *p = allocReply();
|
||||||
p->to = dest;
|
p->to = dest;
|
||||||
@ -157,7 +157,7 @@ void SerialPluginRadio::sendPayload(NodeNum dest, bool wantReplies)
|
|||||||
service.sendToMesh(p);
|
service.sendToMesh(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessMessage SerialPluginRadio::handleReceived(const MeshPacket &mp)
|
ProcessMessage SerialModuleRadio::handleReceived(const MeshPacket &mp)
|
||||||
{
|
{
|
||||||
#ifndef NO_ESP32
|
#ifndef NO_ESP32
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ ProcessMessage SerialPluginRadio::handleReceived(const MeshPacket &mp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Serial Plugin Disabled\n");
|
DEBUG_MSG("Serial Module Disabled\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,24 +6,24 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
class SerialPlugin : private concurrency::OSThread
|
class SerialModule : private concurrency::OSThread
|
||||||
{
|
{
|
||||||
bool firstTime = 1;
|
bool firstTime = 1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SerialPlugin();
|
SerialModule();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int32_t runOnce() override;
|
virtual int32_t runOnce() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern SerialPlugin *serialPlugin;
|
extern SerialModule *serialModule;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Radio interface for SerialPlugin
|
* Radio interface for SerialModule
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class SerialPluginRadio : public SinglePortPlugin
|
class SerialModuleRadio : public SinglePortPlugin
|
||||||
{
|
{
|
||||||
uint32_t lastRxID = 0;
|
uint32_t lastRxID = 0;
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ class SerialPluginRadio : public SinglePortPlugin
|
|||||||
from the main code.
|
from the main code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SerialPluginRadio();
|
SerialModuleRadio();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send our payload into the mesh
|
* Send our payload into the mesh
|
||||||
@ -50,4 +50,4 @@ class SerialPluginRadio : public SinglePortPlugin
|
|||||||
virtual ProcessMessage handleReceived(const MeshPacket &mp) override;
|
virtual ProcessMessage handleReceived(const MeshPacket &mp) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern SerialPluginRadio *serialPluginRadio;
|
extern SerialModuleRadio *serialModuleRadio;
|
||||||
|
@ -12,9 +12,9 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
StoreForwardPlugin *storeForwardPlugin;
|
StoreForwardModule *storeForwardModule;
|
||||||
|
|
||||||
int32_t StoreForwardPlugin::runOnce()
|
int32_t StoreForwardModule::runOnce()
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifndef NO_ESP32
|
||||||
@ -31,11 +31,11 @@ int32_t StoreForwardPlugin::runOnce()
|
|||||||
if (airTime->channelUtilizationPercent() < 25) {
|
if (airTime->channelUtilizationPercent() < 25) {
|
||||||
|
|
||||||
// DEBUG_MSG("--- --- --- In busy loop 1 %d\n", this->packetHistoryTXQueue_index);
|
// DEBUG_MSG("--- --- --- In busy loop 1 %d\n", this->packetHistoryTXQueue_index);
|
||||||
storeForwardPlugin->sendPayload(this->busyTo, this->packetHistoryTXQueue_index);
|
storeForwardModule->sendPayload(this->busyTo, this->packetHistoryTXQueue_index);
|
||||||
|
|
||||||
if (this->packetHistoryTXQueue_index == packetHistoryTXQueue_size) {
|
if (this->packetHistoryTXQueue_index == packetHistoryTXQueue_size) {
|
||||||
strcpy(this->routerMessage, "** S&F - Done");
|
strcpy(this->routerMessage, "** S&F - Done");
|
||||||
storeForwardPlugin->sendMessage(this->busyTo, this->routerMessage);
|
storeForwardModule->sendMessage(this->busyTo, this->routerMessage);
|
||||||
|
|
||||||
// DEBUG_MSG("--- --- --- In busy loop - Done \n");
|
// DEBUG_MSG("--- --- --- In busy loop - Done \n");
|
||||||
this->packetHistoryTXQueue_index = 0;
|
this->packetHistoryTXQueue_index = 0;
|
||||||
@ -52,13 +52,13 @@ int32_t StoreForwardPlugin::runOnce()
|
|||||||
|
|
||||||
return (this->packetTimeMax);
|
return (this->packetTimeMax);
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Store & Forward Plugin - Disabled (is_router = false)\n");
|
DEBUG_MSG("Store & Forward Module - Disabled (is_router = false)\n");
|
||||||
|
|
||||||
return (INT32_MAX);
|
return (INT32_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Store & Forward Plugin - Disabled\n");
|
DEBUG_MSG("Store & Forward Module - Disabled\n");
|
||||||
|
|
||||||
return (INT32_MAX);
|
return (INT32_MAX);
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ int32_t StoreForwardPlugin::runOnce()
|
|||||||
/*
|
/*
|
||||||
Create our data structure in the PSRAM.
|
Create our data structure in the PSRAM.
|
||||||
*/
|
*/
|
||||||
void StoreForwardPlugin::populatePSRAM()
|
void StoreForwardModule::populatePSRAM()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
For PSRAM usage, see:
|
For PSRAM usage, see:
|
||||||
@ -104,7 +104,7 @@ void StoreForwardPlugin::populatePSRAM()
|
|||||||
DEBUG_MSG(" numberOfPackets for packetHistory - %u\n", numberOfPackets);
|
DEBUG_MSG(" numberOfPackets for packetHistory - %u\n", numberOfPackets);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StoreForwardPlugin::historyReport()
|
void StoreForwardModule::historyReport()
|
||||||
{
|
{
|
||||||
DEBUG_MSG("Iterating through the message history...\n");
|
DEBUG_MSG("Iterating through the message history...\n");
|
||||||
DEBUG_MSG("Message history contains %u records\n", this->packetHistoryCurrent);
|
DEBUG_MSG("Message history contains %u records\n", this->packetHistoryCurrent);
|
||||||
@ -113,27 +113,27 @@ void StoreForwardPlugin::historyReport()
|
|||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void StoreForwardPlugin::historySend(uint32_t msAgo, uint32_t to)
|
void StoreForwardModule::historySend(uint32_t msAgo, uint32_t to)
|
||||||
{
|
{
|
||||||
|
|
||||||
// uint32_t packetsSent = 0;
|
// uint32_t packetsSent = 0;
|
||||||
|
|
||||||
uint32_t queueSize = storeForwardPlugin->historyQueueCreate(msAgo, to);
|
uint32_t queueSize = storeForwardModule->historyQueueCreate(msAgo, to);
|
||||||
|
|
||||||
if (queueSize) {
|
if (queueSize) {
|
||||||
snprintf(this->routerMessage, 80, "** S&F - Sending %u message(s)", queueSize);
|
snprintf(this->routerMessage, 80, "** S&F - Sending %u message(s)", queueSize);
|
||||||
storeForwardPlugin->sendMessage(to, this->routerMessage);
|
storeForwardModule->sendMessage(to, this->routerMessage);
|
||||||
|
|
||||||
this->busy = true; // runOnce() will pickup the next steps once busy = true.
|
this->busy = true; // runOnce() will pickup the next steps once busy = true.
|
||||||
this->busyTo = to;
|
this->busyTo = to;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
strcpy(this->routerMessage, "** S&F - No history to send");
|
strcpy(this->routerMessage, "** S&F - No history to send");
|
||||||
storeForwardPlugin->sendMessage(to, this->routerMessage);
|
storeForwardModule->sendMessage(to, this->routerMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t StoreForwardPlugin::historyQueueCreate(uint32_t msAgo, uint32_t to)
|
uint32_t StoreForwardModule::historyQueueCreate(uint32_t msAgo, uint32_t to)
|
||||||
{
|
{
|
||||||
|
|
||||||
// uint32_t packetHistoryTXQueueIndex = 0;
|
// uint32_t packetHistoryTXQueueIndex = 0;
|
||||||
@ -177,7 +177,7 @@ uint32_t StoreForwardPlugin::historyQueueCreate(uint32_t msAgo, uint32_t to)
|
|||||||
return this->packetHistoryTXQueue_size;
|
return this->packetHistoryTXQueue_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StoreForwardPlugin::historyAdd(const MeshPacket &mp)
|
void StoreForwardModule::historyAdd(const MeshPacket &mp)
|
||||||
{
|
{
|
||||||
const auto &p = mp.decoded;
|
const auto &p = mp.decoded;
|
||||||
|
|
||||||
@ -191,13 +191,13 @@ void StoreForwardPlugin::historyAdd(const MeshPacket &mp)
|
|||||||
this->packetHistoryCurrent++;
|
this->packetHistoryCurrent++;
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshPacket *StoreForwardPlugin::allocReply()
|
MeshPacket *StoreForwardModule::allocReply()
|
||||||
{
|
{
|
||||||
auto reply = allocDataPacket(); // Allocate a packet for sending
|
auto reply = allocDataPacket(); // Allocate a packet for sending
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StoreForwardPlugin::sendPayload(NodeNum dest, uint32_t packetHistory_index)
|
void StoreForwardModule::sendPayload(NodeNum dest, uint32_t packetHistory_index)
|
||||||
{
|
{
|
||||||
DEBUG_MSG("Sending S&F Payload\n");
|
DEBUG_MSG("Sending S&F Payload\n");
|
||||||
MeshPacket *p = allocReply();
|
MeshPacket *p = allocReply();
|
||||||
@ -218,7 +218,7 @@ void StoreForwardPlugin::sendPayload(NodeNum dest, uint32_t packetHistory_index)
|
|||||||
service.sendToMesh(p);
|
service.sendToMesh(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StoreForwardPlugin::sendMessage(NodeNum dest, char *str)
|
void StoreForwardModule::sendMessage(NodeNum dest, char *str)
|
||||||
{
|
{
|
||||||
MeshPacket *p = allocReply();
|
MeshPacket *p = allocReply();
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ void StoreForwardPlugin::sendMessage(NodeNum dest, char *str)
|
|||||||
// HardwareMessage_init_default
|
// HardwareMessage_init_default
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessMessage StoreForwardPlugin::handleReceived(const MeshPacket &mp)
|
ProcessMessage StoreForwardModule::handleReceived(const MeshPacket &mp)
|
||||||
{
|
{
|
||||||
#ifndef NO_ESP32
|
#ifndef NO_ESP32
|
||||||
if (radioConfig.preferences.store_forward_module_enabled) {
|
if (radioConfig.preferences.store_forward_module_enabled) {
|
||||||
@ -261,9 +261,9 @@ ProcessMessage StoreForwardPlugin::handleReceived(const MeshPacket &mp)
|
|||||||
// Send the last 60 minutes of messages.
|
// Send the last 60 minutes of messages.
|
||||||
if (this->busy) {
|
if (this->busy) {
|
||||||
strcpy(this->routerMessage, "** S&F - Busy. Try again shortly.");
|
strcpy(this->routerMessage, "** S&F - Busy. Try again shortly.");
|
||||||
storeForwardPlugin->sendMessage(getFrom(&mp), this->routerMessage);
|
storeForwardModule->sendMessage(getFrom(&mp), this->routerMessage);
|
||||||
} else {
|
} else {
|
||||||
storeForwardPlugin->historySend(1000 * 60, getFrom(&mp));
|
storeForwardModule->historySend(1000 * 60, getFrom(&mp));
|
||||||
}
|
}
|
||||||
} else if ((p.payload.bytes[0] == 'S') && (p.payload.bytes[1] == 'F') && (p.payload.bytes[2] == 'm') &&
|
} else if ((p.payload.bytes[0] == 'S') && (p.payload.bytes[1] == 'F') && (p.payload.bytes[2] == 'm') &&
|
||||||
(p.payload.bytes[3] == 0x00)) {
|
(p.payload.bytes[3] == 0x00)) {
|
||||||
@ -271,10 +271,10 @@ ProcessMessage StoreForwardPlugin::handleReceived(const MeshPacket &mp)
|
|||||||
"01234567890123456789012345678901234567890123456789012345678901234567890123456789"
|
"01234567890123456789012345678901234567890123456789012345678901234567890123456789"
|
||||||
"01234567890123456789012345678901234567890123456789012345678901234567890123456",
|
"01234567890123456789012345678901234567890123456789012345678901234567890123456",
|
||||||
sizeof(this->routerMessage));
|
sizeof(this->routerMessage));
|
||||||
storeForwardPlugin->sendMessage(getFrom(&mp), this->routerMessage);
|
storeForwardModule->sendMessage(getFrom(&mp), this->routerMessage);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
storeForwardPlugin->historyAdd(mp);
|
storeForwardModule->historyAdd(mp);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (mp.decoded.portnum == PortNum_STORE_FORWARD_APP) {
|
} else if (mp.decoded.portnum == PortNum_STORE_FORWARD_APP) {
|
||||||
@ -285,7 +285,7 @@ ProcessMessage StoreForwardPlugin::handleReceived(const MeshPacket &mp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Store & Forward Plugin - Disabled\n");
|
DEBUG_MSG("Store & Forward Module - Disabled\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -293,7 +293,7 @@ ProcessMessage StoreForwardPlugin::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
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessMessage StoreForwardPlugin::handleReceivedProtobuf(const MeshPacket &mp, StoreAndForward *p)
|
ProcessMessage StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndForward *p)
|
||||||
{
|
{
|
||||||
if (!radioConfig.preferences.store_forward_module_enabled) {
|
if (!radioConfig.preferences.store_forward_module_enabled) {
|
||||||
// If this module is not enabled in any capacity, don't handle the packet, and allow other modules to consume
|
// If this module is not enabled in any capacity, don't handle the packet, and allow other modules to consume
|
||||||
@ -323,9 +323,9 @@ ProcessMessage StoreForwardPlugin::handleReceivedProtobuf(const MeshPacket &mp,
|
|||||||
// Send the last 60 minutes of messages.
|
// Send the last 60 minutes of messages.
|
||||||
if (this->busy) {
|
if (this->busy) {
|
||||||
strcpy(this->routerMessage, "** S&F - Busy. Try again shortly.");
|
strcpy(this->routerMessage, "** S&F - Busy. Try again shortly.");
|
||||||
storeForwardPlugin->sendMessage(getFrom(&mp), this->routerMessage);
|
storeForwardModule->sendMessage(getFrom(&mp), this->routerMessage);
|
||||||
} else {
|
} else {
|
||||||
storeForwardPlugin->historySend(1000 * 60, getFrom(&mp));
|
storeForwardModule->historySend(1000 * 60, getFrom(&mp));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -377,8 +377,8 @@ ProcessMessage StoreForwardPlugin::handleReceivedProtobuf(const MeshPacket &mp,
|
|||||||
return ProcessMessage::STOP; // There's no need for others to look at this message.
|
return ProcessMessage::STOP; // There's no need for others to look at this message.
|
||||||
}
|
}
|
||||||
|
|
||||||
StoreForwardPlugin::StoreForwardPlugin()
|
StoreForwardModule::StoreForwardModule()
|
||||||
: SinglePortPlugin("StoreForwardPlugin", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread("StoreForwardPlugin")
|
: SinglePortPlugin("StoreForwardModule", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread("StoreForwardModule")
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifndef NO_ESP32
|
||||||
@ -387,7 +387,7 @@ StoreForwardPlugin::StoreForwardPlugin()
|
|||||||
|
|
||||||
if (StoreForward_Dev) {
|
if (StoreForward_Dev) {
|
||||||
/*
|
/*
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -400,7 +400,7 @@ StoreForwardPlugin::StoreForwardPlugin()
|
|||||||
|
|
||||||
// Router
|
// Router
|
||||||
if (radioConfig.preferences.is_router) {
|
if (radioConfig.preferences.is_router) {
|
||||||
DEBUG_MSG("Initializing Store & Forward Plugin - Enabled as Router\n");
|
DEBUG_MSG("Initializing Store & Forward Module - Enabled as Router\n");
|
||||||
if (ESP.getPsramSize()) {
|
if (ESP.getPsramSize()) {
|
||||||
if (ESP.getFreePsram() >= 1024 * 1024) {
|
if (ESP.getFreePsram() >= 1024 * 1024) {
|
||||||
|
|
||||||
@ -427,17 +427,17 @@ StoreForwardPlugin::StoreForwardPlugin()
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Device has less than 1M of PSRAM free. Aborting startup.\n");
|
DEBUG_MSG("Device has less than 1M of PSRAM free. Aborting startup.\n");
|
||||||
DEBUG_MSG("Store & Forward Plugin - Aborting Startup.\n");
|
DEBUG_MSG("Store & Forward Module - Aborting Startup.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Device doesn't have PSRAM.\n");
|
DEBUG_MSG("Device doesn't have PSRAM.\n");
|
||||||
DEBUG_MSG("Store & Forward Plugin - Aborting Startup.\n");
|
DEBUG_MSG("Store & Forward Module - Aborting Startup.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client
|
// Client
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Initializing Store & Forward Plugin - Enabled as Client\n");
|
DEBUG_MSG("Initializing Store & Forward Module - Enabled as Client\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,7 +18,7 @@ struct PacketHistoryStruct {
|
|||||||
pb_size_t payload_size;
|
pb_size_t payload_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
class StoreForwardPlugin : public SinglePortPlugin, private concurrency::OSThread
|
class StoreForwardModule : public SinglePortPlugin, private concurrency::OSThread
|
||||||
{
|
{
|
||||||
// bool firstTime = 1;
|
// bool firstTime = 1;
|
||||||
bool busy = 0;
|
bool busy = 0;
|
||||||
@ -37,7 +37,7 @@ class StoreForwardPlugin : public SinglePortPlugin, private concurrency::OSThrea
|
|||||||
uint32_t packetTimeMax = 2000;
|
uint32_t packetTimeMax = 2000;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StoreForwardPlugin();
|
StoreForwardModule();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Update our local reference of when we last saw that node.
|
Update our local reference of when we last saw that node.
|
||||||
@ -82,4 +82,4 @@ class StoreForwardPlugin : public SinglePortPlugin, private concurrency::OSThrea
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern StoreForwardPlugin *storeForwardPlugin;
|
extern StoreForwardModule *storeForwardModule;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
//#define GPS_TX_PIN 12 // not connected
|
//#define GPS_TX_PIN 12 // not connected
|
||||||
|
|
||||||
#define BUTTON_PIN 39 // The middle button GPIO on the T-Beam
|
#define BUTTON_PIN 39 // The middle button GPIO on the T-Beam
|
||||||
#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Plugin (#975).
|
#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975).
|
||||||
#define LED_PIN 2 // add status LED (compatible with core-pcb and DIY targets)
|
#define LED_PIN 2 // add status LED (compatible with core-pcb and DIY targets)
|
||||||
|
|
||||||
#define LORA_DIO0 26 // a No connect on the SX1262/SX1268 module
|
#define LORA_DIO0 26 // a No connect on the SX1262/SX1268 module
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#define BUTTON_PIN 2 // The middle button GPIO on the T-Beam
|
#define BUTTON_PIN 2 // The middle button GPIO on the T-Beam
|
||||||
#define BUTTON_NEED_PULLUP
|
#define BUTTON_NEED_PULLUP
|
||||||
#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Plugin (#975).
|
#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975).
|
||||||
|
|
||||||
#define LORA_DIO0 26 // a No connect on the SX1262/SX1268 module
|
#define LORA_DIO0 26 // a No connect on the SX1262/SX1268 module
|
||||||
#define LORA_RESET 27 // RST for SX1276, and for SX1262/SX1268
|
#define LORA_RESET 27 // RST for SX1276, and for SX1262/SX1268
|
||||||
|
@ -27,4 +27,4 @@
|
|||||||
#define ADC_MULTIPLIER 3.8
|
#define ADC_MULTIPLIER 3.8
|
||||||
|
|
||||||
#define BATTERY_PIN 37 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
|
#define BATTERY_PIN 37 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
|
||||||
#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Plugin.
|
#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module.
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#define BUTTON_PIN 38 // The middle button GPIO on the T-Beam
|
#define BUTTON_PIN 38 // The middle button GPIO on the T-Beam
|
||||||
//#define BUTTON_PIN_ALT 13 // Alternate GPIO for an external button if needed. Does anyone use this? It is not documented anywhere.
|
//#define BUTTON_PIN_ALT 13 // Alternate GPIO for an external button if needed. Does anyone use this? It is not documented anywhere.
|
||||||
#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Plugin.
|
#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module.
|
||||||
|
|
||||||
#define LED_INVERTED 1
|
#define LED_INVERTED 1
|
||||||
#define LED_PIN 4 // Newer tbeams (1.1) have an extra led on GPIO4
|
#define LED_PIN 4 // Newer tbeams (1.1) have an extra led on GPIO4
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#define BUTTON_PIN 39
|
#define BUTTON_PIN 39
|
||||||
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
|
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
|
||||||
#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Plugin.
|
#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module.
|
||||||
|
|
||||||
#define USE_RF95
|
#define USE_RF95
|
||||||
#define LORA_DIO0 26 // a No connect on the SX1262 module
|
#define LORA_DIO0 26 // a No connect on the SX1262 module
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#define LED_PIN 2 // If defined we will blink this LED
|
#define LED_PIN 2 // If defined we will blink this LED
|
||||||
#define BUTTON_PIN 0 // If defined, this will be used for user button presses
|
#define BUTTON_PIN 0 // If defined, this will be used for user button presses
|
||||||
#define BUTTON_NEED_PULLUP
|
#define BUTTON_NEED_PULLUP
|
||||||
#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Plugin.
|
#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module.
|
||||||
|
|
||||||
#define USE_RF95
|
#define USE_RF95
|
||||||
#define LORA_DIO0 26 // a No connect on the SX1262 module
|
#define LORA_DIO0 26 // a No connect on the SX1262 module
|
||||||
|
Loading…
Reference in New Issue
Block a user