CloudConfigRK
Public Member Functions | Protected Attributes
CloudConfigStorageFile< SIZE > Class Template Reference

Storage method to store data in the flash file system. More...

#include <CloudConfigRK.h>

Inheritance diagram for CloudConfigStorageFile< SIZE >:
CloudConfigStorageData CloudConfigStorage

Public Member Functions

 CloudConfigStorageFile (const char *path)
 Constructor for storage of data in a flash file system file. More...
 
virtual void setup ()
 Called during setup() to load, validate, and parse the JSON data.
 
virtual bool save ()
 Called to save the data to the file when it is updated.
 
- Public Member Functions inherited from CloudConfigStorageData
 CloudConfigStorageData ()
 Default constructor.
 
 CloudConfigStorageData (CloudConfigDataHeader *header, size_t dataSize)
 Constructor with header. More...
 
CloudConfigStorageDatawithData (CloudConfigDataHeader *header, size_t dataSize)
 Specify the data header and data location. More...
 
virtual CloudConfigDataHeadergetDataHeader ()
 Gets a pointer to the CloudConfigDataHeader structure.
 
void validate ()
 Validate the CloudConfigDataHeader. More...
 
const char *const getJsonData () const
 Gets a pointer to the JSON data for reading (const) More...
 
size_t getMaxJsonDataSize () const
 Returns the maximum size of the JSON data in characters. More...
 
char * getJsonData ()
 Gets a pointer to the JSON data for writing (not const) More...
 
size_t getTotalSize () const
 Gets the total size of the buffer including both the header and the JSON data. More...
 
virtual bool updateData (const char *json)
 This method is called after subclasses update the JSON data. More...
 
- Public Member Functions inherited from CloudConfigStorage
 CloudConfigStorage ()
 Constructor. Base class constructor is empty.
 
bool hasJsonData () const
 Returns true if there is JSON data field is not empty.
 
virtual void parse ()
 Called after the JSON data is updated to parse the data using the JSON parser. More...
 
virtual void loop ()
 Called from loop(). Optional. Only needed if the storage method wants loop processing time.
 
JSONValue getJSONValue ()
 Gets the top level (outer) JSONValue object. More...
 
JSONValue getJSONValueForKey (const char *key)
 Gets the value for a given key in the top-level outer JSON object. More...
 
JSONValue getJSONValueAtIndex (size_t index)
 Gets the value for a given index in the a JSON array in the top-level outer JSON array. More...
 

Protected Attributes

String path
 The file system path passed to the contructor.
 
CloudConfigData< SIZE > dataBuffer
 Copy of the file data in RAM.
 
- Protected Attributes inherited from CloudConfigStorageData
CloudConfigDataHeaderheader
 Pointer to the header with data after it.
 
size_t dataSize
 Size of the JSON data, not including sizeof(CloudConfigDataHeader)
 
- Protected Attributes inherited from CloudConfigStorage
JSONValue jsonObj
 The JSONValue object for the outermost JSON object (or array) More...
 

Additional Inherited Members

- Static Public Member Functions inherited from CloudConfigStorage
static JSONValue getJSONValueForKey (JSONValue parentObj, const char *key)
 Gets the value for a given key in the a JSON object. More...
 
static JSONValue getJSONValueAtIndex (JSONValue parentObj, size_t index)
 Gets the value for a given index in the a JSON array. More...
 
- Protected Member Functions inherited from CloudConfigStorage
virtual ~CloudConfigStorage ()
 Destructor. Base class destructor is empty. Also, you can't delete one of these.
 
 CloudConfigStorage (const CloudConfigStorage &)=delete
 This class is not copyable.
 
CloudConfigStorageoperator= (const CloudConfigStorage &)=delete
 This class is not copyable.
 

Detailed Description

template<size_t SIZE>
class CloudConfigStorageFile< SIZE >

Storage method to store data in the flash file system.

On Gen 3 devices (Argon, Boron, B Series SoM, Tracker SoM) the file system is usually a good choice. Since the emulated EEPROM is just a file on the file system on Gen 3, there is no performance advantage for using EEPROM over File.

The file system is 2 MB on most devices, 4 MB on the Tracker.

Parameters
SIZEthe templated maximum size of the JSON data.

You need for SIZE to be larger enough for the largest configuration you will have, but it does reserve sizeof(CloudConfigDataHeader) + SIZE bytes of RAM, so you don't want it be excessively large. For function, subscription and webhook update methods, SIZE can't be larger than 622 bytes.

Constructor & Destructor Documentation

◆ CloudConfigStorageFile()

template<size_t SIZE>
CloudConfigStorageFile< SIZE >::CloudConfigStorageFile ( const char *  path)
inline

Constructor for storage of data in a flash file system file.

Parameters
pathThe pathname (slash separated, like Unix) to the file to store the data in.

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