Generalized-Core-Counter 3.20
Particle-based generalized core counter firmware
Loading...
Searching...
No Matches
Cloud Class Reference

This class is a singleton; you do not create one as a global, on the stack, or with new. More...

#include <Cloud.h>

Public Member Functions

bool loadConfigurationFromCloud ()
 Load and apply configuration from cloud ledgers.
void loop ()
 Service deferred cloud work; call from main loop.
bool publishDataToLedger ()
 Publish latest sensor data to device-data ledger.
void setup ()
 Perform setup operations; call this from global application setup().
bool writeDeviceStatusToCloud ()
 Write current device configuration to device-status ledger.

Static Public Member Functions

static Cloudinstance ()
 Gets the singleton instance of this class, allocating it if necessary.

Protected Member Functions

 Cloud ()
 The constructor is protected because the class is a singleton.
 Cloud (const Cloud &)=delete
 This class is a singleton and cannot be copied.
Cloudoperator= (const Cloud &)=delete
 This class is a singleton and cannot be copied.
virtual ~Cloud ()
 The destructor is protected because the class is a singleton and cannot be deleted.

Static Protected Attributes

static Cloud_instance
 Singleton instance of this class.

Detailed Description

This class is a singleton; you do not create one as a global, on the stack, or with new.

From global application setup you must call: Cloud::instance().setup();

Definition at line 48 of file Cloud.h.

Constructor & Destructor Documentation

◆ Cloud() [1/2]

Cloud::Cloud ( )
protected

The constructor is protected because the class is a singleton.

Use Cloud::instance() to instantiate the singleton.

Definition at line 27 of file Cloud.cpp.

Referenced by Cloud(), instance(), and operator=().

◆ ~Cloud()

Cloud::~Cloud ( )
protectedvirtual

The destructor is protected because the class is a singleton and cannot be deleted.

Definition at line 33 of file Cloud.cpp.

◆ Cloud() [2/2]

Cloud::Cloud ( const Cloud & )
protecteddelete

This class is a singleton and cannot be copied.

References Cloud().

Member Function Documentation

◆ instance()

Cloud & Cloud::instance ( )
static

Gets the singleton instance of this class, allocating it if necessary.

Use Cloud::instance() to instantiate the singleton.

Definition at line 20 of file Cloud.cpp.

References _instance, and Cloud().

Referenced by handleConnectingState(), handleFirmwareUpdateState(), loop(), publishData(), and setup().

◆ loadConfigurationFromCloud()

bool Cloud::loadConfigurationFromCloud ( )

Load and apply configuration from cloud ledgers.

Reads merged configuration from default-settings (Product scope) and device-settings (Device scope), with device settings overriding defaults.

Returns
true if configuration was successfully applied

Definition at line 153 of file Cloud.cpp.

Referenced by handleConnectingState(), and handleFirmwareUpdateState().

◆ loop()

void Cloud::loop ( )

Service deferred cloud work; call from main loop.

Used to keep any ledger/status publishing out of callback context and to avoid stacking multiple expensive operations in a single loop() iteration.

Definition at line 188 of file Cloud.cpp.

References writeDeviceStatusToCloud().

Referenced by loop().

◆ operator=()

Cloud & Cloud::operator= ( const Cloud & )
protecteddelete

This class is a singleton and cannot be copied.

References Cloud().

◆ publishDataToLedger()

bool Cloud::publishDataToLedger ( )

Publish latest sensor data to device-data ledger.

Updates the Device→Cloud ledger with current sensor readings, making data visible in Particle Console even when device is offline

Returns
true if successful

Definition at line 589 of file Cloud.cpp.

References COUNTING, current, OCCUPANCY, SCHEDULED, and sysStatus.

◆ setup()

void Cloud::setup ( )

Perform setup operations; call this from global application setup().

You typically use Cloud::instance().setup();

Definition at line 36 of file Cloud.cpp.

Referenced by setup().

◆ writeDeviceStatusToCloud()

bool Cloud::writeDeviceStatusToCloud ( )

Write current device configuration to device-status ledger.

Updates Device→Cloud ledger with current configuration for Console visibility.

Returns
true if successful

Definition at line 520 of file Cloud.cpp.

References FIRMWARE_VERSION, sensorConfig, and sysStatus.

Referenced by loop().

Member Data Documentation

◆ _instance

Cloud * Cloud::_instance
staticprotected

Singleton instance of this class.

The object pointer to this class is stored here. It's NULL at system boot.

Definition at line 257 of file Cloud.h.

Referenced by instance().


The documentation for this class was generated from the following files: