Merge pull request #1464 from meshtastic/LocalConfig

Segemented config works for me (TM)
This commit is contained in:
Thomas Göttgens
2022-05-22 13:41:47 +02:00
committed by GitHub
co-authored by GitHub
38 changed files with 313 additions and 286 deletions
+2 -2
View File
@@ -118,8 +118,8 @@ class ButtonThread : public concurrency::OSThread
{ {
// DEBUG_MSG("press!\n"); // DEBUG_MSG("press!\n");
#ifdef BUTTON_PIN #ifdef BUTTON_PIN
if ((BUTTON_PIN != moduleConfig.payloadVariant.canned_message.inputbroker_pin_press) || if ((BUTTON_PIN != moduleConfig.canned_message.inputbroker_pin_press) ||
!moduleConfig.payloadVariant.canned_message.enabled) { !moduleConfig.canned_message.enabled) {
powerFSM.trigger(EVENT_PRESS); powerFSM.trigger(EVENT_PRESS);
} }
#endif #endif
+3 -3
View File
@@ -62,7 +62,7 @@ class GPSStatus : public Status
int32_t getLatitude() const int32_t getLatitude() const
{ {
if (config.payloadVariant.position.fixed_position) { if (config.position.fixed_position) {
#ifdef GPS_EXTRAVERBOSE #ifdef GPS_EXTRAVERBOSE
DEBUG_MSG("WARNING: Using fixed latitude\n"); DEBUG_MSG("WARNING: Using fixed latitude\n");
#endif #endif
@@ -75,7 +75,7 @@ class GPSStatus : public Status
int32_t getLongitude() const int32_t getLongitude() const
{ {
if (config.payloadVariant.position.fixed_position) { if (config.position.fixed_position) {
#ifdef GPS_EXTRAVERBOSE #ifdef GPS_EXTRAVERBOSE
DEBUG_MSG("WARNING: Using fixed longitude\n"); DEBUG_MSG("WARNING: Using fixed longitude\n");
#endif #endif
@@ -88,7 +88,7 @@ class GPSStatus : public Status
int32_t getAltitude() const int32_t getAltitude() const
{ {
if (config.payloadVariant.position.fixed_position) { if (config.position.fixed_position) {
#ifdef GPS_EXTRAVERBOSE #ifdef GPS_EXTRAVERBOSE
DEBUG_MSG("WARNING: Using fixed altitude\n"); DEBUG_MSG("WARNING: Using fixed altitude\n");
#endif #endif
+3 -3
View File
@@ -104,8 +104,8 @@ class AnalogBatteryLevel : public HasBatteryLevel
#ifdef BATTERY_PIN #ifdef BATTERY_PIN
// Override variant or default ADC_MULTIPLIER if we have the override pref // Override variant or default ADC_MULTIPLIER if we have the override pref
float operativeAdcMultiplier = config.payloadVariant.power.adc_multiplier_override > 0 float operativeAdcMultiplier = config.power.adc_multiplier_override > 0
? config.payloadVariant.power.adc_multiplier_override ? config.power.adc_multiplier_override
: ADC_MULTIPLIER; : ADC_MULTIPLIER;
// Do not call analogRead() often. // Do not call analogRead() often.
const uint32_t min_read_interval = 5000; const uint32_t min_read_interval = 5000;
@@ -357,7 +357,7 @@ bool Power::axp192Init()
DEBUG_MSG("DCDC3: %s\n", axp.isDCDC3Enable() ? "ENABLE" : "DISABLE"); DEBUG_MSG("DCDC3: %s\n", axp.isDCDC3Enable() ? "ENABLE" : "DISABLE");
DEBUG_MSG("Exten: %s\n", axp.isExtenEnable() ? "ENABLE" : "DISABLE"); DEBUG_MSG("Exten: %s\n", axp.isExtenEnable() ? "ENABLE" : "DISABLE");
switch (config.payloadVariant.power.charge_current) { switch (config.power.charge_current) {
case Config_PowerConfig_ChargeCurrent_MAUnset: case Config_PowerConfig_ChargeCurrent_MAUnset:
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_450MA); axp.setChargeControlCur(AXP1XX_CHARGE_CUR_450MA);
break; break;
+13 -13
View File
@@ -12,15 +12,15 @@
static bool isPowered() static bool isPowered()
{ {
// Completely circumvents the battery / power sensing logic and assumes constant power source // Completely circumvents the battery / power sensing logic and assumes constant power source
if (config.payloadVariant.power.is_always_powered) { if (config.power.is_always_powered) {
return true; return true;
} }
bool isRouter = (config.payloadVariant.device.role == Config_DeviceConfig_Role_Router ? 1 : 0); bool isRouter = (config.device.role == Config_DeviceConfig_Role_Router ? 1 : 0);
// If we are not a router and we already have AC power go to POWER state after init, otherwise go to ON // If we are not a router and we already have AC power go to POWER state after init, otherwise go to ON
// We assume routers might be powered all the time, but from a low current (solar) source // We assume routers might be powered all the time, but from a low current (solar) source
bool isLowPower = config.payloadVariant.power.is_low_power || isRouter; bool isLowPower = config.power.is_low_power || isRouter;
/* To determine if we're externally powered, assumptions /* To determine if we're externally powered, assumptions
1) If we're powered up and there's no battery, we must be getting power externally. (because we'd be dead otherwise) 1) If we're powered up and there's no battery, we must be getting power externally. (because we'd be dead otherwise)
@@ -34,7 +34,7 @@ static void sdsEnter()
{ {
DEBUG_MSG("Enter state: SDS\n"); DEBUG_MSG("Enter state: SDS\n");
// FIXME - make sure GPS and LORA radio are off first - because we want close to zero current draw // FIXME - make sure GPS and LORA radio are off first - because we want close to zero current draw
doDeepSleep(config.payloadVariant.power.sds_secs ? config.payloadVariant.power.sds_secs : default_sds_secs * 1000LL); doDeepSleep(config.power.sds_secs ? config.power.sds_secs : default_sds_secs * 1000LL);
} }
extern Power *power; extern Power *power;
@@ -52,7 +52,7 @@ static uint32_t secsSlept;
static void lsEnter() static void lsEnter()
{ {
DEBUG_MSG("lsEnter begin, ls_secs=%u\n", DEBUG_MSG("lsEnter begin, ls_secs=%u\n",
config.payloadVariant.power.ls_secs ? config.payloadVariant.power.ls_secs : default_ls_secs); config.power.ls_secs ? config.power.ls_secs : default_ls_secs);
screen->setOn(false); screen->setOn(false);
secsSlept = 0; // How long have we been sleeping this time secsSlept = 0; // How long have we been sleeping this time
@@ -66,7 +66,7 @@ static void lsIdle()
#ifndef NO_ESP32 #ifndef NO_ESP32
// Do we have more sleeping to do? // Do we have more sleeping to do?
if (secsSlept < config.payloadVariant.power.ls_secs ? config.payloadVariant.power.ls_secs : default_ls_secs * 1000) { if (secsSlept < config.power.ls_secs ? config.power.ls_secs : default_ls_secs * 1000) {
// Briefly come out of sleep long enough to blink the led once every few seconds // Briefly come out of sleep long enough to blink the led once every few seconds
uint32_t sleepTime = 30; uint32_t sleepTime = 30;
@@ -239,7 +239,7 @@ Fsm powerFSM(&stateBOOT);
void PowerFSM_setup() void PowerFSM_setup()
{ {
bool isRouter = (config.payloadVariant.device.role == Config_DeviceConfig_Role_Router ? 1 : 0); bool isRouter = (config.device.role == Config_DeviceConfig_Role_Router ? 1 : 0);
bool hasPower = isPowered(); bool hasPower = isPowered();
DEBUG_MSG("PowerFSM init, USB power=%d\n", hasPower); DEBUG_MSG("PowerFSM init, USB power=%d\n", hasPower);
@@ -334,7 +334,7 @@ void PowerFSM_setup()
powerFSM.add_transition(&stateON, &stateON, EVENT_FIRMWARE_UPDATE, NULL, "Got firmware update"); powerFSM.add_transition(&stateON, &stateON, EVENT_FIRMWARE_UPDATE, NULL, "Got firmware update");
powerFSM.add_timed_transition(&stateON, &stateDARK, powerFSM.add_timed_transition(&stateON, &stateDARK,
config.payloadVariant.display.screen_on_secs ? config.payloadVariant.display.screen_on_secs config.display.screen_on_secs ? config.display.screen_on_secs
: 60 * 1000, : 60 * 1000,
NULL, "Screen-on timeout"); NULL, "Screen-on timeout");
@@ -347,20 +347,20 @@ void PowerFSM_setup()
// We never enter light-sleep or NB states on NRF52 (because the CPU uses so little power normally) // We never enter light-sleep or NB states on NRF52 (because the CPU uses so little power normally)
// See: https://github.com/meshtastic/Meshtastic-device/issues/1071 // See: https://github.com/meshtastic/Meshtastic-device/issues/1071
if (isRouter || config.payloadVariant.power.is_power_saving) { if (isRouter || config.power.is_power_saving) {
// I don't think this transition is correct, turning off for now - @geeksville // I don't think this transition is correct, turning off for now - @geeksville
// powerFSM.add_timed_transition(&stateDARK, &stateNB, getPref_phone_timeout_secs() * 1000, NULL, "Phone timeout"); // powerFSM.add_timed_transition(&stateDARK, &stateNB, getPref_phone_timeout_secs() * 1000, NULL, "Phone timeout");
powerFSM.add_timed_transition(&stateNB, &stateLS, powerFSM.add_timed_transition(&stateNB, &stateLS,
config.payloadVariant.power.min_wake_secs ? config.payloadVariant.power.min_wake_secs config.power.min_wake_secs ? config.power.min_wake_secs
: default_min_wake_secs * 1000, : default_min_wake_secs * 1000,
NULL, "Min wake timeout"); NULL, "Min wake timeout");
powerFSM.add_timed_transition(&stateDARK, &stateLS, powerFSM.add_timed_transition(&stateDARK, &stateLS,
config.payloadVariant.power.wait_bluetooth_secs config.power.wait_bluetooth_secs
? config.payloadVariant.power.wait_bluetooth_secs ? config.power.wait_bluetooth_secs
: default_wait_bluetooth_secs * 1000, : default_wait_bluetooth_secs * 1000,
NULL, "Bluetooth timeout"); NULL, "Bluetooth timeout");
meshSds = config.payloadVariant.power.mesh_sds_timeout_secs ? config.payloadVariant.power.mesh_sds_timeout_secs meshSds = config.power.mesh_sds_timeout_secs ? config.power.mesh_sds_timeout_secs
: default_mesh_sds_timeout_secs; : default_mesh_sds_timeout_secs;
} else { } else {
+2 -2
View File
@@ -26,11 +26,11 @@ class PowerFSMThread : public OSThread
if (powerStatus->getHasUSB()) { if (powerStatus->getHasUSB()) {
timeLastPowered = millis(); timeLastPowered = millis();
} else if (config.payloadVariant.power.on_battery_shutdown_after_secs > 0 && } else if (config.power.on_battery_shutdown_after_secs > 0 &&
millis() > millis() >
timeLastPowered + timeLastPowered +
(1000 * (1000 *
config.payloadVariant.power.on_battery_shutdown_after_secs)) { // shutdown after 30 minutes unpowered config.power.on_battery_shutdown_after_secs)) { // shutdown after 30 minutes unpowered
powerFSM.trigger(EVENT_SHUTDOWN); powerFSM.trigger(EVENT_SHUTDOWN);
} }
+3 -3
View File
@@ -45,8 +45,8 @@ SerialConsole::SerialConsole() : StreamAPI(&Port), RedirectablePrint(&Port)
bool SerialConsole::checkIsConnected() bool SerialConsole::checkIsConnected()
{ {
uint32_t now = millis(); uint32_t now = millis();
return (now - lastContactMsec) < config.payloadVariant.power.phone_timeout_secs return (now - lastContactMsec) < config.power.phone_timeout_secs
? config.payloadVariant.power.phone_timeout_secs ? config.power.phone_timeout_secs
: default_phone_timeout_secs * 1000UL; : default_phone_timeout_secs * 1000UL;
} }
@@ -57,7 +57,7 @@ bool SerialConsole::checkIsConnected()
bool SerialConsole::handleToRadio(const uint8_t *buf, size_t len) bool SerialConsole::handleToRadio(const uint8_t *buf, size_t len)
{ {
// Turn off debug serial printing once the API is activated, because other threads could print and corrupt packets // Turn off debug serial printing once the API is activated, because other threads could print and corrupt packets
if (!config.payloadVariant.device.debug_log_enabled) if (!config.device.debug_log_enabled)
setDestination(&noopPrint); setDestination(&noopPrint);
canWrite = true; canWrite = true;
+12 -7
View File
@@ -194,6 +194,11 @@ bool GPS::hasLock()
return hasValidLocation; return hasValidLocation;
} }
bool GPS::hasFlow()
{
return hasGPS;
}
// Allow defining the polarity of the WAKE output. default is active high // Allow defining the polarity of the WAKE output. default is active high
#ifndef GPS_WAKE_ACTIVE #ifndef GPS_WAKE_ACTIVE
#define GPS_WAKE_ACTIVE 1 #define GPS_WAKE_ACTIVE 1
@@ -262,13 +267,13 @@ void GPS::setAwake(bool on)
*/ */
uint32_t GPS::getWakeTime() const uint32_t GPS::getWakeTime() const
{ {
uint32_t t = config.payloadVariant.position.gps_attempt_time; uint32_t t = config.position.gps_attempt_time;
if (t == UINT32_MAX) if (t == UINT32_MAX)
return t; // already maxint return t; // already maxint
if (t == 0) if (t == 0)
t = (config.payloadVariant.device.role == Config_DeviceConfig_Role_Router) t = (config.device.role == Config_DeviceConfig_Role_Router)
? 5 * 60 ? 5 * 60
: 15 * 60; // Allow up to 15 mins for each attempt (probably will be much : 15 * 60; // Allow up to 15 mins for each attempt (probably will be much
// less if we can find sats) or less if a router // less if we can find sats) or less if a router
@@ -282,8 +287,8 @@ uint32_t GPS::getWakeTime() const
*/ */
uint32_t GPS::getSleepTime() const uint32_t GPS::getSleepTime() const
{ {
uint32_t t = config.payloadVariant.position.gps_update_interval; uint32_t t = config.position.gps_update_interval;
bool gps_disabled = config.payloadVariant.position.gps_disabled; bool gps_disabled = config.position.gps_disabled;
if (gps_disabled) if (gps_disabled)
t = UINT32_MAX; // Sleep forever now t = UINT32_MAX; // Sleep forever now
@@ -292,7 +297,7 @@ uint32_t GPS::getSleepTime() const
return t; // already maxint return t; // already maxint
if (t == 0) // default - unset in preferences if (t == 0) // default - unset in preferences
t = (config.payloadVariant.device.role == Config_DeviceConfig_Role_Router) ? 24 * 60 * 60 t = (config.device.role == Config_DeviceConfig_Role_Router) ? 24 * 60 * 60
: 2 * 60; // 2 mins or once per day for routers : 2 * 60; // 2 mins or once per day for routers
t *= 1000; t *= 1000;
@@ -322,7 +327,7 @@ int32_t GPS::runOnce()
} else { } else {
#ifdef GPS_UBLOX #ifdef GPS_UBLOX
// reset the GPS on next bootup // reset the GPS on next bootup
if(devicestate.did_gps_reset && (millis() > 60000)) { if(devicestate.did_gps_reset && (millis() > 60000) && !hasFlow()) {
DEBUG_MSG("GPS is not communicating, trying factory reset on next bootup.\n"); DEBUG_MSG("GPS is not communicating, trying factory reset on next bootup.\n");
devicestate.did_gps_reset = false; devicestate.did_gps_reset = false;
nodeDB.saveToDisk(); nodeDB.saveToDisk();
@@ -437,7 +442,7 @@ GPS *createGps()
#ifdef NO_GPS #ifdef NO_GPS
return nullptr; return nullptr;
#else #else
if (!config.payloadVariant.position.gps_disabled) { if (!config.position.gps_disabled) {
#ifdef GPS_ALTITUDE_HAE #ifdef GPS_ALTITUDE_HAE
DEBUG_MSG("Using HAE altitude model\n"); DEBUG_MSG("Using HAE altitude model\n");
#else #else
+3
View File
@@ -57,6 +57,9 @@ class GPS : private concurrency::OSThread
/// Returns true if we have acquired GPS lock. /// Returns true if we have acquired GPS lock.
virtual bool hasLock(); virtual bool hasLock();
/// Returns true if there's valid data flow with the chip.
virtual bool hasFlow();
/// Return true if we are connected to a GPS /// Return true if we are connected to a GPS
bool isConnected() const { return hasGPS; } bool isConnected() const { return hasGPS; }
+4
View File
@@ -235,6 +235,10 @@ bool NMEAGPS::hasLock()
return false; return false;
} }
bool NMEAGPS::hasFlow()
{
return reader.passedChecksum() > 0;
}
bool NMEAGPS::whileIdle() bool NMEAGPS::whileIdle()
{ {
+2
View File
@@ -51,4 +51,6 @@ class NMEAGPS : public GPS
virtual bool lookForLocation() override; virtual bool lookForLocation() override;
virtual bool hasLock() override; virtual bool hasLock() override;
virtual bool hasFlow() override;
}; };
+20 -20
View File
@@ -353,8 +353,8 @@ static void drawCriticalFaultFrame(OLEDDisplay *display, OLEDDisplayUiState *sta
// Ignore messages orginating from phone (from the current node 0x0) unless range test or store and forward module are enabled // Ignore messages orginating from phone (from the current node 0x0) unless range test or store and forward module are enabled
static bool shouldDrawMessage(const MeshPacket *packet) static bool shouldDrawMessage(const MeshPacket *packet)
{ {
return packet->from != 0 && !moduleConfig.payloadVariant.range_test.enabled && return packet->from != 0 && !moduleConfig.range_test.enabled &&
!moduleConfig.payloadVariant.store_forward.enabled; !moduleConfig.store_forward.enabled;
} }
/// Draw the last text message we received /// Draw the last text message we received
@@ -468,7 +468,7 @@ static void drawNodes(OLEDDisplay *display, int16_t x, int16_t y, NodeStatus *no
// Draw GPS status summary // Draw GPS status summary
static void drawGPS(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus *gps) static void drawGPS(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus *gps)
{ {
if (config.payloadVariant.position.fixed_position) { if (config.position.fixed_position) {
// GPS coordinates are currently fixed // GPS coordinates are currently fixed
display->drawString(x - 1, y - 2, "Fixed GPS"); display->drawString(x - 1, y - 2, "Fixed GPS");
return; return;
@@ -507,10 +507,10 @@ static void drawGPS(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus
static void drawGPSAltitude(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus *gps) static void drawGPSAltitude(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus *gps)
{ {
String displayLine = ""; String displayLine = "";
if (!gps->getIsConnected() && !config.payloadVariant.position.fixed_position) { if (!gps->getIsConnected() && !config.position.fixed_position) {
// displayLine = "No GPS Module"; // displayLine = "No GPS Module";
// display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine); // display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
} else if (!gps->getHasLock() && !config.payloadVariant.position.fixed_position) { } else if (!gps->getHasLock() && !config.position.fixed_position) {
// displayLine = "No GPS Lock"; // displayLine = "No GPS Lock";
// display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine); // display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
} else { } else {
@@ -523,13 +523,13 @@ static void drawGPSAltitude(OLEDDisplay *display, int16_t x, int16_t y, const GP
// Draw GPS status coordinates // Draw GPS status coordinates
static void drawGPScoordinates(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus *gps) static void drawGPScoordinates(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus *gps)
{ {
auto gpsFormat = config.payloadVariant.display.gps_format; auto gpsFormat = config.display.gps_format;
String displayLine = ""; String displayLine = "";
if (!gps->getIsConnected() && !config.payloadVariant.position.fixed_position) { if (!gps->getIsConnected() && !config.position.fixed_position) {
displayLine = "No GPS Module"; displayLine = "No GPS Module";
display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine); display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
} else if (!gps->getHasLock() && !config.payloadVariant.position.fixed_position) { } else if (!gps->getHasLock() && !config.position.fixed_position) {
displayLine = "No GPS Lock"; displayLine = "No GPS Lock";
display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine); display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
} else { } else {
@@ -557,7 +557,7 @@ static void drawGPScoordinates(OLEDDisplay *display, int16_t x, int16_t y, const
} }
// If fixed position, display text "Fixed GPS" alternating with the coordinates. // If fixed position, display text "Fixed GPS" alternating with the coordinates.
if (config.payloadVariant.position.fixed_position) { if (config.position.fixed_position) {
if ((millis() / 10000) % 2) { if ((millis() / 10000) % 2) {
display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(coordinateLine))) / 2, y, coordinateLine); display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(coordinateLine))) / 2, y, coordinateLine);
} else { } else {
@@ -994,7 +994,7 @@ int32_t Screen::runOnce()
} }
#ifndef DISABLE_WELCOME_UNSET #ifndef DISABLE_WELCOME_UNSET
if (showingNormalScreen && config.payloadVariant.lora.region == Config_LoRaConfig_RegionCode_Unset) { if (showingNormalScreen && config.lora.region == Config_LoRaConfig_RegionCode_Unset) {
setWelcomeFrames(); setWelcomeFrames();
} }
#endif #endif
@@ -1067,8 +1067,8 @@ int32_t Screen::runOnce()
// standard screen switching is stopped. // standard screen switching is stopped.
if (showingNormalScreen) { if (showingNormalScreen) {
// standard screen loop handling here // standard screen loop handling here
if (config.payloadVariant.display.auto_screen_carousel_secs > 0 && if (config.display.auto_screen_carousel_secs > 0 &&
(millis() - lastScreenTransition) > (config.payloadVariant.display.auto_screen_carousel_secs * 1000)) { (millis() - lastScreenTransition) > (config.display.auto_screen_carousel_secs * 1000)) {
DEBUG_MSG("LastScreenTransition exceeded %ums transitioning to next frame\n", (millis() - lastScreenTransition)); DEBUG_MSG("LastScreenTransition exceeded %ums transitioning to next frame\n", (millis() - lastScreenTransition));
handleOnPress(); handleOnPress();
} }
@@ -1343,8 +1343,8 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
{ {
#ifdef HAS_WIFI #ifdef HAS_WIFI
const char *wifiName = config.payloadVariant.wifi.ssid; const char *wifiName = config.wifi.ssid;
const char *wifiPsw = config.payloadVariant.wifi.psk; const char *wifiPsw = config.wifi.psk;
displayedNodeNum = 0; // Not currently showing a node pane displayedNodeNum = 0; // Not currently showing a node pane
@@ -1355,7 +1355,7 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
if (isSoftAPForced()) { if (isSoftAPForced()) {
display->drawString(x, y, String("WiFi: Software AP (Admin)")); display->drawString(x, y, String("WiFi: Software AP (Admin)"));
} else if (config.payloadVariant.wifi.ap_mode) { } else if (config.wifi.ap_mode) {
display->drawString(x, y, String("WiFi: Software AP")); display->drawString(x, y, String("WiFi: Software AP"));
} else if (WiFi.status() != WL_CONNECTED) { } else if (WiFi.status() != WL_CONNECTED) {
display->drawString(x, y, String("WiFi: Not Connected")); display->drawString(x, y, String("WiFi: Not Connected"));
@@ -1378,8 +1378,8 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
- WL_NO_SHIELD: assigned when no WiFi shield is present; - WL_NO_SHIELD: assigned when no WiFi shield is present;
*/ */
if (WiFi.status() == WL_CONNECTED || isSoftAPForced() || config.payloadVariant.wifi.ap_mode) { if (WiFi.status() == WL_CONNECTED || isSoftAPForced() || config.wifi.ap_mode) {
if (config.payloadVariant.wifi.ap_mode || isSoftAPForced()) { if (config.wifi.ap_mode || isSoftAPForced()) {
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "IP: " + String(WiFi.softAPIP().toString().c_str())); display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "IP: " + String(WiFi.softAPIP().toString().c_str()));
// Number of connections to the AP. Default max for the esp32 is 4 // Number of connections to the AP. Default max for the esp32 is 4
@@ -1471,7 +1471,7 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
} }
} else { } else {
if (config.payloadVariant.wifi.ap_mode) { if (config.wifi.ap_mode) {
if ((millis() / 10000) % 2) { if ((millis() / 10000) % 2) {
display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName)); display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName));
} else { } else {
@@ -1518,7 +1518,7 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
auto mode = ""; auto mode = "";
switch (config.payloadVariant.lora.modem_preset) { switch (config.lora.modem_preset) {
case Config_LoRaConfig_ModemPreset_ShortSlow: case Config_LoRaConfig_ModemPreset_ShortSlow:
mode = "ShortSlow"; mode = "ShortSlow";
break; break;
@@ -1595,7 +1595,7 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(chUtil), y + FONT_HEIGHT_SMALL * 1, chUtil); display->drawString(x + SCREEN_WIDTH - display->getStringWidth(chUtil), y + FONT_HEIGHT_SMALL * 1, chUtil);
// Line 3 // Line 3
if (config.payloadVariant.display.gps_format != if (config.display.gps_format !=
Config_DisplayConfig_GpsCoordinateFormat_GpsFormatDMS) // if DMS then don't draw altitude Config_DisplayConfig_GpsCoordinateFormat_GpsFormatDMS) // if DMS then don't draw altitude
drawGPSAltitude(display, x, y + FONT_HEIGHT_SMALL * 2, gpsStatus); drawGPSAltitude(display, x, y + FONT_HEIGHT_SMALL * 2, gpsStatus);
+8 -8
View File
@@ -7,19 +7,19 @@ RotaryEncoderInterruptImpl1::RotaryEncoderInterruptImpl1() : RotaryEncoderInterr
void RotaryEncoderInterruptImpl1::init() void RotaryEncoderInterruptImpl1::init()
{ {
if (!moduleConfig.payloadVariant.canned_message.rotary1_enabled) { if (!moduleConfig.canned_message.rotary1_enabled) {
// Input device is disabled. // Input device is disabled.
return; return;
} }
uint8_t pinA = moduleConfig.payloadVariant.canned_message.inputbroker_pin_a; uint8_t pinA = moduleConfig.canned_message.inputbroker_pin_a;
uint8_t pinB = moduleConfig.payloadVariant.canned_message.inputbroker_pin_b; uint8_t pinB = moduleConfig.canned_message.inputbroker_pin_b;
uint8_t pinPress = moduleConfig.payloadVariant.canned_message.inputbroker_pin_press; uint8_t pinPress = moduleConfig.canned_message.inputbroker_pin_press;
char eventCw = static_cast<char>(moduleConfig.payloadVariant.canned_message.inputbroker_event_cw); char eventCw = static_cast<char>(moduleConfig.canned_message.inputbroker_event_cw);
char eventCcw = static_cast<char>(moduleConfig.payloadVariant.canned_message.inputbroker_event_ccw); char eventCcw = static_cast<char>(moduleConfig.canned_message.inputbroker_event_ccw);
char eventPressed = static_cast<char>(moduleConfig.payloadVariant.canned_message.inputbroker_event_press); char eventPressed = static_cast<char>(moduleConfig.canned_message.inputbroker_event_press);
// moduleConfig.payloadVariant.canned_message.ext_notification_module_output // moduleConfig.canned_message.ext_notification_module_output
RotaryEncoderInterruptBase::init(pinA, pinB, pinPress, eventCw, eventCcw, eventPressed, RotaryEncoderInterruptBase::init(pinA, pinB, pinPress, eventCw, eventCcw, eventPressed,
RotaryEncoderInterruptImpl1::handleIntA, RotaryEncoderInterruptImpl1::handleIntB, RotaryEncoderInterruptImpl1::handleIntA, RotaryEncoderInterruptImpl1::handleIntB,
RotaryEncoderInterruptImpl1::handleIntPressed); RotaryEncoderInterruptImpl1::handleIntPressed);
+4 -4
View File
@@ -8,14 +8,14 @@ UpDownInterruptImpl1::UpDownInterruptImpl1() : UpDownInterruptBase("upDown1") {}
void UpDownInterruptImpl1::init() void UpDownInterruptImpl1::init()
{ {
if (!moduleConfig.payloadVariant.canned_message.updown1_enabled) { if (!moduleConfig.canned_message.updown1_enabled) {
// Input device is disabled. // Input device is disabled.
return; return;
} }
uint8_t pinUp = moduleConfig.payloadVariant.canned_message.inputbroker_pin_a; uint8_t pinUp = moduleConfig.canned_message.inputbroker_pin_a;
uint8_t pinDown = moduleConfig.payloadVariant.canned_message.inputbroker_pin_b; uint8_t pinDown = moduleConfig.canned_message.inputbroker_pin_b;
uint8_t pinPress = moduleConfig.payloadVariant.canned_message.inputbroker_pin_press; uint8_t pinPress = moduleConfig.canned_message.inputbroker_pin_press;
char eventDown = static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_KEY_DOWN); char eventDown = static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_KEY_DOWN);
char eventUp = static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_KEY_UP); char eventUp = static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_KEY_UP);
+1 -1
View File
@@ -148,7 +148,7 @@ void setup()
#endif #endif
#ifdef DEBUG_PORT #ifdef DEBUG_PORT
if (!config.payloadVariant.device.serial_disabled) { if (!config.device.serial_disabled) {
consoleInit(); // Set serial baud rate and init our mesh console consoleInit(); // Set serial baud rate and init our mesh console
} }
#endif #endif
+3 -3
View File
@@ -83,7 +83,7 @@ void Channels::initDefaultChannel(ChannelIndex chIndex)
{ {
Channel &ch = getByIndex(chIndex); Channel &ch = getByIndex(chIndex);
ChannelSettings &channelSettings = ch.settings; ChannelSettings &channelSettings = ch.settings;
Config_LoRaConfig &loraConfig = config.payloadVariant.lora; Config_LoRaConfig &loraConfig = config.lora;
loraConfig.modem_preset = Config_LoRaConfig_ModemPreset_LongFast; // Default to Long Range & Fast loraConfig.modem_preset = Config_LoRaConfig_ModemPreset_LongFast; // Default to Long Range & Fast
@@ -210,10 +210,10 @@ const char *Channels::getName(size_t chIndex)
// Per mesh.proto spec, if bandwidth is specified we must ignore modemPreset enum, we assume that in that case // Per mesh.proto spec, if bandwidth is specified we must ignore modemPreset enum, we assume that in that case
// the app fucked up and forgot to set channelSettings.name // the app fucked up and forgot to set channelSettings.name
if (config.payloadVariant.lora.bandwidth != 0) if (config.lora.bandwidth != 0)
channelName = "Unset"; channelName = "Unset";
else else
switch (config.payloadVariant.lora.modem_preset) { switch (config.lora.modem_preset) {
case Config_LoRaConfig_ModemPreset_ShortSlow: case Config_LoRaConfig_ModemPreset_ShortSlow:
channelName = "ShortSlow"; channelName = "ShortSlow";
break; break;
+1 -1
View File
@@ -32,7 +32,7 @@ void FloodingRouter::sniffReceived(const MeshPacket *p, const Routing *c)
if ((p->to == NODENUM_BROADCAST) && (p->hop_limit > 0) && (getFrom(p) != getNodeNum())) { if ((p->to == NODENUM_BROADCAST) && (p->hop_limit > 0) && (getFrom(p) != getNodeNum())) {
if (p->id != 0) { if (p->id != 0) {
if (config.payloadVariant.device.role != Config_DeviceConfig_Role_ClientMute) { if (config.device.role != Config_DeviceConfig_Role_ClientMute) {
MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it
tosend->hop_limit--; // bump down the hop count tosend->hop_limit--; // bump down the hop count
+1 -1
View File
@@ -236,7 +236,7 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus)
#ifdef GPS_EXTRAVERBOSE #ifdef GPS_EXTRAVERBOSE
DEBUG_MSG("onGPSchanged() - lost validLocation\n"); DEBUG_MSG("onGPSchanged() - lost validLocation\n");
#endif #endif
if (config.payloadVariant.position.fixed_position) { if (config.position.fixed_position) {
DEBUG_MSG("WARNING: Using fixed position\n"); DEBUG_MSG("WARNING: Using fixed position\n");
pos = node->position; pos = node->position;
} }
+31 -18
View File
@@ -34,8 +34,8 @@ NodeDB nodeDB;
// we have plenty of ram so statically alloc this tempbuf (for now) // we have plenty of ram so statically alloc this tempbuf (for now)
EXT_RAM_ATTR DeviceState devicestate; EXT_RAM_ATTR DeviceState devicestate;
MyNodeInfo &myNodeInfo = devicestate.my_node; MyNodeInfo &myNodeInfo = devicestate.my_node;
Config config; LocalConfig config;
ModuleConfig moduleConfig; LocalModuleConfig moduleConfig;
ChannelFile channelFile; ChannelFile channelFile;
/** The current change # for radio settings. Starts at 0 on boot and any time the radio settings /** The current change # for radio settings. Starts at 0 on boot and any time the radio settings
@@ -88,7 +88,7 @@ bool NodeDB::resetRadioConfig()
radioGeneration++; radioGeneration++;
// radioConfig.has_preferences = true; // radioConfig.has_preferences = true;
if (config.payloadVariant.device.factory_reset) { if (config.device.factory_reset) {
DEBUG_MSG("Performing factory reset!\n"); DEBUG_MSG("Performing factory reset!\n");
installDefaultDeviceState(); installDefaultDeviceState();
#ifndef NO_ESP32 #ifndef NO_ESP32
@@ -126,11 +126,11 @@ bool NodeDB::resetRadioConfig()
DEBUG_MSG("***** DEVELOPMENT MODE - DO NOT RELEASE *****\n"); DEBUG_MSG("***** DEVELOPMENT MODE - DO NOT RELEASE *****\n");
// Sleep quite frequently to stress test the BLE comms, broadcast position every 6 mins // Sleep quite frequently to stress test the BLE comms, broadcast position every 6 mins
config.payloadVariant.display.screen_on_secs = 10; config.display.screen_on_secs = 10;
config.payloadVariant.power.wait_bluetooth_secs = 10; config.power.wait_bluetooth_secs = 10;
config.payloadVariant.position.position_broadcast_secs = 6 * 60; config.position.position_broadcast_secs = 6 * 60;
config.payloadVariant.power.ls_secs = 60; config.power.ls_secs = 60;
config.payloadVariant.lora.region = Config_LoRaConfig_RegionCode_TW; config.lora.region = Config_LoRaConfig_RegionCode_TW;
// Enter super deep sleep soon and stay there not very long // Enter super deep sleep soon and stay there not very long
// radioConfig.preferences.mesh_sds_timeout_secs = 10; // radioConfig.preferences.mesh_sds_timeout_secs = 10;
@@ -145,13 +145,19 @@ bool NodeDB::resetRadioConfig()
void NodeDB::installDefaultConfig() void NodeDB::installDefaultConfig()
{ {
memset(&config, 0, sizeof(config)); memset(&config, 0, sizeof(LocalConfig));
strncpy(config.payloadVariant.device.ntp_server, "0.pool.ntp.org", 32); config.lora.region = Config_LoRaConfig_RegionCode_Unset;
config.lora.modem_preset = Config_LoRaConfig_ModemPreset_LongFast;
resetRadioConfig();
strncpy(config.device.ntp_server, "0.pool.ntp.org", 32);
// for backward compat, default position flags are ALT+MSL
config.position.position_flags =
(Config_PositionConfig_PositionFlags_POS_ALTITUDE | Config_PositionConfig_PositionFlags_POS_ALT_MSL);
} }
void NodeDB::installDefaultModuleConfig() void NodeDB::installDefaultModuleConfig()
{ {
memset(&moduleConfig, 0, sizeof(moduleConfig)); memset(&moduleConfig, 0, sizeof(ModuleConfig));
} }
// void NodeDB::installDefaultRadioConfig() // void NodeDB::installDefaultRadioConfig()
@@ -161,19 +167,19 @@ void NodeDB::installDefaultModuleConfig()
// resetRadioConfig(); // resetRadioConfig();
// // for backward compat, default position flags are BAT+ALT+MSL (0x23 = 35) // // for backward compat, default position flags are BAT+ALT+MSL (0x23 = 35)
// config.payloadVariant.position.position_flags = // config.position.position_flags =
// (Config_PositionConfig_PositionFlags_POS_BATTERY | Config_PositionConfig_PositionFlags_POS_ALTITUDE | // (Config_PositionConfig_PositionFlags_POS_BATTERY | Config_PositionConfig_PositionFlags_POS_ALTITUDE |
// Config_PositionConfig_PositionFlags_POS_ALT_MSL); // Config_PositionConfig_PositionFlags_POS_ALT_MSL);
// } // }
void NodeDB::installDefaultChannels() void NodeDB::installDefaultChannels()
{ {
memset(&channelFile, 0, sizeof(channelFile)); memset(&channelFile, 0, sizeof(ChannelFile));
} }
void NodeDB::installDefaultDeviceState() void NodeDB::installDefaultDeviceState()
{ {
memset(&devicestate, 0, sizeof(devicestate)); memset(&devicestate, 0, sizeof(DeviceState));
*numNodes = 0; // Forget node DB *numNodes = 0; // Forget node DB
@@ -250,7 +256,7 @@ void NodeDB::init()
resetRadioConfig(); // If bogus settings got saved, then fix them resetRadioConfig(); // If bogus settings got saved, then fix them
DEBUG_MSG("region=%d, NODENUM=0x%x, dbsize=%d\n", config.payloadVariant.lora.region, myNodeInfo.my_node_num, *numNodes); DEBUG_MSG("region=%d, NODENUM=0x%x, dbsize=%d\n", config.lora.region, myNodeInfo.my_node_num, *numNodes);
} }
// We reserve a few nodenums for future use // We reserve a few nodenums for future use
@@ -331,7 +337,7 @@ void NodeDB::loadFromDisk()
} }
} }
if (!loadProto(configfile, Config_size, sizeof(Config), Config_fields, &config)) { if (!loadProto(configfile, LocalConfig_size, sizeof(LocalConfig), LocalConfig_fields, &config)) {
installDefaultConfig(); // Our in RAM copy might now be corrupt installDefaultConfig(); // Our in RAM copy might now be corrupt
} }
@@ -366,7 +372,7 @@ bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_
f.close(); f.close();
// brief window of risk here ;-) // brief window of risk here ;-)
if (!FSCom.remove(filename)) if (FSCom.exists(filename) && !FSCom.remove(filename))
DEBUG_MSG("Warning: Can't remove old pref file\n"); DEBUG_MSG("Warning: Can't remove old pref file\n");
if (!FSCom.rename(filenameTmp.c_str(), filename)) if (!FSCom.rename(filenameTmp.c_str(), filename))
DEBUG_MSG("Error: can't rename new pref file\n"); DEBUG_MSG("Error: can't rename new pref file\n");
@@ -396,7 +402,14 @@ void NodeDB::saveToDisk()
FSCom.mkdir("/prefs"); FSCom.mkdir("/prefs");
#endif #endif
saveProto(preffile, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate); saveProto(preffile, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate);
saveProto(configfile, Config_size, sizeof(Config), Config_fields, &config); // save all config segments
config.has_device = true;
config.has_display = true;
config.has_lora = true;
config.has_position = true;
config.has_power = true;
config.has_wifi = true;
saveProto(configfile, LocalConfig_size, sizeof(LocalConfig), LocalConfig_fields, &config);
saveProto(moduleConfigfile, Module_Config_size, sizeof(ModuleConfig), ModuleConfig_fields, &moduleConfig); saveProto(moduleConfigfile, Module_Config_size, sizeof(ModuleConfig), ModuleConfig_fields, &moduleConfig);
saveChannelsToDisk(); saveChannelsToDisk();
+3 -3
View File
@@ -11,8 +11,8 @@
extern DeviceState devicestate; extern DeviceState devicestate;
extern ChannelFile channelFile; extern ChannelFile channelFile;
extern MyNodeInfo &myNodeInfo; extern MyNodeInfo &myNodeInfo;
extern Config config; extern LocalConfig config;
extern ModuleConfig moduleConfig; extern LocalModuleConfig moduleConfig;
extern User &owner; extern User &owner;
/// Given a node, return how many seconds in the past (vs now) that we last heard from it /// Given a node, return how many seconds in the past (vs now) that we last heard from it
@@ -161,7 +161,7 @@ extern NodeDB nodeDB;
// Our delay functions check for this for times that should never expire // Our delay functions check for this for times that should never expire
#define NODE_DELAY_FOREVER 0xffffffff #define NODE_DELAY_FOREVER 0xffffffff
#define IF_ROUTER(routerVal, normalVal) ((config.payloadVariant.device.role == Config_DeviceConfig_Role_Router) ? (routerVal) : (normalVal)) #define IF_ROUTER(routerVal, normalVal) ((config.device.role == Config_DeviceConfig_Role_Router) ? (routerVal) : (normalVal))
#define default_broadcast_interval_secs IF_ROUTER(12 * 60 * 60, 15 * 60) #define default_broadcast_interval_secs IF_ROUTER(12 * 60 * 60, 15 * 60)
#define default_wait_bluetooth_secs IF_ROUTER(1, 60) #define default_wait_bluetooth_secs IF_ROUTER(1, 60)
+5 -5
View File
@@ -100,10 +100,10 @@ const RegionInfo *myRegion;
void initRegion() void initRegion()
{ {
const RegionInfo *r = regions; const RegionInfo *r = regions;
for (; r->code != Config_LoRaConfig_RegionCode_Unset && r->code != config.payloadVariant.lora.region; r++) for (; r->code != Config_LoRaConfig_RegionCode_Unset && r->code != config.lora.region; r++)
; ;
myRegion = r; myRegion = r;
DEBUG_MSG("Wanted region %d, using %s\n", config.payloadVariant.lora.region, r->name); DEBUG_MSG("Wanted region %d, using %s\n", config.lora.region, r->name);
} }
/** /**
@@ -208,8 +208,8 @@ uint32_t RadioInterface::getTxDelayMsecWeighted(float snr)
// low SNR = Short Delay // low SNR = Short Delay
uint32_t delay = 0; uint32_t delay = 0;
if (config.payloadVariant.device.role == Config_DeviceConfig_Role_Router || if (config.device.role == Config_DeviceConfig_Role_Router ||
config.payloadVariant.device.role == Config_DeviceConfig_Role_RouterClient) { config.device.role == Config_DeviceConfig_Role_RouterClient) {
delay = map(snr, SNR_MIN, SNR_MAX, MIN_TX_WAIT_MSEC, (MIN_TX_WAIT_MSEC + (shortPacketMsec / 2))); delay = map(snr, SNR_MIN, SNR_MAX, MIN_TX_WAIT_MSEC, (MIN_TX_WAIT_MSEC + (shortPacketMsec / 2)));
DEBUG_MSG("rx_snr found in packet. As a router, setting tx delay:%d\n", delay); DEBUG_MSG("rx_snr found in packet. As a router, setting tx delay:%d\n", delay);
} else { } else {
@@ -357,7 +357,7 @@ void RadioInterface::applyModemConfig()
{ {
// Set up default configuration // Set up default configuration
// No Sync Words in LORA mode // No Sync Words in LORA mode
Config_LoRaConfig &loraConfig = config.payloadVariant.lora; Config_LoRaConfig &loraConfig = config.lora;
auto channelSettings = channels.getPrimary(); auto channelSettings = channels.getPrimary();
if (loraConfig.spread_factor == 0) { if (loraConfig.spread_factor == 0) {
switch (loraConfig.modem_preset) { switch (loraConfig.modem_preset) {
+3 -3
View File
@@ -93,8 +93,8 @@ bool RadioLibInterface::canSendImmediately()
/// bluetooth comms code. If the txmit queue is empty it might return an error /// bluetooth comms code. If the txmit queue is empty it might return an error
ErrorCode RadioLibInterface::send(MeshPacket *p) ErrorCode RadioLibInterface::send(MeshPacket *p)
{ {
if (config.payloadVariant.lora.region != Config_LoRaConfig_RegionCode_Unset) { if (config.lora.region != Config_LoRaConfig_RegionCode_Unset) {
if (disabled || config.payloadVariant.lora.tx_disabled) { if (disabled || config.lora.tx_disabled) {
DEBUG_MSG("send - lora_tx_disabled\n"); DEBUG_MSG("send - lora_tx_disabled\n");
packetPool.release(p); packetPool.release(p);
return ERRNO_DISABLED; return ERRNO_DISABLED;
@@ -345,7 +345,7 @@ void RadioLibInterface::handleReceiveInterrupt()
void RadioLibInterface::startSend(MeshPacket *txp) void RadioLibInterface::startSend(MeshPacket *txp)
{ {
printPacket("Starting low level send", txp); printPacket("Starting low level send", txp);
if (disabled || config.payloadVariant.lora.tx_disabled) { if (disabled || config.lora.tx_disabled) {
DEBUG_MSG("startSend is dropping tx packet because we are disabled\n"); DEBUG_MSG("startSend is dropping tx packet because we are disabled\n");
packetPool.release(txp); packetPool.release(txp);
} else { } else {
+2 -2
View File
@@ -17,8 +17,8 @@ ErrorCode ReliableRouter::send(MeshPacket *p)
// message will rebroadcast. But asking for hop_limit 0 in that context means the client app has no preference on hop // message will rebroadcast. But asking for hop_limit 0 in that context means the client app has no preference on hop
// counts and we want this message to get through the whole mesh, so use the default. // counts and we want this message to get through the whole mesh, so use the default.
if (p->to == NODENUM_BROADCAST && p->hop_limit == 0) { if (p->to == NODENUM_BROADCAST && p->hop_limit == 0) {
if (config.payloadVariant.lora.hop_limit && config.payloadVariant.lora.hop_limit <= HOP_MAX) { if (config.lora.hop_limit && config.lora.hop_limit <= HOP_MAX) {
p->hop_limit = (config.payloadVariant.lora.hop_limit >= HOP_MAX) ? HOP_MAX : config.payloadVariant.lora.hop_limit; p->hop_limit = (config.lora.hop_limit >= HOP_MAX) ? HOP_MAX : config.lora.hop_limit;
} else { } else {
p->hop_limit = HOP_RELIABLE; p->hop_limit = HOP_RELIABLE;
} }
+4 -4
View File
@@ -118,8 +118,8 @@ MeshPacket *Router::allocForSending()
p->which_payloadVariant = MeshPacket_decoded_tag; // Assume payload is decoded at start. p->which_payloadVariant = MeshPacket_decoded_tag; // Assume payload is decoded at start.
p->from = nodeDB.getNodeNum(); p->from = nodeDB.getNodeNum();
p->to = NODENUM_BROADCAST; p->to = NODENUM_BROADCAST;
if (config.payloadVariant.lora.hop_limit && config.payloadVariant.lora.hop_limit <= HOP_MAX) { if (config.lora.hop_limit && config.lora.hop_limit <= HOP_MAX) {
p->hop_limit = (config.payloadVariant.lora.hop_limit >= HOP_MAX) ? HOP_MAX : config.payloadVariant.lora.hop_limit; p->hop_limit = (config.lora.hop_limit >= HOP_MAX) ? HOP_MAX : config.lora.hop_limit;
} else { } else {
p->hop_limit = HOP_RELIABLE; p->hop_limit = HOP_RELIABLE;
} }
@@ -227,7 +227,7 @@ ErrorCode Router::send(MeshPacket *p)
*/ */
bool shouldActuallyEncrypt = true; bool shouldActuallyEncrypt = true;
if (*moduleConfig.payloadVariant.mqtt.address && !moduleConfig.payloadVariant.mqtt.encryption_enabled) { if (*moduleConfig.mqtt.address && !moduleConfig.mqtt.encryption_enabled) {
shouldActuallyEncrypt = false; shouldActuallyEncrypt = false;
} }
@@ -436,7 +436,7 @@ void Router::handleReceived(MeshPacket *p, RxSource src)
void Router::perhapsHandleReceived(MeshPacket *p) void Router::perhapsHandleReceived(MeshPacket *p)
{ {
// assert(radioConfig.has_preferences); // assert(radioConfig.has_preferences);
bool ignore = is_in_repeated(config.payloadVariant.lora.ignore_incoming, p->from); bool ignore = is_in_repeated(config.lora.ignore_incoming, p->from);
if (ignore) if (ignore)
DEBUG_MSG("Ignoring incoming message, 0x%x is in our ignore list\n", p->from); DEBUG_MSG("Ignoring incoming message, 0x%x is in our ignore list\n", p->from);
+1 -1
View File
@@ -610,7 +610,7 @@ void handleReport(HTTPRequest *req, HTTPResponse *res)
// data->wifi // data->wifi
String ipStr; String ipStr;
if (config.payloadVariant.wifi.ap_mode || isSoftAPForced()) { if (config.wifi.ap_mode || isSoftAPForced()) {
ipStr = String(WiFi.softAPIP().toString()); ipStr = String(WiFi.softAPIP().toString());
} else { } else {
ipStr = String(WiFi.localIP().toString()); ipStr = String(WiFi.localIP().toString());
+11 -11
View File
@@ -28,7 +28,7 @@ DNSServer dnsServer;
WiFiUDP ntpUDP; WiFiUDP ntpUDP;
#ifndef DISABLE_NTP #ifndef DISABLE_NTP
NTPClient timeClient(ntpUDP, config.payloadVariant.device.ntp_server); NTPClient timeClient(ntpUDP, config.device.ntp_server);
#endif #endif
uint8_t wifiDisconnectReason = 0; uint8_t wifiDisconnectReason = 0;
@@ -59,8 +59,8 @@ static WifiSleepObserver wifiSleepObserver;
static int32_t reconnectWiFi() static int32_t reconnectWiFi()
{ {
const char *wifiName = config.payloadVariant.wifi.ssid; const char *wifiName = config.wifi.ssid;
const char *wifiPsw = config.payloadVariant.wifi.psk; const char *wifiPsw = config.wifi.psk;
if (needReconnect && !WiFi.isConnected()) { if (needReconnect && !WiFi.isConnected()) {
// if (radioConfig.has_preferences && needReconnect && !WiFi.isConnected()) { // if (radioConfig.has_preferences && needReconnect && !WiFi.isConnected()) {
@@ -114,7 +114,7 @@ bool isWifiAvailable()
return true; return true;
} }
const char *wifiName = config.payloadVariant.wifi.ssid; const char *wifiName = config.wifi.ssid;
if (*wifiName) { if (*wifiName) {
return true; return true;
@@ -184,14 +184,14 @@ bool initWifi(bool forceSoftAP)
{ {
forcedSoftAP = forceSoftAP; forcedSoftAP = forceSoftAP;
if ((config.payloadVariant.wifi.ssid[0]) || forceSoftAP) { if ((config.wifi.ssid[0]) || forceSoftAP) {
// if ((radioConfig.has_preferences && config.payloadVariant.wifi.ssid[0]) || forceSoftAP) { // if ((radioConfig.has_preferences && config.wifi.ssid[0]) || forceSoftAP) {
const char *wifiName = config.payloadVariant.wifi.ssid; const char *wifiName = config.wifi.ssid;
const char *wifiPsw = config.payloadVariant.wifi.psk; const char *wifiPsw = config.wifi.psk;
if (forceSoftAP) { if (forceSoftAP) {
DEBUG_MSG("WiFi ... Forced AP Mode\n"); DEBUG_MSG("WiFi ... Forced AP Mode\n");
} else if (config.payloadVariant.wifi.ap_mode) { } else if (config.wifi.ap_mode) {
DEBUG_MSG("WiFi ... AP Mode\n"); DEBUG_MSG("WiFi ... AP Mode\n");
} else { } else {
DEBUG_MSG("WiFi ... Client Mode\n"); DEBUG_MSG("WiFi ... Client Mode\n");
@@ -203,7 +203,7 @@ bool initWifi(bool forceSoftAP)
wifiPsw = NULL; wifiPsw = NULL;
if (*wifiName || forceSoftAP) { if (*wifiName || forceSoftAP) {
if (config.payloadVariant.wifi.ap_mode || forceSoftAP) { if (config.wifi.ap_mode || forceSoftAP) {
IPAddress apIP(192, 168, 42, 1); IPAddress apIP(192, 168, 42, 1);
WiFi.onEvent(WiFiEvent); WiFi.onEvent(WiFiEvent);
@@ -362,7 +362,7 @@ static void WiFiEvent(WiFiEvent_t event)
void handleDNSResponse() void handleDNSResponse()
{ {
if (config.payloadVariant.wifi.ap_mode || isSoftAPForced()) { if (config.wifi.ap_mode || isSoftAPForced()) {
dnsServer.processNextRequest(); dnsServer.processNextRequest();
} }
} }
+27 -27
View File
@@ -176,27 +176,27 @@ void AdminModule::handleSetConfig(const Config &c)
switch (c.which_payloadVariant) { switch (c.which_payloadVariant) {
case Config_device_tag: case Config_device_tag:
DEBUG_MSG("Setting config: Device\n"); DEBUG_MSG("Setting config: Device\n");
config.payloadVariant.device = c.payloadVariant.device; config.device = c.payloadVariant.device;
break; break;
case Config_position_tag: case Config_position_tag:
DEBUG_MSG("Setting config: Position\n"); DEBUG_MSG("Setting config: Position\n");
config.payloadVariant.position = c.payloadVariant.position; config.position = c.payloadVariant.position;
break; break;
case Config_power_tag: case Config_power_tag:
DEBUG_MSG("Setting config: Power\n"); DEBUG_MSG("Setting config: Power\n");
config.payloadVariant.power = c.payloadVariant.power; config.power = c.payloadVariant.power;
break; break;
case Config_wifi_tag: case Config_wifi_tag:
DEBUG_MSG("Setting config: WiFi\n"); DEBUG_MSG("Setting config: WiFi\n");
config.payloadVariant.wifi = c.payloadVariant.wifi; config.wifi = c.payloadVariant.wifi;
break; break;
case Config_display_tag: case Config_display_tag:
DEBUG_MSG("Setting config: Display\n"); DEBUG_MSG("Setting config: Display\n");
config.payloadVariant.display = c.payloadVariant.display; config.display = c.payloadVariant.display;
break; break;
case Config_lora_tag: case Config_lora_tag:
DEBUG_MSG("Setting config: LoRa\n"); DEBUG_MSG("Setting config: LoRa\n");
config.payloadVariant.lora = c.payloadVariant.lora; config.lora = c.payloadVariant.lora;
break; break;
} }
@@ -208,31 +208,31 @@ void AdminModule::handleSetModuleConfig(const ModuleConfig &c)
switch (c.which_payloadVariant) { switch (c.which_payloadVariant) {
case ModuleConfig_mqtt_tag: case ModuleConfig_mqtt_tag:
DEBUG_MSG("Setting module config: MQTT\n"); DEBUG_MSG("Setting module config: MQTT\n");
moduleConfig.payloadVariant.mqtt = c.payloadVariant.mqtt; moduleConfig.mqtt = c.payloadVariant.mqtt;
break; break;
case ModuleConfig_serial_tag: case ModuleConfig_serial_tag:
DEBUG_MSG("Setting module config: Serial\n"); DEBUG_MSG("Setting module config: Serial\n");
moduleConfig.payloadVariant.serial = c.payloadVariant.serial; moduleConfig.serial = c.payloadVariant.serial;
break; break;
case ModuleConfig_external_notification_tag: case ModuleConfig_external_notification_tag:
DEBUG_MSG("Setting module config: External Notification\n"); DEBUG_MSG("Setting module config: External Notification\n");
moduleConfig.payloadVariant.external_notification = c.payloadVariant.external_notification; moduleConfig.external_notification = c.payloadVariant.external_notification;
break; break;
case ModuleConfig_store_forward_tag: case ModuleConfig_store_forward_tag:
DEBUG_MSG("Setting module config: Store & Forward\n"); DEBUG_MSG("Setting module config: Store & Forward\n");
moduleConfig.payloadVariant.store_forward = c.payloadVariant.store_forward; moduleConfig.store_forward = c.payloadVariant.store_forward;
break; break;
case ModuleConfig_range_test_tag: case ModuleConfig_range_test_tag:
DEBUG_MSG("Setting module config: Range Test\n"); DEBUG_MSG("Setting module config: Range Test\n");
moduleConfig.payloadVariant.range_test = c.payloadVariant.range_test; moduleConfig.range_test = c.payloadVariant.range_test;
break; break;
case ModuleConfig_telemetry_tag: case ModuleConfig_telemetry_tag:
DEBUG_MSG("Setting module config: Telemetry\n"); DEBUG_MSG("Setting module config: Telemetry\n");
moduleConfig.payloadVariant.telemetry = c.payloadVariant.telemetry; moduleConfig.telemetry = c.payloadVariant.telemetry;
break; break;
case ModuleConfig_canned_message_tag: case ModuleConfig_canned_message_tag:
DEBUG_MSG("Setting module config: Canned Message\n"); DEBUG_MSG("Setting module config: Canned Message\n");
moduleConfig.payloadVariant.canned_message = c.payloadVariant.canned_message; moduleConfig.canned_message = c.payloadVariant.canned_message;
break; break;
} }
@@ -271,33 +271,33 @@ void AdminModule::handleGetConfig(const MeshPacket &req, const uint32_t configTy
case AdminMessage_ConfigType_DEVICE_CONFIG: case AdminMessage_ConfigType_DEVICE_CONFIG:
DEBUG_MSG("Getting config: Device\n"); DEBUG_MSG("Getting config: Device\n");
res.get_config_response.which_payloadVariant = Config_device_tag; res.get_config_response.which_payloadVariant = Config_device_tag;
res.get_config_response.payloadVariant.device = config.payloadVariant.device; res.get_config_response.payloadVariant.device = config.device;
break; break;
case AdminMessage_ConfigType_POSITION_CONFIG: case AdminMessage_ConfigType_POSITION_CONFIG:
DEBUG_MSG("Getting config: Position\n"); DEBUG_MSG("Getting config: Position\n");
res.get_config_response.which_payloadVariant = Config_position_tag; res.get_config_response.which_payloadVariant = Config_position_tag;
res.get_config_response.payloadVariant.position = config.payloadVariant.position; res.get_config_response.payloadVariant.position = config.position;
break; break;
case AdminMessage_ConfigType_POWER_CONFIG: case AdminMessage_ConfigType_POWER_CONFIG:
DEBUG_MSG("Getting config: Power\n"); DEBUG_MSG("Getting config: Power\n");
res.get_config_response.which_payloadVariant = Config_power_tag; res.get_config_response.which_payloadVariant = Config_power_tag;
res.get_config_response.payloadVariant.power = config.payloadVariant.power; res.get_config_response.payloadVariant.power = config.power;
break; break;
case AdminMessage_ConfigType_WIFI_CONFIG: case AdminMessage_ConfigType_WIFI_CONFIG:
DEBUG_MSG("Getting config: WiFi\n"); DEBUG_MSG("Getting config: WiFi\n");
res.get_config_response.which_payloadVariant = Config_wifi_tag; res.get_config_response.which_payloadVariant = Config_wifi_tag;
res.get_config_response.payloadVariant.wifi = config.payloadVariant.wifi; res.get_config_response.payloadVariant.wifi = config.wifi;
writeSecret(res.get_config_response.payloadVariant.wifi.psk, config.payloadVariant.wifi.psk); writeSecret(res.get_config_response.payloadVariant.wifi.psk, config.wifi.psk);
break; break;
case AdminMessage_ConfigType_DISPLAY_CONFIG: case AdminMessage_ConfigType_DISPLAY_CONFIG:
DEBUG_MSG("Getting config: Display\n"); DEBUG_MSG("Getting config: Display\n");
res.get_config_response.which_payloadVariant = Config_display_tag; res.get_config_response.which_payloadVariant = Config_display_tag;
res.get_config_response.payloadVariant.display = config.payloadVariant.display; res.get_config_response.payloadVariant.display = config.display;
break; break;
case AdminMessage_ConfigType_LORA_CONFIG: case AdminMessage_ConfigType_LORA_CONFIG:
DEBUG_MSG("Getting config: LoRa\n"); DEBUG_MSG("Getting config: LoRa\n");
res.get_config_response.which_payloadVariant = Config_lora_tag; res.get_config_response.which_payloadVariant = Config_lora_tag;
res.get_config_response.payloadVariant.lora = config.payloadVariant.lora; res.get_config_response.payloadVariant.lora = config.lora;
break; break;
} }
@@ -323,38 +323,38 @@ void AdminModule::handleGetModuleConfig(const MeshPacket &req, const uint32_t co
case AdminMessage_ModuleConfigType_MQTT_CONFIG: case AdminMessage_ModuleConfigType_MQTT_CONFIG:
DEBUG_MSG("Getting module config: MQTT\n"); DEBUG_MSG("Getting module config: MQTT\n");
res.get_module_config_response.which_payloadVariant = ModuleConfig_mqtt_tag; res.get_module_config_response.which_payloadVariant = ModuleConfig_mqtt_tag;
res.get_module_config_response.payloadVariant.mqtt = moduleConfig.payloadVariant.mqtt; res.get_module_config_response.payloadVariant.mqtt = moduleConfig.mqtt;
break; break;
case AdminMessage_ModuleConfigType_SERIAL_CONFIG: case AdminMessage_ModuleConfigType_SERIAL_CONFIG:
DEBUG_MSG("Getting module config: Serial\n"); DEBUG_MSG("Getting module config: Serial\n");
res.get_module_config_response.which_payloadVariant = ModuleConfig_serial_tag; res.get_module_config_response.which_payloadVariant = ModuleConfig_serial_tag;
res.get_module_config_response.payloadVariant.serial = moduleConfig.payloadVariant.serial; res.get_module_config_response.payloadVariant.serial = moduleConfig.serial;
break; break;
case AdminMessage_ModuleConfigType_EXTNOTIF_CONFIG: case AdminMessage_ModuleConfigType_EXTNOTIF_CONFIG:
DEBUG_MSG("Getting module config: External Notification\n"); DEBUG_MSG("Getting module config: External Notification\n");
res.get_module_config_response.which_payloadVariant = ModuleConfig_external_notification_tag; res.get_module_config_response.which_payloadVariant = ModuleConfig_external_notification_tag;
res.get_module_config_response.payloadVariant.external_notification = res.get_module_config_response.payloadVariant.external_notification =
moduleConfig.payloadVariant.external_notification; moduleConfig.external_notification;
break; break;
case AdminMessage_ModuleConfigType_STOREFORWARD_CONFIG: case AdminMessage_ModuleConfigType_STOREFORWARD_CONFIG:
DEBUG_MSG("Getting module config: Store & Forward\n"); DEBUG_MSG("Getting module config: Store & Forward\n");
res.get_module_config_response.which_payloadVariant = ModuleConfig_store_forward_tag; res.get_module_config_response.which_payloadVariant = ModuleConfig_store_forward_tag;
res.get_module_config_response.payloadVariant.store_forward = moduleConfig.payloadVariant.store_forward; res.get_module_config_response.payloadVariant.store_forward = moduleConfig.store_forward;
break; break;
case AdminMessage_ModuleConfigType_RANGETEST_CONFIG: case AdminMessage_ModuleConfigType_RANGETEST_CONFIG:
DEBUG_MSG("Getting module config: Range Test\n"); DEBUG_MSG("Getting module config: Range Test\n");
res.get_module_config_response.which_payloadVariant = ModuleConfig_range_test_tag; res.get_module_config_response.which_payloadVariant = ModuleConfig_range_test_tag;
res.get_module_config_response.payloadVariant.range_test = moduleConfig.payloadVariant.range_test; res.get_module_config_response.payloadVariant.range_test = moduleConfig.range_test;
break; break;
case AdminMessage_ModuleConfigType_TELEMETRY_CONFIG: case AdminMessage_ModuleConfigType_TELEMETRY_CONFIG:
DEBUG_MSG("Getting module config: Telemetry\n"); DEBUG_MSG("Getting module config: Telemetry\n");
res.get_module_config_response.which_payloadVariant = ModuleConfig_telemetry_tag; res.get_module_config_response.which_payloadVariant = ModuleConfig_telemetry_tag;
res.get_module_config_response.payloadVariant.telemetry = moduleConfig.payloadVariant.telemetry; res.get_module_config_response.payloadVariant.telemetry = moduleConfig.telemetry;
break; break;
case AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG: case AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG:
DEBUG_MSG("Getting module config: Canned Message\n"); DEBUG_MSG("Getting module config: Canned Message\n");
res.get_module_config_response.which_payloadVariant = ModuleConfig_canned_message_tag; res.get_module_config_response.which_payloadVariant = ModuleConfig_canned_message_tag;
res.get_module_config_response.payloadVariant.canned_message = moduleConfig.payloadVariant.canned_message; res.get_module_config_response.payloadVariant.canned_message = moduleConfig.canned_message;
break; break;
} }
+7 -7
View File
@@ -28,7 +28,7 @@ extern bool saveProto(const char *filename, size_t protoSize, size_t objSize, co
CannedMessageModule::CannedMessageModule() CannedMessageModule::CannedMessageModule()
: SinglePortModule("canned", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread("CannedMessageModule") : SinglePortModule("canned", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread("CannedMessageModule")
{ {
if (moduleConfig.payloadVariant.canned_message.enabled) { if (moduleConfig.canned_message.enabled) {
this->loadProtoForModule(); this->loadProtoForModule();
if (this->splitConfiguredMessages() <= 0) { if (this->splitConfiguredMessages() <= 0) {
DEBUG_MSG("CannedMessageModule: No messages are configured. Module is disabled\n"); DEBUG_MSG("CannedMessageModule: No messages are configured. Module is disabled\n");
@@ -91,9 +91,9 @@ int CannedMessageModule::splitConfiguredMessages()
int CannedMessageModule::handleInputEvent(const InputEvent *event) int CannedMessageModule::handleInputEvent(const InputEvent *event)
{ {
if ((strlen(moduleConfig.payloadVariant.canned_message.allow_input_source) > 0) && if ((strlen(moduleConfig.canned_message.allow_input_source) > 0) &&
(strcmp(moduleConfig.payloadVariant.canned_message.allow_input_source, event->source) != 0) && (strcmp(moduleConfig.canned_message.allow_input_source, event->source) != 0) &&
(strcmp(moduleConfig.payloadVariant.canned_message.allow_input_source, "_any") != 0)) { (strcmp(moduleConfig.canned_message.allow_input_source, "_any") != 0)) {
// Event source is not accepted. // Event source is not accepted.
// Event only accepted if source matches the configured one, or // Event only accepted if source matches the configured one, or
// the configured one is "_any" (or if there is no configured // the configured one is "_any" (or if there is no configured
@@ -138,7 +138,7 @@ void CannedMessageModule::sendText(NodeNum dest, const char *message, bool wantR
p->want_ack = true; p->want_ack = true;
p->decoded.payload.size = strlen(message); p->decoded.payload.size = strlen(message);
memcpy(p->decoded.payload.bytes, message, p->decoded.payload.size); memcpy(p->decoded.payload.bytes, message, p->decoded.payload.size);
if (moduleConfig.payloadVariant.canned_message.send_bell) { if (moduleConfig.canned_message.send_bell) {
p->decoded.payload.bytes[p->decoded.payload.size - 1] = 7; // Bell character p->decoded.payload.bytes[p->decoded.payload.size - 1] = 7; // Bell character
p->decoded.payload.bytes[p->decoded.payload.size] = '\0'; // Bell character p->decoded.payload.bytes[p->decoded.payload.size] = '\0'; // Bell character
p->decoded.payload.size++; p->decoded.payload.size++;
@@ -151,7 +151,7 @@ void CannedMessageModule::sendText(NodeNum dest, const char *message, bool wantR
int32_t CannedMessageModule::runOnce() int32_t CannedMessageModule::runOnce()
{ {
if ((!moduleConfig.payloadVariant.canned_message.enabled) || (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED) || if ((!moduleConfig.canned_message.enabled) || (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED) ||
(this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE)) { (this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE)) {
return 30000; // TODO: should return MAX_VAL return 30000; // TODO: should return MAX_VAL
} }
@@ -214,7 +214,7 @@ const char *CannedMessageModule::getNextMessage()
} }
bool CannedMessageModule::shouldDraw() bool CannedMessageModule::shouldDraw()
{ {
if (!moduleConfig.payloadVariant.canned_message.enabled) { if (!moduleConfig.canned_message.enabled) {
return false; return false;
} }
return (currentMessageIndex != -1) || (this->runState != CANNED_MESSAGE_RUN_STATE_INACTIVE); return (currentMessageIndex != -1) || (this->runState != CANNED_MESSAGE_RUN_STATE_INACTIVE);
+32 -32
View File
@@ -19,26 +19,26 @@
Quick reference: Quick reference:
moduleConfig.payloadVariant.external_notification.enabled moduleConfig.external_notification.enabled
0 = Disabled (Default) 0 = Disabled (Default)
1 = Enabled 1 = Enabled
moduleConfig.payloadVariant.external_notification.active moduleConfig.external_notification.active
0 = Active Low (Default) 0 = Active Low (Default)
1 = Active High 1 = Active High
moduleConfig.payloadVariant.external_notification.alert_message moduleConfig.external_notification.alert_message
0 = Disabled (Default) 0 = Disabled (Default)
1 = Alert when a text message comes 1 = Alert when a text message comes
moduleConfig.payloadVariant.external_notification.alert_bell moduleConfig.external_notification.alert_bell
0 = Disabled (Default) 0 = Disabled (Default)
1 = Alert when the bell character is received 1 = Alert when the bell character is received
moduleConfig.payloadVariant.external_notification.output moduleConfig.external_notification.output
GPIO of the output. (Default = 13) GPIO of the output. (Default = 13)
moduleConfig.payloadVariant.external_notification.output_ms moduleConfig.external_notification.output_ms
Amount of time in ms for the alert. Default is 1000. Amount of time in ms for the alert. Default is 1000.
*/ */
@@ -59,19 +59,19 @@ int32_t ExternalNotificationModule::runOnce()
without having to configure it from the PythonAPI or WebUI. without having to configure it from the PythonAPI or WebUI.
*/ */
// moduleConfig.payloadVariant.external_notification.enabled = 1; // moduleConfig.external_notification.enabled = 1;
// moduleConfig.payloadVariant.external_notification.alert_message = 1; // moduleConfig.external_notification.alert_message = 1;
// moduleConfig.payloadVariant.external_notification.active = 1; // moduleConfig.external_notification.active = 1;
// moduleConfig.payloadVariant.external_notification.alert_bell = 1; // moduleConfig.external_notification.alert_bell = 1;
// moduleConfig.payloadVariant.external_notification.output_ms = 1000; // moduleConfig.external_notification.output_ms = 1000;
// moduleConfig.payloadVariant.external_notification.output = 13; // moduleConfig.external_notification.output = 13;
if (externalCurrentState) { if (externalCurrentState) {
// 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 + (moduleConfig.payloadVariant.external_notification.output_ms if (externalTurnedOn + (moduleConfig.external_notification.output_ms
? moduleConfig.payloadVariant.external_notification.output_ms ? moduleConfig.external_notification.output_ms
: EXT_NOTIFICATION_MODULE_OUTPUT_MS) < : EXT_NOTIFICATION_MODULE_OUTPUT_MS) <
millis()) { millis()) {
DEBUG_MSG("Turning off external notification\n"); DEBUG_MSG("Turning off external notification\n");
@@ -88,10 +88,10 @@ void ExternalNotificationModule::setExternalOn()
externalCurrentState = 1; externalCurrentState = 1;
externalTurnedOn = millis(); externalTurnedOn = millis();
digitalWrite((moduleConfig.payloadVariant.external_notification.output digitalWrite((moduleConfig.external_notification.output
? moduleConfig.payloadVariant.external_notification.output ? moduleConfig.external_notification.output
: EXT_NOTIFICATION_MODULE_OUTPUT), : EXT_NOTIFICATION_MODULE_OUTPUT),
(moduleConfig.payloadVariant.external_notification.active ? true : false)); (moduleConfig.external_notification.active ? true : false));
#endif #endif
} }
@@ -100,10 +100,10 @@ void ExternalNotificationModule::setExternalOff()
#ifdef EXT_NOTIFY_OUT #ifdef EXT_NOTIFY_OUT
externalCurrentState = 0; externalCurrentState = 0;
digitalWrite((moduleConfig.payloadVariant.external_notification.output digitalWrite((moduleConfig.external_notification.output
? moduleConfig.payloadVariant.external_notification.output ? moduleConfig.external_notification.output
: EXT_NOTIFICATION_MODULE_OUTPUT), : EXT_NOTIFICATION_MODULE_OUTPUT),
(moduleConfig.payloadVariant.external_notification.active ? false : true)); (moduleConfig.external_notification.active ? false : true));
#endif #endif
} }
@@ -124,21 +124,21 @@ ExternalNotificationModule::ExternalNotificationModule()
without having to configure it from the PythonAPI or WebUI. without having to configure it from the PythonAPI or WebUI.
*/ */
// moduleConfig.payloadVariant.external_notification.enabled = 1; // moduleConfig.external_notification.enabled = 1;
// moduleConfig.payloadVariant.external_notification.alert_message = 1; // moduleConfig.external_notification.alert_message = 1;
// moduleConfig.payloadVariant.external_notification.active = 1; // moduleConfig.external_notification.active = 1;
// moduleConfig.payloadVariant.external_notification.alert_bell = 1; // moduleConfig.external_notification.alert_bell = 1;
// moduleConfig.payloadVariant.external_notification.output_ms = 1000; // moduleConfig.external_notification.output_ms = 1000;
// moduleConfig.payloadVariant.external_notification.output = 13; // moduleConfig.external_notification.output = 13;
if (moduleConfig.payloadVariant.external_notification.enabled) { if (moduleConfig.external_notification.enabled) {
DEBUG_MSG("Initializing External Notification Module\n"); DEBUG_MSG("Initializing External Notification Module\n");
// Set the direction of a pin // Set the direction of a pin
pinMode((moduleConfig.payloadVariant.external_notification.output pinMode((moduleConfig.external_notification.output
? moduleConfig.payloadVariant.external_notification.output ? moduleConfig.external_notification.output
: EXT_NOTIFICATION_MODULE_OUTPUT), : EXT_NOTIFICATION_MODULE_OUTPUT),
OUTPUT); OUTPUT);
@@ -157,13 +157,13 @@ ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp)
#ifndef NO_ESP32 #ifndef NO_ESP32
#ifdef EXT_NOTIFY_OUT #ifdef EXT_NOTIFY_OUT
if (moduleConfig.payloadVariant.external_notification.enabled) { if (moduleConfig.external_notification.enabled) {
if (getFrom(&mp) != nodeDB.getNodeNum()) { if (getFrom(&mp) != nodeDB.getNodeNum()) {
// TODO: This may be a problem if messages are sent in unicide, but I'm not sure if it will. // TODO: This may be a problem if messages are sent in unicide, but I'm not sure if it will.
// Need to know if and how this could be a problem. // Need to know if and how this could be a problem.
if (moduleConfig.payloadVariant.external_notification.alert_bell) { if (moduleConfig.external_notification.alert_bell) {
auto &p = mp.decoded; auto &p = mp.decoded;
DEBUG_MSG("externalNotificationModule - 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++) {
@@ -173,7 +173,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp)
} }
} }
if (moduleConfig.payloadVariant.external_notification.alert_message) { if (moduleConfig.external_notification.alert_message) {
DEBUG_MSG("externalNotificationModule - Notification Module\n"); DEBUG_MSG("externalNotificationModule - Notification Module\n");
setExternalOn(); setExternalOn();
} }
+1 -1
View File
@@ -69,6 +69,6 @@ int32_t NodeInfoModule::runOnce()
DEBUG_MSG("Sending our nodeinfo to mesh (wantReplies=%d)\n", requestReplies); DEBUG_MSG("Sending our nodeinfo to mesh (wantReplies=%d)\n", requestReplies);
sendOurNodeInfo(NODENUM_BROADCAST, requestReplies); // Send our info (don't request replies) sendOurNodeInfo(NODENUM_BROADCAST, requestReplies); // Send our info (don't request replies)
return config.payloadVariant.position.position_broadcast_secs ? config.payloadVariant.position.position_broadcast_secs return config.position.position_broadcast_secs ? config.position.position_broadcast_secs
: default_broadcast_interval_secs * 1000; : default_broadcast_interval_secs * 1000;
} }
+4 -4
View File
@@ -60,7 +60,7 @@ MeshPacket *PositionModule::allocReply()
// configuration of POSITION packet // configuration of POSITION packet
// consider making this a function argument? // consider making this a function argument?
uint32_t pos_flags = config.payloadVariant.position.position_flags; uint32_t pos_flags = config.position.position_flags;
// Populate a Position struct with ONLY the requested fields // Populate a Position struct with ONLY the requested fields
Position p = Position_init_default; // Start with an empty structure Position p = Position_init_default; // Start with an empty structure
@@ -127,8 +127,8 @@ int32_t PositionModule::runOnce()
// We limit our GPS broadcasts to a max rate // We limit our GPS broadcasts to a max rate
uint32_t now = millis(); uint32_t now = millis();
if (lastGpsSend == 0 || now - lastGpsSend >= config.payloadVariant.position.position_broadcast_secs if (lastGpsSend == 0 || now - lastGpsSend >= config.position.position_broadcast_secs
? config.payloadVariant.position.position_broadcast_secs ? config.position.position_broadcast_secs
: default_broadcast_interval_secs * 1000) { : default_broadcast_interval_secs * 1000) {
// Only send packets if the channel is less than 40% utilized. // Only send packets if the channel is less than 40% utilized.
@@ -151,7 +151,7 @@ int32_t PositionModule::runOnce()
DEBUG_MSG("Channel utilization is >50 percent. Skipping this opportunity to send.\n"); DEBUG_MSG("Channel utilization is >50 percent. Skipping this opportunity to send.\n");
} }
} else if (!config.payloadVariant.position.position_broadcast_smart_disabled) { } else if (!config.position.position_broadcast_smart_disabled) {
// 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) {
+1 -1
View File
@@ -21,7 +21,7 @@ int32_t DeviceTelemetryModule::runOnce()
sendOurTelemetry(); sendOurTelemetry();
// OSThread library. Multiply the preference value by 1000 to convert seconds to miliseconds // OSThread library. Multiply the preference value by 1000 to convert seconds to miliseconds
return getIntervalOrDefaultMs(moduleConfig.payloadVariant.telemetry.device_update_interval); return getIntervalOrDefaultMs(moduleConfig.telemetry.device_update_interval);
#endif #endif
} }
+24 -24
View File
@@ -50,17 +50,17 @@ int32_t EnvironmentTelemetryModule::runOnce()
without having to configure it from the PythonAPI or WebUI. without having to configure it from the PythonAPI or WebUI.
*/ */
/* /*
moduleConfig.payloadVariant.telemetry.environment_measurement_enabled = 1; moduleConfig.telemetry.environment_measurement_enabled = 1;
moduleConfig.payloadVariant.telemetry.environment_screen_enabled = 1; moduleConfig.telemetry.environment_screen_enabled = 1;
moduleConfig.payloadVariant.telemetry.environment_read_error_count_threshold = 5; moduleConfig.telemetry.environment_read_error_count_threshold = 5;
moduleConfig.payloadVariant.telemetry.environment_update_interval = 600; moduleConfig.telemetry.environment_update_interval = 600;
moduleConfig.payloadVariant.telemetry.environment_recovery_interval = 60; moduleConfig.telemetry.environment_recovery_interval = 60;
moduleConfig.payloadVariant.telemetry.environment_sensor_pin = 13; // If one-wire moduleConfig.telemetry.environment_sensor_pin = 13; // If one-wire
moduleConfig.payloadVariant.telemetry.environment_sensor_type = TelemetrySensorType::TelemetrySensorType_BME280; moduleConfig.telemetry.environment_sensor_type = TelemetrySensorType::TelemetrySensorType_BME280;
*/ */
if (!(moduleConfig.payloadVariant.telemetry.environment_measurement_enabled || if (!(moduleConfig.telemetry.environment_measurement_enabled ||
moduleConfig.payloadVariant.telemetry.environment_screen_enabled)) { moduleConfig.telemetry.environment_screen_enabled)) {
// If this module is not enabled, and the user doesn't want the display screen don't waste any OSThread time on it // If this module is not enabled, and the user doesn't want the display screen don't waste any OSThread time on it
return (INT32_MAX); return (INT32_MAX);
} }
@@ -69,11 +69,11 @@ int32_t EnvironmentTelemetryModule::runOnce()
// This is the first time the OSThread library has called this function, so do some setup // This is the first time the OSThread library has called this function, so do some setup
firstTime = 0; firstTime = 0;
if (moduleConfig.payloadVariant.telemetry.environment_measurement_enabled) { if (moduleConfig.telemetry.environment_measurement_enabled) {
DEBUG_MSG("Environment Telemetry: Initializing\n"); DEBUG_MSG("Environment Telemetry: Initializing\n");
// it's possible to have this module enabled, only for displaying values on the screen. // it's possible to have this module enabled, only for displaying values on the screen.
// therefore, we should only enable the sensor loop if measurement is also enabled // therefore, we should only enable the sensor loop if measurement is also enabled
switch (moduleConfig.payloadVariant.telemetry.environment_sensor_type) { switch (moduleConfig.telemetry.environment_sensor_type) {
case TelemetrySensorType_DHT11: case TelemetrySensorType_DHT11:
case TelemetrySensorType_DHT12: case TelemetrySensorType_DHT12:
@@ -97,35 +97,35 @@ int32_t EnvironmentTelemetryModule::runOnce()
return (INT32_MAX); return (INT32_MAX);
} else { } else {
// if we somehow got to a second run of this module with measurement disabled, then just wait forever // if we somehow got to a second run of this module with measurement disabled, then just wait forever
if (!moduleConfig.payloadVariant.telemetry.environment_measurement_enabled) if (!moduleConfig.telemetry.environment_measurement_enabled)
return (INT32_MAX); return (INT32_MAX);
// this is not the first time OSThread library has called this function // this is not the first time OSThread library has called this function
// so just do what we intend to do on the interval // so just do what we intend to do on the interval
if (sensor_read_error_count > moduleConfig.payloadVariant.telemetry.environment_read_error_count_threshold) { if (sensor_read_error_count > moduleConfig.telemetry.environment_read_error_count_threshold) {
if (moduleConfig.payloadVariant.telemetry.environment_recovery_interval > 0) { if (moduleConfig.telemetry.environment_recovery_interval > 0) {
DEBUG_MSG("Environment Telemetry: TEMPORARILY DISABLED; The " DEBUG_MSG("Environment Telemetry: TEMPORARILY DISABLED; The "
"telemetry_module_environment_read_error_count_threshold has been exceed: %d. Will retry reads in " "telemetry_module_environment_read_error_count_threshold has been exceed: %d. Will retry reads in "
"%d seconds\n", "%d seconds\n",
moduleConfig.payloadVariant.telemetry.environment_read_error_count_threshold, moduleConfig.telemetry.environment_read_error_count_threshold,
moduleConfig.payloadVariant.telemetry.environment_recovery_interval); moduleConfig.telemetry.environment_recovery_interval);
sensor_read_error_count = 0; sensor_read_error_count = 0;
return (moduleConfig.payloadVariant.telemetry.environment_recovery_interval * 1000); return (moduleConfig.telemetry.environment_recovery_interval * 1000);
} }
DEBUG_MSG("Environment Telemetry: DISABLED; The telemetry_module_environment_read_error_count_threshold has " DEBUG_MSG("Environment Telemetry: DISABLED; The telemetry_module_environment_read_error_count_threshold has "
"been exceed: %d. Reads will not be retried until after device reset\n", "been exceed: %d. Reads will not be retried until after device reset\n",
moduleConfig.payloadVariant.telemetry.environment_read_error_count_threshold); moduleConfig.telemetry.environment_read_error_count_threshold);
return (INT32_MAX); return (INT32_MAX);
} else if (sensor_read_error_count > 0) { } else if (sensor_read_error_count > 0) {
DEBUG_MSG("Environment Telemetry: There have been %d sensor read failures. Will retry %d more times\n", DEBUG_MSG("Environment Telemetry: There have been %d sensor read failures. Will retry %d more times\n",
sensor_read_error_count, sensor_read_error_count, sensor_read_error_count, sensor_read_error_count, sensor_read_error_count, sensor_read_error_count,
moduleConfig.payloadVariant.telemetry.environment_read_error_count_threshold - sensor_read_error_count); moduleConfig.telemetry.environment_read_error_count_threshold - sensor_read_error_count);
} }
if (!sendOurTelemetry()) { if (!sendOurTelemetry()) {
// if we failed to read the sensor, then try again // if we failed to read the sensor, then try again
// as soon as we can according to the maximum polling frequency // as soon as we can according to the maximum polling frequency
switch (moduleConfig.payloadVariant.telemetry.environment_sensor_type) { switch (moduleConfig.telemetry.environment_sensor_type) {
case TelemetrySensorType_DHT11: case TelemetrySensorType_DHT11:
case TelemetrySensorType_DHT12: case TelemetrySensorType_DHT12:
case TelemetrySensorType_DHT21: case TelemetrySensorType_DHT21:
@@ -143,7 +143,7 @@ int32_t EnvironmentTelemetryModule::runOnce()
} }
} }
} }
return getIntervalOrDefaultMs(moduleConfig.payloadVariant.telemetry.environment_update_interval); return getIntervalOrDefaultMs(moduleConfig.telemetry.environment_update_interval);
#endif #endif
} }
@@ -161,7 +161,7 @@ uint32_t GetTimeSinceMeshPacket(const MeshPacket *mp)
bool EnvironmentTelemetryModule::wantUIFrame() bool EnvironmentTelemetryModule::wantUIFrame()
{ {
return moduleConfig.payloadVariant.telemetry.environment_screen_enabled; return moduleConfig.telemetry.environment_screen_enabled;
} }
float EnvironmentTelemetryModule::CelsiusToFahrenheit(float c) float EnvironmentTelemetryModule::CelsiusToFahrenheit(float c)
@@ -195,7 +195,7 @@ void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSt
display->setFont(FONT_SMALL); display->setFont(FONT_SMALL);
String last_temp = String(lastMeasurement.variant.environment_metrics.temperature, 0) + "°C"; String last_temp = String(lastMeasurement.variant.environment_metrics.temperature, 0) + "°C";
if (moduleConfig.payloadVariant.telemetry.environment_display_fahrenheit) { if (moduleConfig.telemetry.environment_display_fahrenheit) {
last_temp = String(CelsiusToFahrenheit(lastMeasurement.variant.environment_metrics.temperature), 0) + "°F"; last_temp = String(CelsiusToFahrenheit(lastMeasurement.variant.environment_metrics.temperature), 0) + "°F";
} }
display->drawString(x, y += fontHeight(FONT_MEDIUM) - 2, "From: " + String(lastSender) + "(" + String(agoSecs) + "s)"); display->drawString(x, y += fontHeight(FONT_MEDIUM) - 2, "From: " + String(lastSender) + "(" + String(agoSecs) + "s)");
@@ -244,7 +244,7 @@ bool EnvironmentTelemetryModule::sendOurTelemetry(NodeNum dest, bool wantReplies
DEBUG_MSG("-----------------------------------------\n"); DEBUG_MSG("-----------------------------------------\n");
DEBUG_MSG("Environment Telemetry: Read data\n"); DEBUG_MSG("Environment Telemetry: Read data\n");
switch (moduleConfig.payloadVariant.telemetry.environment_sensor_type) { switch (moduleConfig.telemetry.environment_sensor_type) {
case TelemetrySensorType_DS18B20: case TelemetrySensorType_DS18B20:
if (!dallasSensor.getMeasurement(&m)) if (!dallasSensor.getMeasurement(&m))
sensor_read_error_count++; sensor_read_error_count++;
+3 -3
View File
@@ -10,14 +10,14 @@ DHTSensor::DHTSensor() : TelemetrySensor{} {}
int32_t DHTSensor::runOnce() int32_t DHTSensor::runOnce()
{ {
if (TelemetrySensorType_DHT11 || TelemetrySensorType_DHT12) { if (TelemetrySensorType_DHT11 || TelemetrySensorType_DHT12) {
dht = new DHT(moduleConfig.payloadVariant.telemetry.environment_sensor_pin, DHT11); dht = new DHT(moduleConfig.telemetry.environment_sensor_pin, DHT11);
} else { } else {
dht = new DHT(moduleConfig.payloadVariant.telemetry.environment_sensor_pin, DHT22); dht = new DHT(moduleConfig.telemetry.environment_sensor_pin, DHT22);
} }
dht->begin(); dht->begin();
dht->read(); dht->read();
DEBUG_MSG("Telemetry: Opened DHT11/DHT12 on pin: %d\n", moduleConfig.payloadVariant.telemetry.environment_sensor_pin); DEBUG_MSG("Telemetry: Opened DHT11/DHT12 on pin: %d\n", moduleConfig.telemetry.environment_sensor_pin);
return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
} }
@@ -10,12 +10,12 @@ DallasSensor::DallasSensor() : TelemetrySensor{} {}
int32_t DallasSensor::runOnce() int32_t DallasSensor::runOnce()
{ {
oneWire = new OneWire(moduleConfig.payloadVariant.telemetry.environment_sensor_pin); oneWire = new OneWire(moduleConfig.telemetry.environment_sensor_pin);
ds18b20 = new DS18B20(oneWire); ds18b20 = new DS18B20(oneWire);
ds18b20->begin(); ds18b20->begin();
ds18b20->setResolution(12); ds18b20->setResolution(12);
ds18b20->requestTemperatures(); ds18b20->requestTemperatures();
DEBUG_MSG("Telemetry: Opened DS18B20 on pin: %d\n", moduleConfig.payloadVariant.telemetry.environment_sensor_pin); DEBUG_MSG("Telemetry: Opened DS18B20 on pin: %d\n", moduleConfig.telemetry.environment_sensor_pin);
return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
} }
+10 -10
View File
@@ -36,23 +36,23 @@ int32_t RangeTestModule::runOnce()
without having to configure it from the PythonAPI or WebUI. without having to configure it from the PythonAPI or WebUI.
*/ */
// moduleConfig.payloadVariant.range_test.enabled = 1; // moduleConfig.range_test.enabled = 1;
// moduleConfig.payloadVariant.range_test.sender = 45; // moduleConfig.range_test.sender = 45;
// moduleConfig.payloadVariant.range_test.save = 1; // moduleConfig.range_test.save = 1;
// Fixed position is useful when testing indoors. // Fixed position is useful when testing indoors.
// radioConfig.preferences.fixed_position = 1; // radioConfig.preferences.fixed_position = 1;
uint32_t senderHeartbeat = moduleConfig.payloadVariant.range_test.sender * 1000; uint32_t senderHeartbeat = moduleConfig.range_test.sender * 1000;
if (moduleConfig.payloadVariant.range_test.enabled) { if (moduleConfig.range_test.enabled) {
if (firstTime) { if (firstTime) {
rangeTestModuleRadio = new RangeTestModuleRadio(); rangeTestModuleRadio = new RangeTestModuleRadio();
firstTime = 0; firstTime = 0;
if (moduleConfig.payloadVariant.range_test.sender) { if (moduleConfig.range_test.sender) {
DEBUG_MSG("Initializing Range Test Module -- Sender\n"); DEBUG_MSG("Initializing Range Test Module -- Sender\n");
return (5000); // Sending first message 5 seconds after initilization. return (5000); // Sending first message 5 seconds after initilization.
} else { } else {
@@ -62,7 +62,7 @@ int32_t RangeTestModule::runOnce()
} else { } else {
if (moduleConfig.payloadVariant.range_test.sender) { if (moduleConfig.range_test.sender) {
// If sender // If sender
DEBUG_MSG("Range Test Module - Sending heartbeat every %d ms\n", (senderHeartbeat)); DEBUG_MSG("Range Test Module - Sending heartbeat every %d ms\n", (senderHeartbeat));
@@ -71,7 +71,7 @@ int32_t RangeTestModule::runOnce()
DEBUG_MSG("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock()); DEBUG_MSG("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock());
DEBUG_MSG("gpsStatus->getDOP() %d\n", gpsStatus->getDOP()); DEBUG_MSG("gpsStatus->getDOP() %d\n", gpsStatus->getDOP());
DEBUG_MSG("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock()); DEBUG_MSG("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock());
DEBUG_MSG("pref.fixed_position() %d\n", config.payloadVariant.position.fixed_position); DEBUG_MSG("pref.fixed_position() %d\n", config.position.fixed_position);
// 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) {
@@ -131,7 +131,7 @@ ProcessMessage RangeTestModuleRadio::handleReceived(const MeshPacket &mp)
{ {
#ifndef NO_ESP32 #ifndef NO_ESP32
if (moduleConfig.payloadVariant.range_test.enabled) { if (moduleConfig.range_test.enabled) {
/* /*
auto &p = mp.decoded; auto &p = mp.decoded;
@@ -141,7 +141,7 @@ ProcessMessage RangeTestModuleRadio::handleReceived(const MeshPacket &mp)
if (getFrom(&mp) != nodeDB.getNodeNum()) { if (getFrom(&mp) != nodeDB.getNodeNum()) {
if (moduleConfig.payloadVariant.range_test.save) { if (moduleConfig.range_test.save) {
appendFile(mp); appendFile(mp);
} }
+32 -32
View File
@@ -76,13 +76,13 @@ int32_t SerialModule::runOnce()
without having to configure it from the PythonAPI or WebUI. without having to configure it from the PythonAPI or WebUI.
*/ */
// moduleConfig.payloadVariant.serial.enabled = 1; // moduleConfig.serial.enabled = 1;
// moduleConfig.payloadVariant.serial.rxd = 35; // moduleConfig.serial.rxd = 35;
// moduleConfig.payloadVariant.serial.txd = 15; // moduleConfig.serial.txd = 15;
// moduleConfig.payloadVariant.serial.timeout = 1000; // moduleConfig.serial.timeout = 1000;
// moduleConfig.payloadVariant.serial.echo = 1; // moduleConfig.serial.echo = 1;
if (moduleConfig.payloadVariant.serial.enabled) { if (moduleConfig.serial.enabled) {
if (firstTime) { if (firstTime) {
@@ -91,65 +91,65 @@ int32_t SerialModule::runOnce()
uint32_t baud = 0; uint32_t baud = 0;
if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_Default) { if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_Default) {
baud = 38400; baud = 38400;
} else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_110) { } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_110) {
baud = 110; baud = 110;
} else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_300) { } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_300) {
baud = 300; baud = 300;
} else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_600) { } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_600) {
baud = 600; baud = 600;
} else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_1200) { } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_1200) {
baud = 1200; baud = 1200;
} else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_2400) { } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_2400) {
baud = 2400; baud = 2400;
} else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_4800) { } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_4800) {
baud = 4800; baud = 4800;
} else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_9600) { } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_9600) {
baud = 9600; baud = 9600;
} else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_19200) { } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_19200) {
baud = 19200; baud = 19200;
} else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_38400) { } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_38400) {
baud = 38400; baud = 38400;
} else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_57600) { } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_57600) {
baud = 57600; baud = 57600;
} else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_115200) { } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_115200) {
baud = 115200; baud = 115200;
} else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_230400) { } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_230400) {
baud = 230400; baud = 230400;
} else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_460800) { } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_460800) {
baud = 460800; baud = 460800;
} else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_576000) { } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_576000) {
baud = 576000; baud = 576000;
} else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_921600) { } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_921600) {
baud = 921600; baud = 921600;
} }
if (moduleConfig.payloadVariant.serial.rxd && moduleConfig.payloadVariant.serial.txd) { if (moduleConfig.serial.rxd && moduleConfig.serial.txd) {
Serial2.begin(baud, SERIAL_8N1, moduleConfig.payloadVariant.serial.rxd, moduleConfig.payloadVariant.serial.txd); Serial2.begin(baud, SERIAL_8N1, moduleConfig.serial.rxd, moduleConfig.serial.txd);
} else { } else {
Serial2.begin(baud, SERIAL_8N1, RXD2, TXD2); Serial2.begin(baud, SERIAL_8N1, RXD2, TXD2);
} }
if (moduleConfig.payloadVariant.serial.timeout) { if (moduleConfig.serial.timeout) {
Serial2.setTimeout( Serial2.setTimeout(
moduleConfig.payloadVariant.serial.timeout); // Number of MS to wait to set the timeout for the string. moduleConfig.serial.timeout); // Number of MS to wait to set the timeout for the string.
} else { } else {
Serial2.setTimeout(TIMEOUT); // Number of MS to wait to set the timeout for the string. Serial2.setTimeout(TIMEOUT); // Number of MS to wait to set the timeout for the string.
@@ -211,7 +211,7 @@ ProcessMessage SerialModuleRadio::handleReceived(const MeshPacket &mp)
{ {
#ifndef NO_ESP32 #ifndef NO_ESP32
if (moduleConfig.payloadVariant.serial.enabled) { if (moduleConfig.serial.enabled) {
auto &p = mp.decoded; auto &p = mp.decoded;
// DEBUG_MSG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n", // DEBUG_MSG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n",
@@ -220,10 +220,10 @@ ProcessMessage SerialModuleRadio::handleReceived(const MeshPacket &mp)
if (getFrom(&mp) == nodeDB.getNodeNum()) { if (getFrom(&mp) == nodeDB.getNodeNum()) {
/* /*
* If moduleConfig.payloadVariant.serial.echo is true, then echo the packets that are sent out * If moduleConfig.serial.echo is true, then echo the packets that are sent out
* back to the TX of the serial interface. * back to the TX of the serial interface.
*/ */
if (moduleConfig.payloadVariant.serial.echo) { if (moduleConfig.serial.echo) {
// For some reason, we get the packet back twice when we send out of the radio. // For some reason, we get the packet back twice when we send out of the radio.
// TODO: need to find out why. // TODO: need to find out why.
@@ -237,13 +237,13 @@ ProcessMessage SerialModuleRadio::handleReceived(const MeshPacket &mp)
} else { } else {
if (moduleConfig.payloadVariant.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_MODE_Default || if (moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_MODE_Default ||
moduleConfig.payloadVariant.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_MODE_SIMPLE) { moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_MODE_SIMPLE) {
// DEBUG_MSG("* * Message came from the mesh\n"); // DEBUG_MSG("* * Message came from the mesh\n");
// Serial2.println("* * Message came from the mesh"); // Serial2.println("* * Message came from the mesh");
Serial2.printf("%s", p.payload.bytes); Serial2.printf("%s", p.payload.bytes);
} else if (moduleConfig.payloadVariant.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_MODE_PROTO) { } else if (moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_MODE_PROTO) {
} }
} }
+16 -16
View File
@@ -19,9 +19,9 @@ int32_t StoreForwardModule::runOnce()
#ifndef NO_ESP32 #ifndef NO_ESP32
if (moduleConfig.payloadVariant.store_forward.enabled) { if (moduleConfig.store_forward.enabled) {
if (config.payloadVariant.device.role == Config_DeviceConfig_Role_Router) { if (config.device.role == Config_DeviceConfig_Role_Router) {
// Send out the message queue. // Send out the message queue.
if (this->busy) { if (this->busy) {
@@ -242,7 +242,7 @@ void StoreForwardModule::sendMessage(NodeNum dest, char *str)
ProcessMessage StoreForwardModule::handleReceived(const MeshPacket &mp) ProcessMessage StoreForwardModule::handleReceived(const MeshPacket &mp)
{ {
#ifndef NO_ESP32 #ifndef NO_ESP32
if (moduleConfig.payloadVariant.store_forward.enabled) { if (moduleConfig.store_forward.enabled) {
DEBUG_MSG("--- S&F Received something\n"); DEBUG_MSG("--- S&F Received something\n");
@@ -295,7 +295,7 @@ ProcessMessage StoreForwardModule::handleReceived(const MeshPacket &mp)
ProcessMessage StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndForward *p) ProcessMessage StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndForward *p)
{ {
if (!moduleConfig.payloadVariant.store_forward.enabled) { if (!moduleConfig.store_forward.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
return ProcessMessage::CONTINUE; return ProcessMessage::CONTINUE;
} }
@@ -391,14 +391,14 @@ StoreForwardModule::StoreForwardModule()
without having to configure it from the PythonAPI or WebUI. without having to configure it from the PythonAPI or WebUI.
*/ */
moduleConfig.payloadVariant.store_forward.enabled = 1; moduleConfig.store_forward.enabled = 1;
config.payloadVariant.power.is_always_powered = 1; config.power.is_always_powered = 1;
} }
if (moduleConfig.payloadVariant.store_forward.enabled) { if (moduleConfig.store_forward.enabled) {
// Router // Router
if (config.payloadVariant.device.role == Config_DeviceConfig_Role_Router) { if (config.device.role == Config_DeviceConfig_Role_Router) {
DEBUG_MSG("Initializing Store & Forward Module - 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) {
@@ -406,20 +406,20 @@ StoreForwardModule::StoreForwardModule()
// Do the startup here // Do the startup here
// Maximum number of records to return. // Maximum number of records to return.
if (moduleConfig.payloadVariant.store_forward.history_return_max) if (moduleConfig.store_forward.history_return_max)
this->historyReturnMax = moduleConfig.payloadVariant.store_forward.history_return_max; this->historyReturnMax = moduleConfig.store_forward.history_return_max;
// Maximum time window for records to return (in minutes) // Maximum time window for records to return (in minutes)
if (moduleConfig.payloadVariant.store_forward.history_return_window) if (moduleConfig.store_forward.history_return_window)
this->historyReturnWindow = moduleConfig.payloadVariant.store_forward.history_return_window; this->historyReturnWindow = moduleConfig.store_forward.history_return_window;
// Maximum number of records to store in memory // Maximum number of records to store in memory
if (moduleConfig.payloadVariant.store_forward.records) if (moduleConfig.store_forward.records)
this->records = moduleConfig.payloadVariant.store_forward.records; this->records = moduleConfig.store_forward.records;
// Maximum number of records to store in memory // Maximum number of records to store in memory
if (moduleConfig.payloadVariant.store_forward.heartbeat) if (moduleConfig.store_forward.heartbeat)
this->heartbeat = moduleConfig.payloadVariant.store_forward.heartbeat; this->heartbeat = moduleConfig.store_forward.heartbeat;
// Popupate PSRAM with our data structures. // Popupate PSRAM with our data structures.
this->populatePSRAM(); this->populatePSRAM();
+9 -9
View File
@@ -111,18 +111,18 @@ void MQTT::reconnect()
const char *mqttUsername = "meshdev"; const char *mqttUsername = "meshdev";
const char *mqttPassword = "large4cats"; const char *mqttPassword = "large4cats";
if (*moduleConfig.payloadVariant.mqtt.address) { if (*moduleConfig.mqtt.address) {
serverAddr = moduleConfig.payloadVariant.mqtt.address; // Override the default serverAddr = moduleConfig.mqtt.address; // Override the default
mqttUsername = mqttUsername =
moduleConfig.payloadVariant.mqtt.username; // do not use the hardcoded credentials for a custom mqtt server moduleConfig.mqtt.username; // do not use the hardcoded credentials for a custom mqtt server
mqttPassword = moduleConfig.payloadVariant.mqtt.password; mqttPassword = moduleConfig.mqtt.password;
} else { } else {
// we are using the default server. Use the hardcoded credentials by default, but allow overriding // we are using the default server. Use the hardcoded credentials by default, but allow overriding
if (*moduleConfig.payloadVariant.mqtt.username && moduleConfig.payloadVariant.mqtt.username[0] != '\0') { if (*moduleConfig.mqtt.username && moduleConfig.mqtt.username[0] != '\0') {
mqttUsername = moduleConfig.payloadVariant.mqtt.username; mqttUsername = moduleConfig.mqtt.username;
} }
if (*moduleConfig.payloadVariant.mqtt.password && moduleConfig.payloadVariant.mqtt.password[0] != '\0') { if (*moduleConfig.mqtt.password && moduleConfig.mqtt.password[0] != '\0') {
mqttPassword = moduleConfig.payloadVariant.mqtt.password; mqttPassword = moduleConfig.mqtt.password;
} }
} }
@@ -175,7 +175,7 @@ bool MQTT::wantsLink() const
{ {
bool hasChannel = false; bool hasChannel = false;
if (moduleConfig.payloadVariant.mqtt.disabled) { if (moduleConfig.mqtt.disabled) {
// DEBUG_MSG("MQTT disabled...\n"); // DEBUG_MSG("MQTT disabled...\n");
} else { } else {
// No need for link if no channel needed it // No need for link if no channel needed it