mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-01 18:29:56 +00:00
6e0b6684ee
* Extend node max to 100 and remove mesh_sds_timeout_secs * Const pointers for you and you and you * Fixes and supressions * Missed it * uint * Resize * Derp
40 lines
1.3 KiB
C++
40 lines
1.3 KiB
C++
#include "NodeDB.h"
|
|
#include "PowerFSM.h"
|
|
#include "concurrency/OSThread.h"
|
|
#include "configuration.h"
|
|
#include "main.h"
|
|
#include "power.h"
|
|
|
|
namespace concurrency
|
|
{
|
|
/// Wrapper to convert our powerFSM stuff into a 'thread'
|
|
class PowerFSMThread : public OSThread
|
|
{
|
|
public:
|
|
// callback returns the period for the next callback invocation (or 0 if we should no longer be called)
|
|
PowerFSMThread() : OSThread("PowerFSM") {}
|
|
|
|
protected:
|
|
int32_t runOnce() override
|
|
{
|
|
powerFSM.run_machine();
|
|
|
|
/// If we are in power state we force the CPU to wake every 10ms to check for serial characters (we don't yet wake
|
|
/// cpu for serial rx - FIXME)
|
|
const auto state = powerFSM.getState();
|
|
canSleep = (state != &statePOWER) && (state != &stateSERIAL);
|
|
|
|
if (powerStatus->getHasUSB()) {
|
|
timeLastPowered = millis();
|
|
} else if (config.power.on_battery_shutdown_after_secs > 0 && config.power.on_battery_shutdown_after_secs != UINT32_MAX &&
|
|
millis() > (timeLastPowered +
|
|
getConfiguredOrDefaultMs(
|
|
config.power.on_battery_shutdown_after_secs))) { // shutdown after 30 minutes unpowered
|
|
powerFSM.trigger(EVENT_SHUTDOWN);
|
|
}
|
|
|
|
return 10;
|
|
}
|
|
};
|
|
|
|
} // namespace concurrency
|