Generalized-Core-Counter 3.20
Particle-based generalized core counter firmware
Loading...
Searching...
No Matches
State_Connect.cpp File Reference
#include "state/State_Common.h"
#include "Config.h"
#include "Cloud.h"
#include "DeviceInfoLedger.h"
#include "MyPersistentData.h"
#include "PublishQueuePosixRK.h"
#include "SensorManager.h"
#include "device_pinout.h"
#include "SensorDefinitions.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 handleFirmwareUpdateState ()
bool isRadioPoweredOn ()
void requestFullDisconnectAndRadioOff ()
void requestRadioPowerOff ()

Function Documentation

◆ handleConnectingState()

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:

  • CONN_PHASE_START: log signal strength and request Particle.connect().
  • CONN_PHASE_WAIT_CLOUD: poll Particle.connected() up to connectAttemptBudgetSec (from sysStatus / Ledger), raising alert 31 on timeout.
  • CONN_PHASE_LOAD_CONFIG: load configuration from cloud ledgers and raise alert 41 on failure.
  • CONN_PHASE_PUBLISH_LEDGER: optionally publish device-data to the ledger (skipped when entered from REPORTING_STATE to avoid clobbering hourlyCount), log queue depth, and transition to FIRMWARE_UPDATE_STATE when updates are pending or back to IDLE_STATE. Connection duration is tracked in sysStatus so budgets and field behaviour can be analysed from device-status data.

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().

◆ handleFirmwareUpdateState()

void handleFirmwareUpdateState ( )

◆ isRadioPoweredOn()

bool isRadioPoweredOn ( )

Definition at line 21 of file State_Connect.cpp.

Referenced by handleSleepingState().

◆ requestFullDisconnectAndRadioOff()

void requestFullDisconnectAndRadioOff ( )

◆ requestRadioPowerOff()

void requestRadioPowerOff ( )

Definition at line 31 of file State_Connect.cpp.

Referenced by requestFullDisconnectAndRadioOff().