mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-01 07:30:33 +00:00
Merge branch 'meshtastic:master' into router
This commit is contained in:
@@ -1,38 +1,38 @@
|
||||
#include "configuration.h"
|
||||
#include "MeshPlugin.h"
|
||||
#include "MeshModule.h"
|
||||
#include "Channels.h"
|
||||
#include "MeshService.h"
|
||||
#include "NodeDB.h"
|
||||
#include "modules/RoutingModule.h"
|
||||
#include <assert.h>
|
||||
|
||||
std::vector<MeshPlugin *> *MeshPlugin::modules;
|
||||
std::vector<MeshModule *> *MeshModule::modules;
|
||||
|
||||
const MeshPacket *MeshPlugin::currentRequest;
|
||||
const MeshPacket *MeshModule::currentRequest;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
MeshPacket *MeshPlugin::currentReply;
|
||||
MeshPacket *MeshModule::currentReply;
|
||||
|
||||
MeshPlugin::MeshPlugin(const char *_name) : name(_name)
|
||||
MeshModule::MeshModule(const char *_name) : name(_name)
|
||||
{
|
||||
// Can't trust static initalizer order, so we check each time
|
||||
if (!modules)
|
||||
modules = new std::vector<MeshPlugin *>();
|
||||
modules = new std::vector<MeshModule *>();
|
||||
|
||||
modules->push_back(this);
|
||||
}
|
||||
|
||||
void MeshPlugin::setup() {}
|
||||
void MeshModule::setup() {}
|
||||
|
||||
MeshPlugin::~MeshPlugin()
|
||||
MeshModule::~MeshModule()
|
||||
{
|
||||
assert(0); // FIXME - remove from list of modules once someone needs this feature
|
||||
}
|
||||
|
||||
MeshPacket *MeshPlugin::allocAckNak(Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex)
|
||||
MeshPacket *MeshModule::allocAckNak(Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex)
|
||||
{
|
||||
Routing c = Routing_init_default;
|
||||
|
||||
@@ -57,7 +57,7 @@ MeshPacket *MeshPlugin::allocAckNak(Routing_Error err, NodeNum to, PacketId idFr
|
||||
return p;
|
||||
}
|
||||
|
||||
MeshPacket *MeshPlugin::allocErrorResponse(Routing_Error err, const MeshPacket *p)
|
||||
MeshPacket *MeshModule::allocErrorResponse(Routing_Error err, const MeshPacket *p)
|
||||
{
|
||||
auto r = allocAckNak(err, getFrom(p), p->id, p->channel);
|
||||
|
||||
@@ -66,7 +66,7 @@ MeshPacket *MeshPlugin::allocErrorResponse(Routing_Error err, const MeshPacket *
|
||||
return r;
|
||||
}
|
||||
|
||||
void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src)
|
||||
void MeshModule::callPlugins(const MeshPacket &mp, RxSource src)
|
||||
{
|
||||
// DEBUG_MSG("In call modules\n");
|
||||
bool moduleFound = false;
|
||||
@@ -183,7 +183,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src)
|
||||
(src == RX_SRC_LOCAL) ? "LOCAL":"REMOTE");
|
||||
}
|
||||
|
||||
MeshPacket *MeshPlugin::allocReply()
|
||||
MeshPacket *MeshModule::allocReply()
|
||||
{
|
||||
auto r = myReply;
|
||||
myReply = NULL; // Only use each reply once
|
||||
@@ -194,7 +194,7 @@ MeshPacket *MeshPlugin::allocReply()
|
||||
* so that subclasses can (optionally) send a response back to the original sender. Implementing this method
|
||||
* is optional
|
||||
*/
|
||||
void MeshPlugin::sendResponse(const MeshPacket &req)
|
||||
void MeshModule::sendResponse(const MeshPacket &req)
|
||||
{
|
||||
auto r = allocReply();
|
||||
if (r) {
|
||||
@@ -222,10 +222,10 @@ void setReplyTo(MeshPacket *p, const MeshPacket &to)
|
||||
p->decoded.request_id = to.id;
|
||||
}
|
||||
|
||||
std::vector<MeshPlugin *> MeshPlugin::GetMeshModulesWithUIFrames()
|
||||
std::vector<MeshModule *> MeshModule::GetMeshModulesWithUIFrames()
|
||||
{
|
||||
|
||||
std::vector<MeshPlugin *> modulesWithUIFrames;
|
||||
std::vector<MeshModule *> modulesWithUIFrames;
|
||||
if (modules) {
|
||||
for (auto i = modules->begin(); i != modules->end(); ++i) {
|
||||
auto &pi = **i;
|
||||
@@ -238,7 +238,7 @@ std::vector<MeshPlugin *> MeshPlugin::GetMeshModulesWithUIFrames()
|
||||
return modulesWithUIFrames;
|
||||
}
|
||||
|
||||
void MeshPlugin::observeUIEvents(
|
||||
void MeshModule::observeUIEvents(
|
||||
Observer<const UIFrameEvent *> *observer)
|
||||
{
|
||||
if (modules) {
|
||||
@@ -254,7 +254,7 @@ void MeshPlugin::observeUIEvents(
|
||||
}
|
||||
}
|
||||
|
||||
AdminMessageHandleResult MeshPlugin::handleAdminMessageForAllPlugins(const MeshPacket &mp, AdminMessage *request, AdminMessage *response)
|
||||
AdminMessageHandleResult MeshModule::handleAdminMessageForAllPlugins(const MeshPacket &mp, AdminMessage *request, AdminMessage *response)
|
||||
{
|
||||
AdminMessageHandleResult handled = AdminMessageHandleResult::NOT_HANDLED;
|
||||
if (modules) {
|
||||
@@ -52,23 +52,23 @@ typedef struct _UIFrameEvent {
|
||||
* Interally we use modules to implement the core meshtastic text messaging and gps position sharing features. You
|
||||
* can use these classes as examples for how to write your own custom module. See here: (FIXME)
|
||||
*/
|
||||
class MeshPlugin
|
||||
class MeshModule
|
||||
{
|
||||
static std::vector<MeshPlugin *> *modules;
|
||||
static std::vector<MeshModule *> *modules;
|
||||
|
||||
public:
|
||||
/** Constructor
|
||||
* name is for debugging output
|
||||
*/
|
||||
MeshPlugin(const char *_name);
|
||||
MeshModule(const char *_name);
|
||||
|
||||
virtual ~MeshPlugin();
|
||||
virtual ~MeshModule();
|
||||
|
||||
/** For use only by MeshService
|
||||
*/
|
||||
static void callPlugins(const MeshPacket &mp, RxSource src = RX_SRC_RADIO);
|
||||
|
||||
static std::vector<MeshPlugin *> GetMeshModulesWithUIFrames();
|
||||
static std::vector<MeshModule *> GetMeshModulesWithUIFrames();
|
||||
static void observeUIEvents(Observer<const UIFrameEvent *> *observer);
|
||||
static AdminMessageHandleResult handleAdminMessageForAllPlugins(
|
||||
const MeshPacket &mp, AdminMessage *request, AdminMessage *response);
|
||||
@@ -438,7 +438,7 @@ size_t NodeDB::getNumOnlineNodes()
|
||||
return numseen;
|
||||
}
|
||||
|
||||
#include "MeshPlugin.h"
|
||||
#include "MeshModule.h"
|
||||
|
||||
/** Update position info for this node based on received position data
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "configuration.h"
|
||||
#include "ProtobufPlugin.h"
|
||||
#include "ProtobufModule.h"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "SinglePortPlugin.h"
|
||||
#include "SinglePortModule.h"
|
||||
|
||||
/**
|
||||
* A base class for mesh modules that assume that they are sending/receiving one particular protobuf based
|
||||
@@ -8,7 +8,7 @@
|
||||
* If you are using protobufs to encode your packets (recommended) you can use this as a baseclass for your module
|
||||
* and avoid a bunch of boilerplate code.
|
||||
*/
|
||||
template <class T> class ProtobufPlugin : protected SinglePortPlugin
|
||||
template <class T> class ProtobufModule : protected SinglePortModule
|
||||
{
|
||||
const pb_msgdesc_t *fields;
|
||||
|
||||
@@ -16,8 +16,8 @@ template <class T> class ProtobufPlugin : protected SinglePortPlugin
|
||||
/** Constructor
|
||||
* name is for debugging output
|
||||
*/
|
||||
ProtobufPlugin(const char *_name, PortNum _ourPortNum, const pb_msgdesc_t *_fields)
|
||||
: SinglePortPlugin(_name, _ourPortNum), fields(_fields)
|
||||
ProtobufModule(const char *_name, PortNum _ourPortNum, const pb_msgdesc_t *_fields)
|
||||
: SinglePortModule(_name, _ourPortNum), fields(_fields)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "configuration.h"
|
||||
#include "ReliableRouter.h"
|
||||
#include "MeshPlugin.h"
|
||||
#include "MeshModule.h"
|
||||
#include "MeshTypes.h"
|
||||
#include "mesh-pb-constants.h"
|
||||
|
||||
@@ -92,7 +92,7 @@ void ReliableRouter::sniffReceived(const MeshPacket *p, const Routing *c)
|
||||
if (p->to == ourNode) { // ignore ack/nak/want_ack packets that are not address to us (we only handle 0 hop reliability
|
||||
// - not DSR routing)
|
||||
if (p->want_ack) {
|
||||
if (MeshPlugin::currentReply)
|
||||
if (MeshModule::currentReply)
|
||||
DEBUG_MSG("Someone else has replied to this message, no need for a 2nd ack\n");
|
||||
else
|
||||
sendAckNak(Routing_Error_NONE, getFrom(p), p->id, p->channel);
|
||||
|
||||
@@ -377,7 +377,7 @@ void Router::handleReceived(MeshPacket *p, RxSource src)
|
||||
}
|
||||
|
||||
// call modules here
|
||||
MeshPlugin::callPlugins(*p, src);
|
||||
MeshModule::callPlugins(*p, src);
|
||||
}
|
||||
|
||||
void Router::perhapsHandleReceived(MeshPacket *p)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
#include "MeshPlugin.h"
|
||||
#include "MeshModule.h"
|
||||
#include "Router.h"
|
||||
|
||||
/**
|
||||
* Most modules are only interested in sending/receving one particular portnum. This baseclass simplifies that common
|
||||
* case.
|
||||
*/
|
||||
class SinglePortPlugin : public MeshPlugin
|
||||
class SinglePortModule : public MeshModule
|
||||
{
|
||||
protected:
|
||||
PortNum ourPortNum;
|
||||
@@ -15,7 +15,7 @@ class SinglePortPlugin : public MeshPlugin
|
||||
/** Constructor
|
||||
* name is for debugging output
|
||||
*/
|
||||
SinglePortPlugin(const char *_name, PortNum _ourPortNum) : MeshPlugin(_name), ourPortNum(_ourPortNum) {}
|
||||
SinglePortModule(const char *_name, PortNum _ourPortNum) : MeshModule(_name), ourPortNum(_ourPortNum) {}
|
||||
|
||||
protected:
|
||||
/**
|
||||
@@ -148,12 +148,12 @@ typedef struct _RadioConfig_UserPreferences {
|
||||
bool debug_log_enabled;
|
||||
pb_size_t ignore_incoming_count;
|
||||
uint32_t ignore_incoming[3];
|
||||
bool serialmodule_enabled;
|
||||
bool serialmodule_echo;
|
||||
uint32_t serialmodule_rxd;
|
||||
uint32_t serialmodule_txd;
|
||||
uint32_t serialmodule_timeout;
|
||||
uint32_t serialmodule_mode;
|
||||
bool serial_module_enabled;
|
||||
bool serial_module_echo;
|
||||
uint32_t serial_module_rxd;
|
||||
uint32_t serial_module_txd;
|
||||
uint32_t serial_module_timeout;
|
||||
uint32_t serial_module_mode;
|
||||
bool ext_notification_module_enabled;
|
||||
uint32_t ext_notification_module_output_ms;
|
||||
uint32_t ext_notification_module_output;
|
||||
@@ -197,7 +197,7 @@ typedef struct _RadioConfig_UserPreferences {
|
||||
bool canned_message_module_send_bell;
|
||||
bool mqtt_encryption_enabled;
|
||||
float adc_multiplier_override;
|
||||
uint32_t serialmodule_baud;
|
||||
uint32_t serial_module_baud;
|
||||
} RadioConfig_UserPreferences;
|
||||
|
||||
typedef struct _RadioConfig {
|
||||
@@ -289,12 +289,12 @@ extern "C" {
|
||||
#define RadioConfig_UserPreferences_factory_reset_tag 100
|
||||
#define RadioConfig_UserPreferences_debug_log_enabled_tag 101
|
||||
#define RadioConfig_UserPreferences_ignore_incoming_tag 103
|
||||
#define RadioConfig_UserPreferences_serialmodule_enabled_tag 120
|
||||
#define RadioConfig_UserPreferences_serialmodule_echo_tag 121
|
||||
#define RadioConfig_UserPreferences_serialmodule_rxd_tag 122
|
||||
#define RadioConfig_UserPreferences_serialmodule_txd_tag 123
|
||||
#define RadioConfig_UserPreferences_serialmodule_timeout_tag 124
|
||||
#define RadioConfig_UserPreferences_serialmodule_mode_tag 125
|
||||
#define RadioConfig_UserPreferences_serial_module_enabled_tag 120
|
||||
#define RadioConfig_UserPreferences_serial_module_echo_tag 121
|
||||
#define RadioConfig_UserPreferences_serial_module_rxd_tag 122
|
||||
#define RadioConfig_UserPreferences_serial_module_txd_tag 123
|
||||
#define RadioConfig_UserPreferences_serial_module_timeout_tag 124
|
||||
#define RadioConfig_UserPreferences_serial_module_mode_tag 125
|
||||
#define RadioConfig_UserPreferences_ext_notification_module_enabled_tag 126
|
||||
#define RadioConfig_UserPreferences_ext_notification_module_output_ms_tag 127
|
||||
#define RadioConfig_UserPreferences_ext_notification_module_output_tag 128
|
||||
@@ -338,7 +338,7 @@ extern "C" {
|
||||
#define RadioConfig_UserPreferences_canned_message_module_send_bell_tag 173
|
||||
#define RadioConfig_UserPreferences_mqtt_encryption_enabled_tag 174
|
||||
#define RadioConfig_UserPreferences_adc_multiplier_override_tag 175
|
||||
#define RadioConfig_UserPreferences_serialmodule_baud_tag 176
|
||||
#define RadioConfig_UserPreferences_serial_module_baud_tag 176
|
||||
#define RadioConfig_preferences_tag 1
|
||||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
@@ -383,12 +383,12 @@ X(a, STATIC, SINGULAR, UINT32, gps_max_dop, 46) \
|
||||
X(a, STATIC, SINGULAR, BOOL, factory_reset, 100) \
|
||||
X(a, STATIC, SINGULAR, BOOL, debug_log_enabled, 101) \
|
||||
X(a, STATIC, REPEATED, UINT32, ignore_incoming, 103) \
|
||||
X(a, STATIC, SINGULAR, BOOL, serialmodule_enabled, 120) \
|
||||
X(a, STATIC, SINGULAR, BOOL, serialmodule_echo, 121) \
|
||||
X(a, STATIC, SINGULAR, UINT32, serialmodule_rxd, 122) \
|
||||
X(a, STATIC, SINGULAR, UINT32, serialmodule_txd, 123) \
|
||||
X(a, STATIC, SINGULAR, UINT32, serialmodule_timeout, 124) \
|
||||
X(a, STATIC, SINGULAR, UINT32, serialmodule_mode, 125) \
|
||||
X(a, STATIC, SINGULAR, BOOL, serial_module_enabled, 120) \
|
||||
X(a, STATIC, SINGULAR, BOOL, serial_module_echo, 121) \
|
||||
X(a, STATIC, SINGULAR, UINT32, serial_module_rxd, 122) \
|
||||
X(a, STATIC, SINGULAR, UINT32, serial_module_txd, 123) \
|
||||
X(a, STATIC, SINGULAR, UINT32, serial_module_timeout, 124) \
|
||||
X(a, STATIC, SINGULAR, UINT32, serial_module_mode, 125) \
|
||||
X(a, STATIC, SINGULAR, BOOL, ext_notification_module_enabled, 126) \
|
||||
X(a, STATIC, SINGULAR, UINT32, ext_notification_module_output_ms, 127) \
|
||||
X(a, STATIC, SINGULAR, UINT32, ext_notification_module_output, 128) \
|
||||
@@ -432,7 +432,7 @@ X(a, STATIC, SINGULAR, STRING, canned_message_module_allow_input_source, 171
|
||||
X(a, STATIC, SINGULAR, BOOL, canned_message_module_send_bell, 173) \
|
||||
X(a, STATIC, SINGULAR, BOOL, mqtt_encryption_enabled, 174) \
|
||||
X(a, STATIC, SINGULAR, FLOAT, adc_multiplier_override, 175) \
|
||||
X(a, STATIC, SINGULAR, UINT32, serialmodule_baud, 176)
|
||||
X(a, STATIC, SINGULAR, UINT32, serial_module_baud, 176)
|
||||
#define RadioConfig_UserPreferences_CALLBACK NULL
|
||||
#define RadioConfig_UserPreferences_DEFAULT NULL
|
||||
|
||||
|
||||
@@ -205,11 +205,12 @@ bool initWifi(bool forceSoftAP)
|
||||
if (forcedSoftAP) {
|
||||
const char *softAPssid = "meshtasticAdmin";
|
||||
const char *softAPpasswd = "12345678";
|
||||
|
||||
DEBUG_MSG("Starting (Forced) WIFI AP: ssid=%s, ok=%d\n", softAPssid, WiFi.softAP(softAPssid, softAPpasswd));
|
||||
int ok = WiFi.softAP(softAPssid, softAPpasswd);
|
||||
DEBUG_MSG("Starting (Forced) WIFI AP: ssid=%s, ok=%d\n", softAPssid, ok);
|
||||
|
||||
} else {
|
||||
DEBUG_MSG("Starting WIFI AP: ssid=%s, ok=%d\n", wifiName, WiFi.softAP(wifiName, wifiPsw));
|
||||
int ok = WiFi.softAP(wifiName, wifiPsw);
|
||||
DEBUG_MSG("Starting WIFI AP: ssid=%s, ok=%d\n", wifiName, ok);
|
||||
}
|
||||
|
||||
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
|
||||
@@ -362,4 +363,4 @@ void handleDNSResponse()
|
||||
uint8_t getWifiDisconnectReason()
|
||||
{
|
||||
return wifiDisconnectReason;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user