sforkowany z mirror/meshtastic-firmware
Segemented config works for me (TM)
Small GPS Fix that cropped up while testing included.raytac-diy
rodzic
33938f73a6
commit
53e9f4df46
|
@ -62,7 +62,7 @@ class GPSStatus : public Status
|
|||
|
||||
int32_t getLatitude() const
|
||||
{
|
||||
if (config.payloadVariant.position.fixed_position) {
|
||||
if (config.position.fixed_position) {
|
||||
#ifdef GPS_EXTRAVERBOSE
|
||||
DEBUG_MSG("WARNING: Using fixed latitude\n");
|
||||
#endif
|
||||
|
@ -75,7 +75,7 @@ class GPSStatus : public Status
|
|||
|
||||
int32_t getLongitude() const
|
||||
{
|
||||
if (config.payloadVariant.position.fixed_position) {
|
||||
if (config.position.fixed_position) {
|
||||
#ifdef GPS_EXTRAVERBOSE
|
||||
DEBUG_MSG("WARNING: Using fixed longitude\n");
|
||||
#endif
|
||||
|
@ -88,7 +88,7 @@ class GPSStatus : public Status
|
|||
|
||||
int32_t getAltitude() const
|
||||
{
|
||||
if (config.payloadVariant.position.fixed_position) {
|
||||
if (config.position.fixed_position) {
|
||||
#ifdef GPS_EXTRAVERBOSE
|
||||
DEBUG_MSG("WARNING: Using fixed altitude\n");
|
||||
#endif
|
||||
|
|
|
@ -357,7 +357,7 @@ bool Power::axp192Init()
|
|||
DEBUG_MSG("DCDC3: %s\n", axp.isDCDC3Enable() ? "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:
|
||||
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_450MA);
|
||||
break;
|
||||
|
|
|
@ -12,15 +12,15 @@
|
|||
static bool isPowered()
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
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
|
||||
// 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
|
||||
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");
|
||||
// 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;
|
||||
|
@ -52,7 +52,7 @@ static uint32_t secsSlept;
|
|||
static void lsEnter()
|
||||
{
|
||||
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);
|
||||
secsSlept = 0; // How long have we been sleeping this time
|
||||
|
||||
|
@ -66,7 +66,7 @@ static void lsIdle()
|
|||
#ifndef NO_ESP32
|
||||
|
||||
// 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
|
||||
uint32_t sleepTime = 30;
|
||||
|
||||
|
@ -239,7 +239,7 @@ Fsm powerFSM(&stateBOOT);
|
|||
|
||||
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();
|
||||
|
||||
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_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,
|
||||
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)
|
||||
|
||||
// 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
|
||||
// powerFSM.add_timed_transition(&stateDARK, &stateNB, getPref_phone_timeout_secs() * 1000, NULL, "Phone timeout");
|
||||
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,
|
||||
NULL, "Min wake timeout");
|
||||
powerFSM.add_timed_transition(&stateDARK, &stateLS,
|
||||
config.payloadVariant.power.wait_bluetooth_secs
|
||||
? config.payloadVariant.power.wait_bluetooth_secs
|
||||
config.power.wait_bluetooth_secs
|
||||
? config.power.wait_bluetooth_secs
|
||||
: default_wait_bluetooth_secs * 1000,
|
||||
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;
|
||||
|
||||
} else {
|
||||
|
|
|
@ -26,11 +26,11 @@ class PowerFSMThread : public OSThread
|
|||
|
||||
if (powerStatus->getHasUSB()) {
|
||||
timeLastPowered = millis();
|
||||
} else if (config.payloadVariant.power.on_battery_shutdown_after_secs > 0 &&
|
||||
} else if (config.power.on_battery_shutdown_after_secs > 0 &&
|
||||
millis() >
|
||||
timeLastPowered +
|
||||
(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);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ SerialConsole::SerialConsole() : StreamAPI(&Port), RedirectablePrint(&Port)
|
|||
bool SerialConsole::checkIsConnected()
|
||||
{
|
||||
uint32_t now = millis();
|
||||
return (now - lastContactMsec) < config.payloadVariant.power.phone_timeout_secs
|
||||
? config.payloadVariant.power.phone_timeout_secs
|
||||
return (now - lastContactMsec) < config.power.phone_timeout_secs
|
||||
? config.power.phone_timeout_secs
|
||||
: default_phone_timeout_secs * 1000UL;
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ bool SerialConsole::checkIsConnected()
|
|||
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
|
||||
if (!config.payloadVariant.device.debug_log_enabled)
|
||||
if (!config.device.debug_log_enabled)
|
||||
setDestination(&noopPrint);
|
||||
canWrite = true;
|
||||
|
||||
|
|
|
@ -194,6 +194,11 @@ bool GPS::hasLock()
|
|||
return hasValidLocation;
|
||||
}
|
||||
|
||||
bool GPS::hasFlow()
|
||||
{
|
||||
return hasGPS;
|
||||
}
|
||||
|
||||
// Allow defining the polarity of the WAKE output. default is active high
|
||||
#ifndef GPS_WAKE_ACTIVE
|
||||
#define GPS_WAKE_ACTIVE 1
|
||||
|
@ -262,13 +267,13 @@ void GPS::setAwake(bool on)
|
|||
*/
|
||||
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)
|
||||
return t; // already maxint
|
||||
|
||||
if (t == 0)
|
||||
t = (config.payloadVariant.device.role == Config_DeviceConfig_Role_Router)
|
||||
t = (config.device.role == Config_DeviceConfig_Role_Router)
|
||||
? 5 * 60
|
||||
: 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
|
||||
|
@ -282,8 +287,8 @@ uint32_t GPS::getWakeTime() const
|
|||
*/
|
||||
uint32_t GPS::getSleepTime() const
|
||||
{
|
||||
uint32_t t = config.payloadVariant.position.gps_update_interval;
|
||||
bool gps_disabled = config.payloadVariant.position.gps_disabled;
|
||||
uint32_t t = config.position.gps_update_interval;
|
||||
bool gps_disabled = config.position.gps_disabled;
|
||||
|
||||
if (gps_disabled)
|
||||
t = UINT32_MAX; // Sleep forever now
|
||||
|
@ -292,7 +297,7 @@ uint32_t GPS::getSleepTime() const
|
|||
return t; // already maxint
|
||||
|
||||
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
|
||||
|
||||
t *= 1000;
|
||||
|
@ -322,7 +327,7 @@ int32_t GPS::runOnce()
|
|||
} else {
|
||||
#ifdef GPS_UBLOX
|
||||
// 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");
|
||||
devicestate.did_gps_reset = false;
|
||||
nodeDB.saveToDisk();
|
||||
|
@ -437,7 +442,7 @@ GPS *createGps()
|
|||
#ifdef NO_GPS
|
||||
return nullptr;
|
||||
#else
|
||||
if (!config.payloadVariant.position.gps_disabled) {
|
||||
if (!config.position.gps_disabled) {
|
||||
#ifdef GPS_ALTITUDE_HAE
|
||||
DEBUG_MSG("Using HAE altitude model\n");
|
||||
#else
|
||||
|
|
|
@ -57,6 +57,9 @@ class GPS : private concurrency::OSThread
|
|||
/// Returns true if we have acquired GPS lock.
|
||||
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
|
||||
bool isConnected() const { return hasGPS; }
|
||||
|
||||
|
|
|
@ -235,6 +235,10 @@ bool NMEAGPS::hasLock()
|
|||
return false;
|
||||
}
|
||||
|
||||
bool NMEAGPS::hasFlow()
|
||||
{
|
||||
return reader.passedChecksum() > 0;
|
||||
}
|
||||
|
||||
bool NMEAGPS::whileIdle()
|
||||
{
|
||||
|
|
|
@ -51,4 +51,6 @@ class NMEAGPS : public GPS
|
|||
virtual bool lookForLocation() override;
|
||||
|
||||
virtual bool hasLock() override;
|
||||
|
||||
virtual bool hasFlow() override;
|
||||
};
|
||||
|
|
|
@ -468,7 +468,7 @@ static void drawNodes(OLEDDisplay *display, int16_t x, int16_t y, NodeStatus *no
|
|||
// Draw GPS status summary
|
||||
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
|
||||
display->drawString(x - 1, y - 2, "Fixed GPS");
|
||||
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)
|
||||
{
|
||||
String displayLine = "";
|
||||
if (!gps->getIsConnected() && !config.payloadVariant.position.fixed_position) {
|
||||
if (!gps->getIsConnected() && !config.position.fixed_position) {
|
||||
// displayLine = "No GPS Module";
|
||||
// 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";
|
||||
// display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
|
||||
} else {
|
||||
|
@ -523,13 +523,13 @@ static void drawGPSAltitude(OLEDDisplay *display, int16_t x, int16_t y, const GP
|
|||
// Draw GPS status coordinates
|
||||
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 = "";
|
||||
|
||||
if (!gps->getIsConnected() && !config.payloadVariant.position.fixed_position) {
|
||||
if (!gps->getIsConnected() && !config.position.fixed_position) {
|
||||
displayLine = "No GPS Module";
|
||||
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";
|
||||
display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
|
||||
} 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 (config.payloadVariant.position.fixed_position) {
|
||||
if (config.position.fixed_position) {
|
||||
if ((millis() / 10000) % 2) {
|
||||
display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(coordinateLine))) / 2, y, coordinateLine);
|
||||
} else {
|
||||
|
@ -994,7 +994,7 @@ int32_t Screen::runOnce()
|
|||
}
|
||||
|
||||
#ifndef DISABLE_WELCOME_UNSET
|
||||
if (showingNormalScreen && config.payloadVariant.lora.region == Config_LoRaConfig_RegionCode_Unset) {
|
||||
if (showingNormalScreen && config.lora.region == Config_LoRaConfig_RegionCode_Unset) {
|
||||
setWelcomeFrames();
|
||||
}
|
||||
#endif
|
||||
|
@ -1067,8 +1067,8 @@ int32_t Screen::runOnce()
|
|||
// standard screen switching is stopped.
|
||||
if (showingNormalScreen) {
|
||||
// standard screen loop handling here
|
||||
if (config.payloadVariant.display.auto_screen_carousel_secs > 0 &&
|
||||
(millis() - lastScreenTransition) > (config.payloadVariant.display.auto_screen_carousel_secs * 1000)) {
|
||||
if (config.display.auto_screen_carousel_secs > 0 &&
|
||||
(millis() - lastScreenTransition) > (config.display.auto_screen_carousel_secs * 1000)) {
|
||||
DEBUG_MSG("LastScreenTransition exceeded %ums transitioning to next frame\n", (millis() - lastScreenTransition));
|
||||
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)
|
||||
{
|
||||
#ifdef HAS_WIFI
|
||||
const char *wifiName = config.payloadVariant.wifi.ssid;
|
||||
const char *wifiPsw = config.payloadVariant.wifi.psk;
|
||||
const char *wifiName = config.wifi.ssid;
|
||||
const char *wifiPsw = config.wifi.psk;
|
||||
|
||||
displayedNodeNum = 0; // Not currently showing a node pane
|
||||
|
||||
|
@ -1355,7 +1355,7 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
|
|||
|
||||
if (isSoftAPForced()) {
|
||||
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"));
|
||||
} else if (WiFi.status() != WL_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;
|
||||
|
||||
*/
|
||||
if (WiFi.status() == WL_CONNECTED || isSoftAPForced() || config.payloadVariant.wifi.ap_mode) {
|
||||
if (config.payloadVariant.wifi.ap_mode || isSoftAPForced()) {
|
||||
if (WiFi.status() == WL_CONNECTED || isSoftAPForced() || config.wifi.ap_mode) {
|
||||
if (config.wifi.ap_mode || isSoftAPForced()) {
|
||||
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
|
||||
|
@ -1471,7 +1471,7 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
|
|||
}
|
||||
|
||||
} else {
|
||||
if (config.payloadVariant.wifi.ap_mode) {
|
||||
if (config.wifi.ap_mode) {
|
||||
if ((millis() / 10000) % 2) {
|
||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName));
|
||||
} else {
|
||||
|
@ -1518,7 +1518,7 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
|
|||
|
||||
auto mode = "";
|
||||
|
||||
switch (config.payloadVariant.lora.modem_preset) {
|
||||
switch (config.lora.modem_preset) {
|
||||
case Config_LoRaConfig_ModemPreset_ShortSlow:
|
||||
mode = "ShortSlow";
|
||||
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);
|
||||
|
||||
// Line 3
|
||||
if (config.payloadVariant.display.gps_format !=
|
||||
if (config.display.gps_format !=
|
||||
Config_DisplayConfig_GpsCoordinateFormat_GpsFormatDMS) // if DMS then don't draw altitude
|
||||
drawGPSAltitude(display, x, y + FONT_HEIGHT_SMALL * 2, gpsStatus);
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ void setup()
|
|||
#endif
|
||||
|
||||
#ifdef DEBUG_PORT
|
||||
if (!config.payloadVariant.device.serial_disabled) {
|
||||
if (!config.device.serial_disabled) {
|
||||
consoleInit(); // Set serial baud rate and init our mesh console
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -83,7 +83,7 @@ void Channels::initDefaultChannel(ChannelIndex chIndex)
|
|||
{
|
||||
Channel &ch = getByIndex(chIndex);
|
||||
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
|
||||
|
||||
|
@ -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
|
||||
// the app fucked up and forgot to set channelSettings.name
|
||||
|
||||
if (config.payloadVariant.lora.bandwidth != 0)
|
||||
if (config.lora.bandwidth != 0)
|
||||
channelName = "Unset";
|
||||
else
|
||||
switch (config.payloadVariant.lora.modem_preset) {
|
||||
switch (config.lora.modem_preset) {
|
||||
case Config_LoRaConfig_ModemPreset_ShortSlow:
|
||||
channelName = "ShortSlow";
|
||||
break;
|
||||
|
|
|
@ -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->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
|
||||
|
||||
tosend->hop_limit--; // bump down the hop count
|
||||
|
|
|
@ -236,7 +236,7 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus)
|
|||
#ifdef GPS_EXTRAVERBOSE
|
||||
DEBUG_MSG("onGPSchanged() - lost validLocation\n");
|
||||
#endif
|
||||
if (config.payloadVariant.position.fixed_position) {
|
||||
if (config.position.fixed_position) {
|
||||
DEBUG_MSG("WARNING: Using fixed position\n");
|
||||
pos = node->position;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ NodeDB nodeDB;
|
|||
// we have plenty of ram so statically alloc this tempbuf (for now)
|
||||
EXT_RAM_ATTR DeviceState devicestate;
|
||||
MyNodeInfo &myNodeInfo = devicestate.my_node;
|
||||
Config config;
|
||||
LocalConfig config;
|
||||
ModuleConfig moduleConfig;
|
||||
ChannelFile channelFile;
|
||||
|
||||
|
@ -88,7 +88,7 @@ bool NodeDB::resetRadioConfig()
|
|||
radioGeneration++;
|
||||
|
||||
// radioConfig.has_preferences = true;
|
||||
if (config.payloadVariant.device.factory_reset) {
|
||||
if (config.device.factory_reset) {
|
||||
DEBUG_MSG("Performing factory reset!\n");
|
||||
installDefaultDeviceState();
|
||||
#ifndef NO_ESP32
|
||||
|
@ -126,11 +126,11 @@ bool NodeDB::resetRadioConfig()
|
|||
DEBUG_MSG("***** DEVELOPMENT MODE - DO NOT RELEASE *****\n");
|
||||
|
||||
// Sleep quite frequently to stress test the BLE comms, broadcast position every 6 mins
|
||||
config.payloadVariant.display.screen_on_secs = 10;
|
||||
config.payloadVariant.power.wait_bluetooth_secs = 10;
|
||||
config.payloadVariant.position.position_broadcast_secs = 6 * 60;
|
||||
config.payloadVariant.power.ls_secs = 60;
|
||||
config.payloadVariant.lora.region = Config_LoRaConfig_RegionCode_TW;
|
||||
config.display.screen_on_secs = 10;
|
||||
config.power.wait_bluetooth_secs = 10;
|
||||
config.position.position_broadcast_secs = 6 * 60;
|
||||
config.power.ls_secs = 60;
|
||||
config.lora.region = Config_LoRaConfig_RegionCode_TW;
|
||||
|
||||
// Enter super deep sleep soon and stay there not very long
|
||||
// radioConfig.preferences.mesh_sds_timeout_secs = 10;
|
||||
|
@ -145,13 +145,19 @@ bool NodeDB::resetRadioConfig()
|
|||
|
||||
void NodeDB::installDefaultConfig()
|
||||
{
|
||||
memset(&config, 0, sizeof(config));
|
||||
strncpy(config.payloadVariant.device.ntp_server, "0.pool.ntp.org", 32);
|
||||
memset(&config, 0, sizeof(LocalConfig));
|
||||
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()
|
||||
{
|
||||
memset(&moduleConfig, 0, sizeof(moduleConfig));
|
||||
memset(&moduleConfig, 0, sizeof(ModuleConfig));
|
||||
}
|
||||
|
||||
// void NodeDB::installDefaultRadioConfig()
|
||||
|
@ -161,19 +167,19 @@ void NodeDB::installDefaultModuleConfig()
|
|||
// resetRadioConfig();
|
||||
|
||||
// // 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_ALT_MSL);
|
||||
// }
|
||||
|
||||
void NodeDB::installDefaultChannels()
|
||||
{
|
||||
memset(&channelFile, 0, sizeof(channelFile));
|
||||
memset(&channelFile, 0, sizeof(ChannelFile));
|
||||
}
|
||||
|
||||
void NodeDB::installDefaultDeviceState()
|
||||
{
|
||||
memset(&devicestate, 0, sizeof(devicestate));
|
||||
memset(&devicestate, 0, sizeof(DeviceState));
|
||||
|
||||
*numNodes = 0; // Forget node DB
|
||||
|
||||
|
@ -250,7 +256,7 @@ void NodeDB::init()
|
|||
|
||||
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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -366,7 +372,7 @@ bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_
|
|||
f.close();
|
||||
|
||||
// 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");
|
||||
if (!FSCom.rename(filenameTmp.c_str(), filename))
|
||||
DEBUG_MSG("Error: can't rename new pref file\n");
|
||||
|
@ -396,7 +402,14 @@ void NodeDB::saveToDisk()
|
|||
FSCom.mkdir("/prefs");
|
||||
#endif
|
||||
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);
|
||||
saveChannelsToDisk();
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
extern DeviceState devicestate;
|
||||
extern ChannelFile channelFile;
|
||||
extern MyNodeInfo &myNodeInfo;
|
||||
extern Config config;
|
||||
extern LocalConfig config;
|
||||
extern ModuleConfig moduleConfig;
|
||||
extern User &owner;
|
||||
|
||||
|
@ -161,7 +161,7 @@ extern NodeDB nodeDB;
|
|||
// Our delay functions check for this for times that should never expire
|
||||
#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_wait_bluetooth_secs IF_ROUTER(1, 60)
|
||||
|
|
|
@ -100,10 +100,10 @@ const RegionInfo *myRegion;
|
|||
void initRegion()
|
||||
{
|
||||
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;
|
||||
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
|
||||
uint32_t delay = 0;
|
||||
|
||||
if (config.payloadVariant.device.role == Config_DeviceConfig_Role_Router ||
|
||||
config.payloadVariant.device.role == Config_DeviceConfig_Role_RouterClient) {
|
||||
if (config.device.role == Config_DeviceConfig_Role_Router ||
|
||||
config.device.role == Config_DeviceConfig_Role_RouterClient) {
|
||||
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);
|
||||
} else {
|
||||
|
@ -357,7 +357,7 @@ void RadioInterface::applyModemConfig()
|
|||
{
|
||||
// Set up default configuration
|
||||
// No Sync Words in LORA mode
|
||||
Config_LoRaConfig &loraConfig = config.payloadVariant.lora;
|
||||
Config_LoRaConfig &loraConfig = config.lora;
|
||||
auto channelSettings = channels.getPrimary();
|
||||
if (loraConfig.spread_factor == 0) {
|
||||
switch (loraConfig.modem_preset) {
|
||||
|
|
|
@ -93,8 +93,8 @@ bool RadioLibInterface::canSendImmediately()
|
|||
/// bluetooth comms code. If the txmit queue is empty it might return an error
|
||||
ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||
{
|
||||
if (config.payloadVariant.lora.region != Config_LoRaConfig_RegionCode_Unset) {
|
||||
if (disabled || config.payloadVariant.lora.tx_disabled) {
|
||||
if (config.lora.region != Config_LoRaConfig_RegionCode_Unset) {
|
||||
if (disabled || config.lora.tx_disabled) {
|
||||
DEBUG_MSG("send - lora_tx_disabled\n");
|
||||
packetPool.release(p);
|
||||
return ERRNO_DISABLED;
|
||||
|
@ -345,7 +345,7 @@ void RadioLibInterface::handleReceiveInterrupt()
|
|||
void RadioLibInterface::startSend(MeshPacket *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");
|
||||
packetPool.release(txp);
|
||||
} else {
|
||||
|
|
|
@ -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
|
||||
// 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 (config.payloadVariant.lora.hop_limit && config.payloadVariant.lora.hop_limit <= HOP_MAX) {
|
||||
p->hop_limit = (config.payloadVariant.lora.hop_limit >= HOP_MAX) ? HOP_MAX : config.payloadVariant.lora.hop_limit;
|
||||
if (config.lora.hop_limit && config.lora.hop_limit <= HOP_MAX) {
|
||||
p->hop_limit = (config.lora.hop_limit >= HOP_MAX) ? HOP_MAX : config.lora.hop_limit;
|
||||
} else {
|
||||
p->hop_limit = HOP_RELIABLE;
|
||||
}
|
||||
|
|
|
@ -118,8 +118,8 @@ MeshPacket *Router::allocForSending()
|
|||
p->which_payloadVariant = MeshPacket_decoded_tag; // Assume payload is decoded at start.
|
||||
p->from = nodeDB.getNodeNum();
|
||||
p->to = NODENUM_BROADCAST;
|
||||
if (config.payloadVariant.lora.hop_limit && config.payloadVariant.lora.hop_limit <= HOP_MAX) {
|
||||
p->hop_limit = (config.payloadVariant.lora.hop_limit >= HOP_MAX) ? HOP_MAX : config.payloadVariant.lora.hop_limit;
|
||||
if (config.lora.hop_limit && config.lora.hop_limit <= HOP_MAX) {
|
||||
p->hop_limit = (config.lora.hop_limit >= HOP_MAX) ? HOP_MAX : config.lora.hop_limit;
|
||||
} else {
|
||||
p->hop_limit = HOP_RELIABLE;
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ void Router::handleReceived(MeshPacket *p, RxSource src)
|
|||
void Router::perhapsHandleReceived(MeshPacket *p)
|
||||
{
|
||||
// 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)
|
||||
DEBUG_MSG("Ignoring incoming message, 0x%x is in our ignore list\n", p->from);
|
||||
|
|
|
@ -610,7 +610,7 @@ void handleReport(HTTPRequest *req, HTTPResponse *res)
|
|||
|
||||
// data->wifi
|
||||
String ipStr;
|
||||
if (config.payloadVariant.wifi.ap_mode || isSoftAPForced()) {
|
||||
if (config.wifi.ap_mode || isSoftAPForced()) {
|
||||
ipStr = String(WiFi.softAPIP().toString());
|
||||
} else {
|
||||
ipStr = String(WiFi.localIP().toString());
|
||||
|
|
|
@ -28,7 +28,7 @@ DNSServer dnsServer;
|
|||
WiFiUDP ntpUDP;
|
||||
|
||||
#ifndef DISABLE_NTP
|
||||
NTPClient timeClient(ntpUDP, config.payloadVariant.device.ntp_server);
|
||||
NTPClient timeClient(ntpUDP, config.device.ntp_server);
|
||||
#endif
|
||||
|
||||
uint8_t wifiDisconnectReason = 0;
|
||||
|
@ -59,8 +59,8 @@ static WifiSleepObserver wifiSleepObserver;
|
|||
|
||||
static int32_t reconnectWiFi()
|
||||
{
|
||||
const char *wifiName = config.payloadVariant.wifi.ssid;
|
||||
const char *wifiPsw = config.payloadVariant.wifi.psk;
|
||||
const char *wifiName = config.wifi.ssid;
|
||||
const char *wifiPsw = config.wifi.psk;
|
||||
|
||||
if (needReconnect && !WiFi.isConnected()) {
|
||||
// if (radioConfig.has_preferences && needReconnect && !WiFi.isConnected()) {
|
||||
|
@ -114,7 +114,7 @@ bool isWifiAvailable()
|
|||
return true;
|
||||
}
|
||||
|
||||
const char *wifiName = config.payloadVariant.wifi.ssid;
|
||||
const char *wifiName = config.wifi.ssid;
|
||||
|
||||
if (*wifiName) {
|
||||
return true;
|
||||
|
@ -184,14 +184,14 @@ bool initWifi(bool forceSoftAP)
|
|||
{
|
||||
forcedSoftAP = forceSoftAP;
|
||||
|
||||
if ((config.payloadVariant.wifi.ssid[0]) || forceSoftAP) {
|
||||
// if ((radioConfig.has_preferences && config.payloadVariant.wifi.ssid[0]) || forceSoftAP) {
|
||||
const char *wifiName = config.payloadVariant.wifi.ssid;
|
||||
const char *wifiPsw = config.payloadVariant.wifi.psk;
|
||||
if ((config.wifi.ssid[0]) || forceSoftAP) {
|
||||
// if ((radioConfig.has_preferences && config.wifi.ssid[0]) || forceSoftAP) {
|
||||
const char *wifiName = config.wifi.ssid;
|
||||
const char *wifiPsw = config.wifi.psk;
|
||||
|
||||
if (forceSoftAP) {
|
||||
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");
|
||||
} else {
|
||||
DEBUG_MSG("WiFi ... Client Mode\n");
|
||||
|
@ -203,7 +203,7 @@ bool initWifi(bool forceSoftAP)
|
|||
wifiPsw = NULL;
|
||||
|
||||
if (*wifiName || forceSoftAP) {
|
||||
if (config.payloadVariant.wifi.ap_mode || forceSoftAP) {
|
||||
if (config.wifi.ap_mode || forceSoftAP) {
|
||||
|
||||
IPAddress apIP(192, 168, 42, 1);
|
||||
WiFi.onEvent(WiFiEvent);
|
||||
|
@ -362,7 +362,7 @@ static void WiFiEvent(WiFiEvent_t event)
|
|||
|
||||
void handleDNSResponse()
|
||||
{
|
||||
if (config.payloadVariant.wifi.ap_mode || isSoftAPForced()) {
|
||||
if (config.wifi.ap_mode || isSoftAPForced()) {
|
||||
dnsServer.processNextRequest();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -176,27 +176,27 @@ void AdminModule::handleSetConfig(const Config &c)
|
|||
switch (c.which_payloadVariant) {
|
||||
case Config_device_tag:
|
||||
DEBUG_MSG("Setting config: Device\n");
|
||||
config.payloadVariant.device = c.payloadVariant.device;
|
||||
config.device = c.payloadVariant.device;
|
||||
break;
|
||||
case Config_position_tag:
|
||||
DEBUG_MSG("Setting config: Position\n");
|
||||
config.payloadVariant.position = c.payloadVariant.position;
|
||||
config.position = c.payloadVariant.position;
|
||||
break;
|
||||
case Config_power_tag:
|
||||
DEBUG_MSG("Setting config: Power\n");
|
||||
config.payloadVariant.power = c.payloadVariant.power;
|
||||
config.power = c.payloadVariant.power;
|
||||
break;
|
||||
case Config_wifi_tag:
|
||||
DEBUG_MSG("Setting config: WiFi\n");
|
||||
config.payloadVariant.wifi = c.payloadVariant.wifi;
|
||||
config.wifi = c.payloadVariant.wifi;
|
||||
break;
|
||||
case Config_display_tag:
|
||||
DEBUG_MSG("Setting config: Display\n");
|
||||
config.payloadVariant.display = c.payloadVariant.display;
|
||||
config.display = c.payloadVariant.display;
|
||||
break;
|
||||
case Config_lora_tag:
|
||||
DEBUG_MSG("Setting config: LoRa\n");
|
||||
config.payloadVariant.lora = c.payloadVariant.lora;
|
||||
config.lora = c.payloadVariant.lora;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -271,33 +271,33 @@ void AdminModule::handleGetConfig(const MeshPacket &req, const uint32_t configTy
|
|||
case AdminMessage_ConfigType_DEVICE_CONFIG:
|
||||
DEBUG_MSG("Getting config: Device\n");
|
||||
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;
|
||||
case AdminMessage_ConfigType_POSITION_CONFIG:
|
||||
DEBUG_MSG("Getting config: Position\n");
|
||||
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;
|
||||
case AdminMessage_ConfigType_POWER_CONFIG:
|
||||
DEBUG_MSG("Getting config: Power\n");
|
||||
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;
|
||||
case AdminMessage_ConfigType_WIFI_CONFIG:
|
||||
DEBUG_MSG("Getting config: WiFi\n");
|
||||
res.get_config_response.which_payloadVariant = Config_wifi_tag;
|
||||
res.get_config_response.payloadVariant.wifi = config.payloadVariant.wifi;
|
||||
writeSecret(res.get_config_response.payloadVariant.wifi.psk, config.payloadVariant.wifi.psk);
|
||||
res.get_config_response.payloadVariant.wifi = config.wifi;
|
||||
writeSecret(res.get_config_response.payloadVariant.wifi.psk, config.wifi.psk);
|
||||
break;
|
||||
case AdminMessage_ConfigType_DISPLAY_CONFIG:
|
||||
DEBUG_MSG("Getting config: Display\n");
|
||||
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;
|
||||
case AdminMessage_ConfigType_LORA_CONFIG:
|
||||
DEBUG_MSG("Getting config: LoRa\n");
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,6 @@ int32_t NodeInfoModule::runOnce()
|
|||
DEBUG_MSG("Sending our nodeinfo to mesh (wantReplies=%d)\n", requestReplies);
|
||||
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;
|
||||
}
|
|
@ -60,7 +60,7 @@ MeshPacket *PositionModule::allocReply()
|
|||
|
||||
// configuration of POSITION packet
|
||||
// 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
|
||||
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
|
||||
uint32_t now = millis();
|
||||
if (lastGpsSend == 0 || now - lastGpsSend >= config.payloadVariant.position.position_broadcast_secs
|
||||
? config.payloadVariant.position.position_broadcast_secs
|
||||
if (lastGpsSend == 0 || now - lastGpsSend >= config.position.position_broadcast_secs
|
||||
? config.position.position_broadcast_secs
|
||||
: default_broadcast_interval_secs * 1000) {
|
||||
|
||||
// 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");
|
||||
}
|
||||
|
||||
} 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.
|
||||
if (airTime->channelUtilizationPercent() < 25) {
|
||||
|
|
|
@ -71,7 +71,7 @@ int32_t RangeTestModule::runOnce()
|
|||
DEBUG_MSG("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock());
|
||||
DEBUG_MSG("gpsStatus->getDOP() %d\n", gpsStatus->getDOP());
|
||||
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.
|
||||
if (airTime->channelUtilizationPercent() < 25) {
|
||||
|
|
|
@ -21,7 +21,7 @@ int32_t StoreForwardModule::runOnce()
|
|||
|
||||
if (moduleConfig.payloadVariant.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.
|
||||
if (this->busy) {
|
||||
|
@ -392,13 +392,13 @@ StoreForwardModule::StoreForwardModule()
|
|||
*/
|
||||
|
||||
moduleConfig.payloadVariant.store_forward.enabled = 1;
|
||||
config.payloadVariant.power.is_always_powered = 1;
|
||||
config.power.is_always_powered = 1;
|
||||
}
|
||||
|
||||
if (moduleConfig.payloadVariant.store_forward.enabled) {
|
||||
|
||||
// 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");
|
||||
if (ESP.getPsramSize()) {
|
||||
if (ESP.getFreePsram() >= 1024 * 1024) {
|
||||
|
|
Ładowanie…
Reference in New Issue