sforkowany z mirror/meshtastic-firmware
Power state lies and other fixes (#1698)
* Power interval defaults and factory reset * Ternary * Fixesraytac-diy
rodzic
9481461145
commit
0f87adad7b
|
@ -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.power.sds_secs ? config.power.sds_secs : default_sds_secs * 1000LL);
|
||||
doDeepSleep(config.power.sds_secs * 1000);
|
||||
}
|
||||
|
||||
extern Power *power;
|
||||
|
@ -51,7 +51,7 @@ static uint32_t secsSlept;
|
|||
|
||||
static void lsEnter()
|
||||
{
|
||||
DEBUG_MSG("lsEnter begin, ls_secs=%u\n", config.power.ls_secs > 0 ? config.power.ls_secs : default_ls_secs);
|
||||
DEBUG_MSG("lsEnter begin, ls_secs=%u\n", config.power.ls_secs);
|
||||
screen->setOn(false);
|
||||
secsSlept = 0; // How long have we been sleeping this time
|
||||
|
||||
|
@ -65,7 +65,7 @@ static void lsIdle()
|
|||
#ifdef ARCH_ESP32
|
||||
|
||||
// Do we have more sleeping to do?
|
||||
if (secsSlept < config.power.ls_secs ? config.power.ls_secs : default_ls_secs) {
|
||||
if (secsSlept < config.power.ls_secs) {
|
||||
// Briefly come out of sleep long enough to blink the led once every few seconds
|
||||
uint32_t sleepTime = 30;
|
||||
|
||||
|
@ -334,8 +334,6 @@ void PowerFSM_setup()
|
|||
// On most boards we use light-sleep to be our main state, but on NRF52 we just stay in DARK
|
||||
State *lowPowerState = &stateLS;
|
||||
|
||||
uint32_t meshSds = 0;
|
||||
|
||||
#ifdef ARCH_ESP32
|
||||
// We never enter light-sleep or NB states on NRF52 (because the CPU uses so little power normally)
|
||||
|
||||
|
@ -343,20 +341,14 @@ void PowerFSM_setup()
|
|||
if (isRouter || config.power.is_power_saving) {
|
||||
powerFSM.add_timed_transition(&stateNB, &stateLS, getConfiguredOrDefaultMs(config.power.min_wake_secs, default_min_wake_secs), NULL, "Min wake timeout");
|
||||
powerFSM.add_timed_transition(&stateDARK, &stateLS, getConfiguredOrDefaultMs(config.power.wait_bluetooth_secs, default_wait_bluetooth_secs), NULL, "Bluetooth timeout");
|
||||
meshSds = config.power.mesh_sds_timeout_secs ? config.power.mesh_sds_timeout_secs : default_mesh_sds_timeout_secs;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
meshSds = UINT32_MAX;
|
||||
}
|
||||
|
||||
#else
|
||||
#elif defined (ARCH_NRF52)
|
||||
lowPowerState = &stateDARK;
|
||||
meshSds = UINT32_MAX; // Workaround for now: Don't go into deep sleep on the RAK4631
|
||||
#endif
|
||||
|
||||
if (meshSds != UINT32_MAX)
|
||||
powerFSM.add_timed_transition(lowPowerState, &stateSDS, meshSds * 1000, NULL, "mesh timeout");
|
||||
if (config.power.sds_secs != UINT32_MAX)
|
||||
powerFSM.add_timed_transition(lowPowerState, &stateSDS, config.power.sds_secs * 1000, NULL, "mesh timeout");
|
||||
|
||||
powerFSM.run_machine(); // run one interation of the state machine, so we run our on enter tasks for the initial DARK state
|
||||
}
|
||||
|
|
|
@ -116,6 +116,8 @@ class NodeDB
|
|||
size_t getNumOnlineNodes();
|
||||
|
||||
void initConfigIntervals(), initModuleConfigIntervals();
|
||||
|
||||
bool factoryReset();
|
||||
|
||||
private:
|
||||
/// Find a node in our DB, create an empty NodeInfo if missing
|
||||
|
@ -129,7 +131,6 @@ class NodeDB
|
|||
newStatus.notifyObservers(&status);
|
||||
}
|
||||
|
||||
bool factoryReset();
|
||||
|
||||
/// read our db from flash
|
||||
void loadFromDisk();
|
||||
|
@ -182,7 +183,7 @@ extern NodeDB nodeDB;
|
|||
#define default_broadcast_interval_secs IF_ROUTER(ONE_DAY / 2, 15 * 60)
|
||||
#define default_wait_bluetooth_secs IF_ROUTER(1, 60)
|
||||
#define default_mesh_sds_timeout_secs IF_ROUTER(NODE_DELAY_FOREVER, 2 * 60 * 60)
|
||||
#define default_sds_secs 365 * ONE_DAY
|
||||
#define default_sds_secs IF_ROUTER(ONE_DAY, UINT32_MAX) // Default to forever super deep sleep
|
||||
#define default_ls_secs IF_ROUTER(ONE_DAY, 5 * 60)
|
||||
#define default_min_wake_secs 10
|
||||
#define default_screen_on_secs 60 * 10
|
||||
|
|
|
@ -114,7 +114,12 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
|
|||
handleGetDeviceMetadata(mp);
|
||||
break;
|
||||
}
|
||||
|
||||
case AdminMessage_factory_reset_tag: {
|
||||
DEBUG_MSG("Initiating factory reset\n");
|
||||
nodeDB.factoryReset();
|
||||
rebootAtMsec = millis() + (5 * 1000);
|
||||
break;
|
||||
}
|
||||
#ifdef ARCH_PORTDUINO
|
||||
case AdminMessage_exit_simulator_tag:
|
||||
DEBUG_MSG("Exiting simulator\n");
|
||||
|
|
|
@ -35,4 +35,5 @@
|
|||
// Leave undefined to disable our PMU IRQ handler. DO NOT ENABLE THIS because the pmuirq can cause sperious interrupts
|
||||
// and waking from light sleep
|
||||
// #define PMU_IRQ 35
|
||||
#define HAS_AXP192
|
||||
#define HAS_AXP192
|
||||
#define GPS_UBLOX
|
Ładowanie…
Reference in New Issue