|
Generalized-Core-Counter 3.20
Particle-based generalized core counter firmware
|
#include "StateMachine.h"Go to the source code of this file.
Functions | |
| void | handleConnectingState () |
| CONNECTING_STATE: establish cloud connection using a phased, non-blocking state machine. | |
| void | handleCountingMode () |
| Handle sensor events in COUNTING mode. | |
| void | handleErrorState () |
| void | handleFirmwareUpdateState () |
| void | handleIdleState () |
| void | handleOccupancyMode () |
| Handle sensor events in OCCUPANCY mode. | |
| void | handleReportingState () |
| void | handleSleepingState () |
| SLEEPING_STATE: deep sleep between reporting intervals. | |
| void | updateOccupancyState () |
| Update occupancy state based on debounce timeout. | |
| void handleConnectingState | ( | ) |
CONNECTING_STATE: establish cloud connection using a phased, non-blocking state machine.
Uses an internal ConnectPhase enum to break connection into small steps that each complete within a single loop() iteration:
Definition at line 68 of file State_Connect.cpp.
References connectedStartMs, current, FIRMWARE_UPDATE_STATE, firstConnectionObserved, firstConnectionQueueDrainedLogged, IDLE_STATE, Cloud::instance(), Cloud::loadConfigurationFromCloud(), maxConnectAttemptMs, measure, oldState, publishDiagnosticSafe(), publishStateTransition(), REPORTING_STATE, requestFullDisconnectAndRadioOff(), SLEEPING_STATE, state, and sysStatus.
Referenced by loop().
| void handleCountingMode | ( | ) |
Handle sensor events in COUNTING mode.
In counting mode, each sensor detection increments counters. Counts are tracked hourly and daily. Used for: traffic counting, people counting, event tracking
Definition at line 24 of file State_Modes.cpp.
References BLUE_LED, countSignalTimer, current, SensorManager::instance(), and loop().
Referenced by loop().
| void handleErrorState | ( | ) |
Definition at line 100 of file State_Error.cpp.
References ab1805, CONNECTED, current, IDLE_STATE, oldState, publishStateTransition(), requestFullDisconnectAndRadioOff(), resetWait, state, and sysStatus.
Referenced by loop().
| void handleFirmwareUpdateState | ( | ) |
Definition at line 173 of file State_Connect.cpp.
References BUTTON_PIN, IDLE_STATE, Cloud::instance(), Cloud::loadConfigurationFromCloud(), oldState, publishStateTransition(), SLEEPING_STATE, and state.
Referenced by loop().
| void handleIdleState | ( | ) |
Definition at line 29 of file State_Idle.cpp.
References CONNECTED, connectedStartMs, countSignalTimer, current, ensureSensorEnabled(), firstConnectionObserved, firstConnectionQueueDrainedLogged, SensorManager::instance(), isWithinOpenHours(), measure, oldState, publishStateTransition(), REPORTING_STATE, SCHEDULED, sensorDetect, SLEEPING_STATE, state, and sysStatus.
Referenced by loop().
| void handleOccupancyMode | ( | ) |
Handle sensor events in OCCUPANCY mode.
In occupancy mode, first detection marks space as "occupied". Space remains occupied until debounce timeout expires without new detections. Tracks total occupied time for reporting. Used for: room occupancy, parking space detection, resource availability
Definition at line 58 of file State_Modes.cpp.
References BLUE_LED, current, SensorManager::instance(), loop(), sysStatus, and updateOccupancyState().
Referenced by loop().
| void handleReportingState | ( | ) |
Definition at line 16 of file State_Report.cpp.
References CONNECTING_STATE, COUNTING, current, dailyCleanup(), IDLE_STATE, measure, oldState, publishData(), publishStateTransition(), state, suppressAlert40ThisSession, and sysStatus.
Referenced by loop().
| void handleSleepingState | ( | ) |
SLEEPING_STATE: deep sleep between reporting intervals.
...
Definition at line 20 of file State_Sleep.cpp.
References ab1805, BLUE_LED, BUTTON_PIN, config, CONNECTED, CONNECTING_STATE, conv, COUNTING, countSignalTimer, current, ensureSensorEnabled(), ERROR_STATE, hibernateDisabledForSession, IDLE_STATE, SensorManager::initializeFromConfig(), SensorManager::instance(), intPin, isRadioPoweredOn(), isWithinOpenHours(), OCCUPANCY, oldState, SensorManager::onEnterSleep(), SensorManager::onExitSleep(), publishStateTransition(), REPORTING_STATE, requestFullDisconnectAndRadioOff(), secondsUntilNextOpen(), sensorDetect, SLEEPING_STATE, state, sysStatus, userSwitchDetected, and wakeBoundary.
Referenced by loop().
| void updateOccupancyState | ( | ) |
Update occupancy state based on debounce timeout.
If space is occupied and debounce timeout has expired without new sensor events, mark space as unoccupied. Accumulates total occupied time for daily reporting.
Definition at line 91 of file State_Modes.cpp.
References BLUE_LED, current, and sysStatus.
Referenced by handleOccupancyMode().