#pragma once #include namespace roro { // Safe Mode (CONTEXT.md): after kCrashLimit starts in a row that ended in a crash, the firmware // starts only what it takes to be fixed over the air (Wi-Fi, Firmware Updates, the Debug Console). // Rollback covers new firmware; this covers firmware that was confirmed and crashes anyway. struct SafeMode { static constexpr int kCrashLimit = 3; static constexpr uint32_t kStableAfterMs = 60000; // then the count starts over // Called first thing at boot with the count so far; returns the new count. static int countAtBoot(bool lastStartWasCrash, int crashesBefore) { return lastStartWasCrash ? crashesBefore + 1 : 0; } static bool active(int crashes) { return crashes >= kCrashLimit; } }; } // namespace roro