Generalized-Core-Counter 3.20
Particle-based generalized core counter firmware
Loading...
Searching...
No Matches
Cloud.h
Go to the documentation of this file.
1
34
35#ifndef __CLOUD_H
36#define __CLOUD_H
37
38#include "Particle.h"
39#include "device_pinout.h"
40#include "MyPersistentData.h"
41
48class Cloud {
49public:
55 static Cloud &instance();
56
62 void setup();
63
73
82
92
100 void loop();
101
102private:
111 bool applyConfigurationFromLedger();
112
118 bool applySensorConfig();
119
125 bool applyTimingConfig();
126
132 bool applyPowerConfig();
133
137 static void onDefaultSettingsSync(Ledger ledger);
138
142 static void onDeviceSettingsSync(Ledger ledger);
143
147 void mergeConfiguration();
148
154 bool applyMessagingConfig();
155
161 bool applyModesConfig();
162
172 template<typename T>
173 bool validateRange(T value, T min, T max, const String& name);
174
180 bool hasNonDefaultConfig();
181
185 Ledger defaultSettingsLedger;
186
190 Ledger deviceSettingsLedger;
191
195 Ledger deviceStatusLedger;
196
200 Ledger deviceDataLedger;
201
205 LedgerData mergedConfig;
206
210 bool ledgersSynced;
211
215 String lastPublishedStatus;
216
223 bool lastApplySuccess;
224
225 // Deferred work flags
226 bool pendingStatusPublish;
227 bool pendingConfigApply;
228
229protected:
235 Cloud();
236
240 virtual ~Cloud();
241
245 Cloud(const Cloud&) = delete;
246
250 Cloud& operator=(const Cloud&) = delete;
251
258
259};
260#endif /* __CLOUD_H */
Persistent Data Storage Structures - EEPROM/Retained Memory Management.
bool writeDeviceStatusToCloud()
Write current device configuration to device-status ledger.
Definition Cloud.cpp:520
Cloud(const Cloud &)=delete
This class is a singleton and cannot be copied.
void setup()
Perform setup operations; call this from global application setup().
Definition Cloud.cpp:36
bool loadConfigurationFromCloud()
Load and apply configuration from cloud ledgers.
Definition Cloud.cpp:153
bool publishDataToLedger()
Publish latest sensor data to device-data ledger.
Definition Cloud.cpp:589
Cloud & operator=(const Cloud &)=delete
This class is a singleton and cannot be copied.
static Cloud * _instance
Singleton instance of this class.
Definition Cloud.h:257
static Cloud & instance()
Gets the singleton instance of this class, allocating it if necessary.
Definition Cloud.cpp:20
void loop()
Service deferred cloud work; call from main loop.
Definition Cloud.cpp:188
virtual ~Cloud()
The destructor is protected because the class is a singleton and cannot be deleted.
Definition Cloud.cpp:33
Cloud()
The constructor is protected because the class is a singleton.
Definition Cloud.cpp:27
Pinout definitions for the carrier board and sensors.