### Initialize PublishQueuePosix Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Call this function from your setup() to initialize the library. ```cpp void setup() ``` -------------------------------- ### Initialize PublishQueuePosixRK Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Call this from setup() to initialize the PublishQueuePosix instance. ```cpp PublishQueuePosix::instance().setup(); ``` -------------------------------- ### PublishQueuePosixRK Setup Function Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/index.html The required setup function for the PublishQueuePosixRK library. This must be called once during the application's setup phase. ```cpp void setup() { PublishQueuePosix::instance().setup(); } ``` -------------------------------- ### setup Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/functions_func.html Initializes the PublishQueuePosix object. This function returns a reference to the PublishQueuePosix object. ```APIDOC ## setup ### Description Initializes the PublishQueuePosix object. ### Method N/A (This appears to be a C++ class method call) ### Endpoint N/A ### Parameters None explicitly documented. ### Response Returns a reference to a [PublishQueuePosix](class_publish_queue_posix.html#ad8590bc7920dad66e85ed60c65ecd867) object. ``` -------------------------------- ### PublishQueuePosix::setup() Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Initializes the PublishQueuePosix library. This function must be called from the global setup() function. ```APIDOC ## void PublishQueuePosix::setup() ### Description Initializes the PublishQueuePosix library. This function must be called from the global setup() function. ### Method void ### Endpoint setup() ### Parameters None ### Request Example ```cpp void setup() ``` ### Response None ``` -------------------------------- ### PublishQueuePosix::setup() Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/index.html Initializes the PublishQueuePosix library. This method must be called from setup() to ensure the library is ready for use. ```APIDOC ## PublishQueuePosix::setup() ### Description You must call this from setup() to initialize this library. ### Method void ### Parameters None ### Request Example None ### Response None ``` -------------------------------- ### PublishQueuePosix::setup Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/_publish_queue_posix_r_k_8h_source.html Initializes the PublishQueuePosix library. This method must be called from the `setup()` function of your application to ensure the library is properly configured before use. ```APIDOC ## PublishQueuePosix::setup ### Description Initializes the PublishQueuePosix library. This function must be called once during the application's setup phase to prepare the library for operation. ### Signature `void setup()` ``` -------------------------------- ### Get RAM Queue Size Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Retrieves the current size of the RAM-based queue. ```cpp size_t getRamQueueSize() const ``` -------------------------------- ### getNumEvents Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/_publish_queue_posix_r_k_8h_source.html Gets the total number of events queued. This includes events in both RAM and file queues. ```APIDOC ## getNumEvents ### Description Gets the total number of events queued. This includes events in both RAM and file queues. ### Signature size_t getNumEvents() ### Returns size_t - The total number of queued events. ``` -------------------------------- ### Get Directory Path for Queue Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Retrieves the directory path currently set for the queue. The returned path will not end with a slash. ```cpp const char * getDirPath() const ``` -------------------------------- ### Get Server IP Address Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/more-tests/automated-test/README.md Use 'dig' to resolve the IP address of the Particle cloud server. This is useful for configuring the device to point to a specific server. ```bash dig 1.udp.particle.io ``` -------------------------------- ### PublishQueuePosix::getPausePublishing Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Gets the state of the pause publishing flag. ```APIDOC ## PublishQueuePosix::getPausePublishing ### Description Gets the state of the pause publishing flag. ### Method bool ### Endpoint getPausePublishing() const ``` -------------------------------- ### getFileQueueSize Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/_publish_queue_posix_r_k_8h_source.html Gets the size of the file-based queue. This represents the number of events stored on disk. ```APIDOC ## getFileQueueSize ### Description Gets the size of the file-based queue. This represents the number of events stored on disk. ### Signature size_t getFileQueueSize() const ### Returns size_t - The number of events in the file queue. ``` -------------------------------- ### PublishQueuePosix Callbacks and Initialization Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/class_publish_queue_posix.html Methods for setting up callbacks and initializing the PublishQueuePosix library. ```APIDOC ## PublishQueuePosix::withPublishCompleteUserCallback ### Description Adds a callback function to call when publishing is complete. ### Method `withPublishCompleteUserCallback(std::function< void(bool succeeded, const char *eventName, const char *eventData)> cb)` ### Parameters - **cb** (std::function< void(bool succeeded, const char *eventName, const char *eventData)>) - The callback function to be executed upon publish completion. ## PublishQueuePosix::setup ### Description Initializes the PublishQueuePosix library. This must be called from the global `setup()` function. ### Method `setup()` ``` -------------------------------- ### getRamQueueSize Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/functions_func.html Gets the size of the RAM-based queue. This function returns a reference to the PublishQueuePosix object. ```APIDOC ## getRamQueueSize ### Description Gets the size of the RAM-based queue. ### Method N/A (This appears to be a C++ class method call) ### Endpoint N/A ### Parameters None explicitly documented. ### Response Returns a reference to a [PublishQueuePosix](class_publish_queue_posix.html#a7e9de217df46af588b7b95c5f3ae339d) object. ``` -------------------------------- ### getFileQueueSize Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/functions_func.html Gets the size of the file-based queue. This function returns a reference to the PublishQueuePosix object. ```APIDOC ## getFileQueueSize ### Description Gets the size of the file-based queue. ### Method N/A (This appears to be a C++ class method call) ### Endpoint N/A ### Parameters None explicitly documented. ### Response Returns a reference to a [PublishQueuePosix](class_publish_queue_posix.html#a4ceda8818c2265cfd11ec63ecbe63b42) object. ``` -------------------------------- ### PublishQueuePosixRK Includes Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/_publish_queue_posix_r_k_8h_source.html Includes necessary libraries for Particle devices and file system operations. ```c++ #include "Particle.h" #include "SequentialFileRK.h" #include ``` -------------------------------- ### Run PublishQueuePosix Loop Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md You must call the loop method from the global loop() function to process the queue. ```cpp void loop() ``` -------------------------------- ### getRamQueueSize Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/_publish_queue_posix_r_k_8h_source.html Gets the size of the RAM queue. This represents the number of events currently held in memory. ```APIDOC ## getRamQueueSize ### Description Gets the size of the RAM queue. This represents the number of events currently held in memory. ### Signature size_t getRamQueueSize() const ### Returns size_t - The number of events in the RAM queue. ``` -------------------------------- ### PublishQueuePosixRK Class Methods Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/_publish_queue_posix_r_k_8h_source.html Provides access to the singleton instance of PublishQueuePosixRK and allows configuration of queue sizes and directory paths. ```APIDOC ## PublishQueuePosixRK Class ### Description The `PublishQueuePosixRK` class provides a mechanism for queuing events to be published. It supports both in-memory (RAM) and file-based queues, allowing for persistent storage of events. ### Methods #### `static PublishQueuePosixRK& instance()` * **Description**: Returns a reference to the singleton instance of the `PublishQueuePosixRK` class. This is the primary way to access the publish queue functionality. * **Usage**: Call this method to get the global instance of the queue. #### `PublishQueuePosixRK& withRamQueueSize(size_t size)` * **Description**: Configures the maximum size of the in-memory (RAM) queue. Events exceeding this size will be moved to the file queue if configured. * **Parameters**: * `size` (size_t) - The maximum number of events to store in the RAM queue. * **Returns**: A reference to the `PublishQueuePosixRK` instance for chaining. #### `size_t getRamQueueSize() const` * **Description**: Returns the current maximum size configured for the RAM queue. * **Returns**: The RAM queue size. #### `PublishQueuePosixRK& withFileQueueSize(size_t size)` * **Description**: Configures the maximum size of the file-based queue. This determines the maximum number of events that can be stored persistently on the filesystem. * **Parameters**: * `size` (size_t) - The maximum number of events to store in the file queue. * **Returns**: A reference to the `PublishQueuePosixRK` instance for chaining. #### `size_t getFileQueueSize() const` * **Description**: Returns the current maximum size configured for the file queue. * **Returns**: The file queue size. #### `PublishQueuePosixRK& withDirPath(const char *dirPath)` * **Description**: Sets the directory path where the file-based queue will be stored. This is essential for persistent event storage. * **Parameters**: * `dirPath` (const char *) - The path to the directory for the file queue. * **Returns**: A reference to the `PublishQueuePosixRK` instance for chaining. #### `const char *getDirPath() const` * **Description**: Returns the currently configured directory path for the file queue. * **Returns**: The directory path string. #### `PublishQueuePosixRK& withPublishCompleteUserCallback(std::function cb)` * **Description**: Registers a callback function to be invoked when a publish operation completes. The callback receives a status indicating success or failure, along with the event name and data. * **Parameters**: * `cb` (std::function) - The callback function to execute upon completion. * **Returns**: A reference to the `PublishQueuePosixRK` instance for chaining. #### `void setup()` * **Description**: Initializes the publish queue system. This method should be called once during the application's setup phase before any publishing occurs. #### `void loop()` * **Description**: Processes the publish queue. This method should be called periodically within the main application loop to handle event publishing and manage queue operations. #### `bool publish(const char *eventName, PublishFlags flags1, PublishFlags flags2 = PublishFlags())` * **Description**: Publishes an event with the given name and flags. The event is added to the queue and will be processed by the `loop()` method. Supports combining flags from two sources. * **Parameters**: * `eventName` (const char *) - The name of the event to publish. * `flags1` (PublishFlags) - The primary set of flags for the event. * `flags2` (PublishFlags, optional) - An additional set of flags for the event. Defaults to an empty set. * **Returns**: `true` if the event was successfully added to the queue, `false` otherwise (e.g., if the queue is full). ``` -------------------------------- ### Publish an Event with PublishQueuePosixRK Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Use this to publish an event with a topic, data buffer, and flags. The flags can include PRIVATE and WITH_ACK. ```cpp PublishQueuePosix::instance().publish("testEvent", buf, PRIVATE | WITH_ACK); ``` -------------------------------- ### getDirPath Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/class_publish_queue_posix.html Gets the directory path that was set using withDirPath(). The returned path will not end with a slash. ```APIDOC ## getDirPath ### Description Gets the directory path that was set using withDirPath(). The returned path will not end with a slash. ### Method const char * ### Endpoint PublishQueuePosix::getDirPath() const ``` -------------------------------- ### PublishQueuePosix Methods Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/class_publish_queue_posix.html This section details the core methods for managing the publish queue, including locking, unlocking, and obtaining the singleton instance. ```APIDOC ## lock ### Description Lock the queue protection mutex. ### Method (Not specified, likely internal) ### Endpoint (Not applicable) ## tryLock ### Description Attempt to lock the queue protection mutex. Returns true if the lock was acquired, false otherwise. ### Method (Not specified, likely internal) ### Endpoint (Not applicable) ### Return Value - bool - true if the lock was acquired, false otherwise. ## unlock ### Description Unlock the queue protection mutex. ### Method (Not specified, likely internal) ### Endpoint (Not applicable) ## instance ### Description Gets the singleton instance of this class. This method allows access to the single PublishQueuePosix object throughout the application. ### Method static ### Endpoint (Not applicable) ### Return Value - [PublishQueuePosix] & - A reference to the singleton instance of the PublishQueuePosix class. ``` -------------------------------- ### Configure Device Server Address Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/more-tests/automated-test/README.md Configure the Particle device to use a custom server by providing its IP address and port. Ensure the IP address is public or accessible via port forwarding. ```bash particle keys server --protocol udp --host 24.92.248.215 --port 5684 ec.pub.der ``` -------------------------------- ### Get File Queue Size Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Retrieves the current maximum number of files allowed for the file-based queue. ```cpp size_t getFileQueueSize() const ``` -------------------------------- ### getNumEvents Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/functions_func.html Gets the total number of events currently in the queue. This function returns a reference to the PublishQueuePosix object. ```APIDOC ## getNumEvents ### Description Gets the total number of events currently in the queue. ### Method N/A (This appears to be a C++ class method call) ### Endpoint N/A ### Parameters None explicitly documented. ### Response Returns a reference to a [PublishQueuePosix](class_publish_queue_posix.html#a1e04445ef87bdfdf78fc5d7a2a67ac46) object. ``` -------------------------------- ### PublishQueuePosix::withDirPath Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/_publish_queue_posix_r_k_8h_source.html Sets the directory to use as the queue directory. This is a required setting. ```APIDOC ## PublishQueuePosix::withDirPath ### Description Sets the directory to use as the queue directory. This is a required setting. ### Method PublishQueuePosix & ### Endpoint PublishQueuePosixRK.h:106 ``` -------------------------------- ### instance Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/functions_func.html Returns the singleton instance of the PublishQueuePosix class. This function returns a reference to the PublishQueuePosix object. ```APIDOC ## instance ### Description Returns the singleton instance of the PublishQueuePosix class. ### Method N/A (This appears to be a C++ class method call) ### Endpoint N/A ### Parameters None explicitly documented. ### Response Returns a reference to a [PublishQueuePosix](class_publish_queue_posix.html#af641a55b459d3a0b465945bc87f8c9e4) object. ``` -------------------------------- ### getDirPath Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/functions_func.html Gets the directory path where the queue files are stored. This function returns a reference to the PublishQueuePosix object. ```APIDOC ## getDirPath ### Description Gets the directory path where the queue files are stored. ### Method N/A (This appears to be a C++ class method call) ### Endpoint N/A ### Parameters None explicitly documented. ### Response Returns a reference to a [PublishQueuePosix](class_publish_queue_posix.html#acc3222ff156a5b65e3cca85ce199e566) object. ``` -------------------------------- ### Configure File Queue Size Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Set the maximum size of the file queue. The default is 100 events. ```cpp PublishQueuePosix::instance().withFileQueueSize(50); ``` -------------------------------- ### PublishQueuePosix::getPausePublishing Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/_publish_queue_posix_r_k_8h_source.html Gets the state of the pause publishing flag. Returns true if it is a good time to go to sleep. ```APIDOC ## PublishQueuePosix::getPausePublishing ### Description Gets the state of the pause publishing flag. Returns true if it is a good time to go to sleep. ### Method const ### Endpoint PublishQueuePosixRK.h:412 ``` -------------------------------- ### PublishQueuePosix::withDirPath(const char * dirPath) Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Sets the directory path for the queue. This is a required setting. The directory will be created if it doesn't exist, but only one level of directory will be created. ```APIDOC ## PublishQueuePosix & PublishQueuePosix::withDirPath(const char * dirPath) ### Description Sets the directory path to be used for the queue. This is a required setting. The directory will be created if it doesn't exist, but only one level of directory will be created. The parent directory must already exist. The path can end with or without a slash; if included, it will be removed. You cannot use the root directory as a queue. ### Method PublishQueuePosix & ### Endpoint withDirPath(const char * dirPath) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **dirPath** (const char *) - Required - The pathname for the queue directory, using Unix-style separators. ``` -------------------------------- ### PublishQueuePosix::getDirPath Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/index.html Gets the directory path that was previously set using withDirPath(). The returned path will not end with a slash. ```APIDOC ## PublishQueuePosix::getDirPath ### Description Gets the directory path set using withDirPath(). ### Method GET ### Endpoint /PublishQueuePosix/getDirPath ### Returns - **const char ofoam** - The directory path. ``` -------------------------------- ### withDirPath(const char * _dirPath) Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/class_publish_queue_posix.html Sets the directory path to be used for the queue directory. This method must be called before publishing events. The path should be Unix-style with '/' as the directory separator. ```APIDOC ## withDirPath(const char * _dirPath) ### Description Sets the directory path to be used for the queue directory. This method must be called before publishing events. The path should be Unix-style with '/' as the directory separator. ### Method `PublishQueuePosix&` ### Parameters - **_dirPath** (const char *) - the pathname, Unix-style with / as the directory separator. ``` -------------------------------- ### Restore Device to Default Cloud Mode Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/more-tests/automated-test/README.md Revert the Particle device back to its default cloud communication mode by running the 'particle keys server' command without any additional options. ```bash particle keys server ``` -------------------------------- ### withDirPath Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/functions_func.html Sets the directory path for queue files and returns a reference to the PublishQueuePosix object. ```APIDOC ## withDirPath ### Description Sets the directory path for queue files. ### Method N/A (This appears to be a C++ class method call) ### Endpoint N/A ### Parameters None explicitly documented. ### Response Returns a reference to a [PublishQueuePosix](class_publish_queue_posix.html#aebea9de0fa9df57fcae3bda39bead02f) object. ``` -------------------------------- ### Get Pause Publishing State Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Retrieves the current state of the pause publishing flag. Returns true if publishing is paused, false otherwise. ```cpp bool getPausePublishing() const ``` -------------------------------- ### Configure RAM Queue Size Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Set the size of the RAM queue. Setting to 0 means all events are written to the file system immediately. The default is 2. ```cpp PublishQueuePosix::instance().withRamQueueSize(0); ``` -------------------------------- ### Set Directory Path for Queue Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Sets the directory path for the queue. This is a required setting. The directory will be created if it doesn't exist, but only one level of directory creation is supported. ```cpp PublishQueuePosix & withDirPath(const char * dirPath) ``` -------------------------------- ### Get Number of Queued Events Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Returns the total number of events currently in both the RAM-based and file-based queues. This operation is fast as the file queue length is stored in RAM. ```cpp size_t getNumEvents() ``` -------------------------------- ### Event Handling Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/_publish_queue_posix_r_k_8h_source.html Methods for creating and reading publish queue events. ```APIDOC ## newRamEvent ### Description Creates a new publish queue event in RAM. ### Method `PublishQueueEvent *newRamEvent(const char *eventName, const char *eventData, PublishFlags flags)` ### Parameters - `eventName` (const char *) - The name of the event. - `eventData` (const char *) - The data for the event. - `flags` (PublishFlags) - Flags associated with the event. ### Response - Returns a pointer to the newly created `PublishQueueEvent` object, or `nullptr` if creation fails. --- ## readQueueFile ### Description Reads a publish queue event from a specified file. ### Method `PublishQueueEvent *readQueueFile(int fileNum)` ### Parameters - `fileNum` (int) - The number of the file to read from. ### Response - Returns a pointer to the `PublishQueueEvent` object read from the file, or `nullptr` if the file cannot be read or is invalid. ``` -------------------------------- ### PublishQueuePosix::writeQueueToFiles Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md If there are events in the RAM queue, write them to files in the flash file system. ```APIDOC ## PublishQueuePosix::writeQueueToFiles ### Description If there are events in the RAM queue, write them to files in the flash file system. ### Method void ### Endpoint writeQueueToFiles() ``` -------------------------------- ### getNumEvents Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/class_publish_queue_posix.html Gets the total number of events queued, including both RAM-based and file-based queues. This operation is fast as the file queue length is stored in RAM. If an event is currently being sent, the result includes this event. ```APIDOC ## getNumEvents ### Description Gets the total number of events queued, including both RAM-based and file-based queues. This operation is fast as the file queue length is stored in RAM. If an event is currently being sent, the result includes this event. ### Method size_t ### Endpoint PublishQueuePosix::getNumEvents() ``` -------------------------------- ### getNumEvents Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/index.html Gets the total number of events queued. This is the number of events in the RAM-based queue and the file-based queue. This operation is fast; the file queue length is stored in RAM, so this command does not need to access the file system. If an event is currently being sent, the result includes this event. ```APIDOC ## getNumEvents ### Description Gets the total number of events queued. This is the number of events in the RAM-based queue and the file-based queue. This operation is fast; the file queue length is stored in RAM, so this command does not need to access the file system. If an event is currently being sent, the result includes this event. ### Method size_t ### Endpoint getNumEvents() ``` -------------------------------- ### PublishQueuePosix::writeQueueToFiles Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/_publish_queue_posix_r_k_8h_source.html If there are events in the RAM queue, write them to files in the flash file system. ```APIDOC ## PublishQueuePosix::writeQueueToFiles ### Description If there are events in the RAM queue, write them to files in the flash file system. ### Method void ### Endpoint PublishQueuePosixRK.h:257 ``` -------------------------------- ### tryLock Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/index.html Attempt the queue protection mutex. ```APIDOC ## tryLock ### Description Attempt the queue protection mutex. ### Method bool ### Endpoint tryLock() ``` -------------------------------- ### PublishQueuePosix::getNumEvents Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Gets the total number of events queued. This is the number of events in the RAM-based queue and the file-based queue. This operation is fast; the file queue length is stored in RAM, so this command does not need to access the file system. If an event is currently being sent, the result includes this event. ```APIDOC ## PublishQueuePosix::getNumEvents ### Description Gets the total number of events queued. This is the number of events in the RAM-based queue and the file-based queue. This operation is fast; the file queue length is stored in RAM, so this command does not need to access the file system. If an event is currently being sent, the result includes this event. ### Method size_t ### Endpoint getNumEvents() ``` -------------------------------- ### PublishQueuePosix Event Management Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/class_publish_queue_posix.html This section covers methods for allocating new events in RAM and reading events from queue files. ```APIDOC ## newRamEvent ### Description Allocate a new event structure in RAM. This is used to prepare an event before it is queued for publishing. ### Method (Not specified, likely internal) ### Endpoint (Not applicable) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Parameters - **eventName** (const char *) - The name of the event. - **eventData** (const char *) - The data associated with the event. - **flags** (PublishFlags) - Flags to control the publishing behavior. ### Return Value - [PublishQueueEvent] * - A pointer to the newly allocated event structure in RAM. ``` ```APIDOC ## readQueueFile ### Description Read an event from a sequentially numbered file. This method is used to retrieve events that have been persisted to the file system. ### Method (Not specified, likely internal) ### Endpoint (Not applicable) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Parameters - **fileNum** (int) - The sequential number of the file to read. ### Return Value - [PublishQueueEvent] * - A pointer to the event structure read from the file. ``` -------------------------------- ### loop Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/functions_func.html Enters the main processing loop of the queue. This function returns a reference to the PublishQueuePosix object. ```APIDOC ## loop ### Description Enters the main processing loop of the queue. ### Method N/A (This appears to be a C++ class method call) ### Endpoint N/A ### Parameters None explicitly documented. ### Response Returns a reference to a [PublishQueuePosix](class_publish_queue_posix.html#a157e71d583df634b290b5ab3e08156f5) object. ``` -------------------------------- ### PublishQueuePosix Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/functions_func.html Constructor for the PublishQueuePosix class. This function returns a reference to the PublishQueuePosix object. ```APIDOC ## PublishQueuePosix ### Description Constructor for the PublishQueuePosix class. ### Method N/A (This appears to be a C++ class method call) ### Endpoint N/A ### Parameters None explicitly documented. ### Response Returns a reference to a [PublishQueuePosix](class_publish_queue_posix.html#a7985d5f2907b43c2701c3747d536a0d0) object. ``` -------------------------------- ### PublishQueuePosix Configuration Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/class_publish_queue_posix.html Methods for configuring the PublishQueuePosix, including queue sizes and directory paths. ```APIDOC ## PublishQueuePosix::withRamQueueSize ### Description Sets the RAM based queue size. ### Method `withRamQueueSize(size_t size)` ### Parameters - **size** (size_t) - The desired size for the RAM queue. ## PublishQueuePosix::getRamQueueSize ### Description Gets the size of the RAM queue. ### Method `getRamQueueSize() const` ### Returns - size_t - The current size of the RAM queue. ## PublishQueuePosix::withFileQueueSize ### Description Sets the file-based queue size. ### Method `withFileQueueSize(size_t size)` ### Parameters - **size** (size_t) - The desired size for the file-based queue. ## PublishQueuePosix::getFileQueueSize ### Description Gets the file queue size. ### Method `getFileQueueSize() const` ### Returns - size_t - The current size of the file queue. ## PublishQueuePosix::withDirPath ### Description Sets the directory to use as the queue directory. This is required! ### Method `withDirPath(const char *dirPath)` ### Parameters - **dirPath** (const char *) - The path to the directory for the queue. ## PublishQueuePosix::getDirPath ### Description Gets the directory path set using `withDirPath()`. ### Method `getDirPath() const` ### Returns - const char* - The configured directory path. ``` -------------------------------- ### withPublishCompleteUserCallback Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/functions_func.html Sets a user callback for publish completion and returns a reference to the PublishQueuePosix object. ```APIDOC ## withPublishCompleteUserCallback ### Description Sets a user callback for publish completion. ### Method N/A (This appears to be a C++ class method call) ### Endpoint N/A ### Parameters None explicitly documented. ### Response Returns a reference to a [PublishQueuePosix](class_publish_queue_posix.html#aeb2e79c07a1e1a50016e53d3c75a28d4) object. ``` -------------------------------- ### PublishQueuePosix::tryLock Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Attempt the queue protection mutex. ```APIDOC ## PublishQueuePosix::tryLock ### Description Attempt the queue protection mutex. ### Method bool ### Endpoint tryLock() ``` -------------------------------- ### publishCompleteCallback Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/functions_func.html Callback function executed upon completion of a publish operation. This function returns a reference to the PublishQueuePosix object. ```APIDOC ## publishCompleteCallback ### Description Callback function executed upon completion of a publish operation. ### Method N/A (This appears to be a C++ class method call) ### Endpoint N/A ### Parameters None explicitly documented. ### Response Returns a reference to a [PublishQueuePosix](class_publish_queue_posix.html#a802d684d2498d64ae99e5e90edf4acb1) object. ``` -------------------------------- ### Callback and State Management Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/_publish_queue_posix_r_k_8h_source.html Methods related to handling publish completion callbacks and managing internal states. ```APIDOC ## publishCompleteCallback ### Description A callback function invoked when a publish operation is completed. ### Method `void publishCompleteCallback(bool succeeded, const char *eventName, const char *eventData)` ### Parameters - `succeeded` (bool) - Indicates whether the publish operation was successful. - `eventName` (const char *) - The name of the event that was published. - `eventData` (const char *) - The data associated with the published event. --- ## stateConnectWait ### Description Transitions the publish queue state to wait for a connection. ### Method `void stateConnectWait()` --- ## stateWait ### Description Transitions the publish queue to a general waiting state. ``` -------------------------------- ### PublishQueuePosix::withDirPath Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/index.html Sets the directory path where event files will be stored. This setting is mandatory for file-based queuing. ```APIDOC ## PublishQueuePosix::withDirPath ### Description Sets the directory to use as the queue directory. This is a required setting for the PublishQueuePosix to function with file-based storage. ### Method PublishQueuePosix & ### Parameters #### Path Parameters - **dirPath** (const char *) - Required - The path to the directory to be used for storing event files. ### Request Example ```cpp // Example of setting the directory path PublishQueuePosix pq; pq.withDirPath("/data/events"); ``` ### Response #### Success Response - **PublishQueuePosix &**: Returns a reference to the PublishQueuePosix object for chaining. ``` -------------------------------- ### PublishQueuePosix::publishCompleteCallback Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/_publish_queue_posix_r_k_8h_source.html Callback function for the BackgroundPublishRK library to signal the completion of a publish operation. It receives a boolean indicating success and the event name and data associated with the publish. ```APIDOC ## PublishQueuePosix::publishCompleteCallback ### Description Callback for BackgroundPublishRK library. It is invoked when a publish operation completes, indicating whether it was successful and providing the event name and data. ### Signature `void publishCompleteCallback(bool succeeded, const char *eventName, const char *eventData)` ### Parameters * **succeeded** (bool) - Indicates if the publish operation was successful. * **eventName** (const char *) - The name of the event that was published. * **eventData** (const char *) - The data associated with the published event. ``` -------------------------------- ### PublishQueuePosix::withFileQueueSize() Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/index.html Sets the maximum size of the file-based queue. The default is 100 events. ```APIDOC ## PublishQueuePosix::withFileQueueSize(size_t size) ### Description Sets the file-based queue size (default is 100). ### Method PublishQueuePosix & ### Parameters * **size** (size_t) - The desired maximum size for the file-based queue. ### Request Example None ### Response An instance of PublishQueuePosix for chaining. ``` -------------------------------- ### PublishQueuePosix::writeQueueToFiles Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/index.html Writes events currently in the RAM queue to files in the flash file system. ```APIDOC ## PublishQueuePosix::writeQueueToFiles ### Description If there are events in the RAM queue, this function writes them to files in the flash file system, persisting them. ### Method void writeQueueToFiles() ### Returns This method does not return a value. ``` -------------------------------- ### Queue Management Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/_publish_queue_posix_r_k_8h_source.html Methods for managing the state and content of the publish queues. ```APIDOC ## writeQueueToFiles ### Description Writes the current state of the publish queues to files. ### Method `void writeQueueToFiles()` --- ## clearQueues ### Description Clears all publish queues. ### Method `void clearQueues()` --- ## getNumEvents ### Description Retrieves the total number of events currently in all publish queues. ### Method `size_t getNumEvents()` --- ## checkQueueLimits ### Description Checks and enforces the limits defined for the publish queues. ``` -------------------------------- ### Write Queue to Files Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Writes any events currently in the RAM queue to files in the flash file system. This ensures persistence of queued events. ```cpp void writeQueueToFiles() ``` -------------------------------- ### PublishQueuePosix::withPublishCompleteUserCallback Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/_publish_queue_posix_r_k_8h_source.html Adds a callback function to call when publishing is complete. The callback receives a boolean indicating success, and C-strings for the event name and data. ```APIDOC ## PublishQueuePosix::withPublishCompleteUserCallback ### Description Adds a callback function to call when publishing is complete. The callback receives a boolean indicating success, and C-strings for the event name and data. ### Method PublishQueuePosix & ### Endpoint PublishQueuePosixRK.h:134 ``` -------------------------------- ### withFileQueueSize Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/functions_func.html Sets the size of the file-based queue and returns a reference to the PublishQueuePosix object. ```APIDOC ## withFileQueueSize ### Description Sets the size of the file-based queue. ### Method N/A (This appears to be a C++ class method call) ### Endpoint N/A ### Parameters None explicitly documented. ### Response Returns a reference to a [PublishQueuePosix](class_publish_queue_posix.html#a5963d98e3b9c4e1254cedd4cb0d3a89c) object. ``` -------------------------------- ### PublishQueuePosix::loop() Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Processes the event queue. This method must be called from the global loop() function. ```APIDOC ## void PublishQueuePosix::loop() ### Description Processes the event queue. This method must be called from the global loop() function. ### Method void ### Endpoint loop() ### Parameters None ### Request Example ```cpp void loop() ``` ### Response None ``` -------------------------------- ### Set RAM Queue Size Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Sets the size of the RAM-based queue. If events exceed this size, they are moved to flash files. Setting to 0 stores events immediately on flash. ```cpp PublishQueuePosix & withRamQueueSize(size_t size) ``` -------------------------------- ### PublishQueuePosix::getDirPath() const Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Retrieves the configured directory path for the queue. ```APIDOC ## const char * PublishQueuePosix::getDirPath() const ### Description Gets the directory path that was set using withDirPath(). The returned path will not end with a slash. ### Method const char * ### Endpoint getDirPath() ### Parameters None ### Response #### Success Response (200) - **dirPath** (const char *) - The configured directory path for the queue. ``` -------------------------------- ### Check Sleep Readiness Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Determines if it is an appropriate time to put the system to sleep. Returns true if no publish is in progress and the queue is empty, or if pausePublishing is true and the current publish has completed or the system is not cloud-connected. ```cpp bool getCanSleep() const ``` -------------------------------- ### publish(const char * _eventName, const char * _data, PublishFlags _flags1, PublishFlags _flags2) Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/class_publish_queue_posix.html Publishes an event with event name, data, and two sets of flags. The second set of flags is optional. Returns true if the event was queued, false otherwise. This function is typically used for publishing events with associated data. ```APIDOC ## publish(const char * _eventName, const char * _data, PublishFlags _flags1, PublishFlags _flags2) ### Description Publishes an event with event name, data, and two sets of flags. The second set of flags is optional. Returns true if the event was queued, false otherwise. This function is typically used for publishing events with associated data. ### Method `bool` ### Parameters - **_eventName** (const char *) - The name of the event (63 character maximum). - **_data** (const char *) - The event data (255 bytes maximum, 622 bytes in system firmware 0.8.0-rc.4 and later). - **_flags1** (PublishFlags) - Normally PRIVATE. You can also use PUBLIC, but one or the other must be specified. - **_flags2** (PublishFlags) - (optional) You can use NO_ACK or WITH_ACK if desired. ### Returns `true` if the event was queued or `false` if it was not. This function almost always returns true. If you queue more events than fit in the buffer the oldest (sometimes second oldest) is discarded. ``` -------------------------------- ### PublishQueuePosix::publish (event, flags) Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/index.html Overload for publishing an event without additional data. It takes the event name and two sets of flags. ```APIDOC ## PublishQueuePosix::publish (event, flags) ### Description Overload for publishing an event. ### Method POST ### Endpoint /PublishQueuePosix/publish ### Parameters #### Request Body - **eventName** (string) - Required - The name of the event (63 character maximum). - **flags1** (PublishFlags) - Required - Normally PRIVATE. Can also be PUBLIC. - **flags2** (PublishFlags) - Optional - Can be NO_ACK or WITH_ACK. ### Returns - **bool** - true if the event was queued or false if it was not. ``` -------------------------------- ### publish Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/_publish_queue_posix_r_k_8h_source.html Overload for publishing an event with event name and flags. This method is a convenience wrapper around the common publish function. ```APIDOC ## publish (Overload 1) ### Description Overload for publishing an event with event name and flags. This method is a convenience wrapper around the common publish function. ### Signature bool publish(const char *eventName, PublishFlags flags1, PublishFlags flags2=PublishFlags()) ### Parameters * **eventName** (const char *) - The name of the event to publish. * **flags1** (PublishFlags) - The first set of publish flags. * **flags2** (PublishFlags, optional) - The second set of publish flags. Defaults to an empty PublishFlags object. ### Returns bool - True if the event was successfully queued for publishing, false otherwise. ``` -------------------------------- ### systemEventHandler Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/functions_func.html Handles system events. This function returns a reference to the PublishQueuePosix object. ```APIDOC ## systemEventHandler ### Description Handles system events. ### Method N/A (This appears to be a C++ class method call) ### Endpoint N/A ### Parameters None explicitly documented. ### Response Returns a reference to a [PublishQueuePosix](class_publish_queue_posix.html#a5119c4048d829dc9c269a84e385723d4) object. ``` -------------------------------- ### PublishQueuePosix::loop Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/_publish_queue_posix_r_k_8h_source.html The main loop function that must be called from the global loop() function. This method processes the event queues and handles the publishing logic. ```APIDOC ## PublishQueuePosix::loop ### Description The main loop function that must be called from the global loop() function. This method processes the event queues and handles the publishing logic. ### Signature void loop() ### Remarks It is crucial to call this method regularly from your application's main loop to ensure events are processed and published correctly. ``` -------------------------------- ### publish(const char * _eventName, PublishFlags _flags1, PublishFlags _flags2) Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/class_publish_queue_posix.html Publishes an event with event name and two sets of flags. The second set of flags is optional. Returns true if the event was queued, false otherwise. This overload is useful when no specific event data needs to be sent. ```APIDOC ## publish(const char * _eventName, PublishFlags _flags1, PublishFlags _flags2) ### Description Publishes an event with event name and two sets of flags. The second set of flags is optional. Returns true if the event was queued, false otherwise. This overload is useful when no specific event data needs to be sent. ### Method `bool` ### Parameters - **_eventName** (const char *) - The name of the event (63 character maximum). - **_flags1** (PublishFlags) - Normally PRIVATE. You can also use PUBLIC, but one or the other must be specified. - **_flags2** (PublishFlags) - (optional) You can use NO_ACK or WITH_ACK if desired. ### Returns `true` if the event was queued or `false` if it was not. This function almost always returns true. If you queue more events than fit in the buffer the oldest (sometimes second oldest) is discarded. ``` -------------------------------- ### Publish Event (With Data) Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Publishes an event with a name, data, and optional flags. Returns true if queued, false otherwise. If the queue is full, the oldest event may be discarded. ```cpp bool publish(const char * eventName, const char * data, PublishFlags flags1, PublishFlags flags2) ``` -------------------------------- ### withRamQueueSize Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/functions_func.html Sets the size of the RAM-based queue and returns a reference to the PublishQueuePosix object. ```APIDOC ## withRamQueueSize ### Description Sets the size of the RAM-based queue. ### Method N/A (This appears to be a C++ class method call) ### Endpoint N/A ### Parameters None explicitly documented. ### Response Returns a reference to a [PublishQueuePosix](class_publish_queue_posix.html#a9b64145e8d3d2221f1a71a3368b1f29e) object. ``` -------------------------------- ### checkQueueLimits Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/class_publish_queue_posix.html Checks the queue limits and discards events if necessary. When the RAM queue exceeds its limit, all events are moved to files. ```APIDOC ## checkQueueLimits ### Description Checks the queue limits and discards events if necessary. When the RAM queue exceeds its limit, all events are moved to files. ### Method void ### Endpoint PublishQueuePosix::checkQueueLimits() ``` -------------------------------- ### PublishQueuePosix::publish (event, data, flags) Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/index.html Overload for publishing an event with associated data. It takes the event name, data, and two sets of flags. ```APIDOC ## PublishQueuePosix::publish (event, data, flags) ### Description Overload for publishing an event with data. ### Method POST ### Endpoint /PublishQueuePosix/publish ### Parameters #### Request Body - **eventName** (string) - Required - The name of the event (63 character maximum). - **data** (string) - Required - The event data (255 bytes maximum, 622 bytes in system firmware 0.8.0-rc.4 and later). - **flags1** (PublishFlags) - Required - Normally PRIVATE. Can also be PUBLIC. - **flags2** (PublishFlags) - Optional - Can be NO_ACK or WITH_ACK. ### Returns - **bool** - true if the event was queued or false if it was not. ``` -------------------------------- ### Publish Event (No Data) Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/README.md Publishes an event with a name and optional flags. Returns true if queued, false otherwise. If the queue is full, the oldest event may be discarded. ```cpp bool publish(const char * eventName, PublishFlags flags1, PublishFlags flags2) ``` -------------------------------- ### stateConnectWait Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/functions_func.html Transitions the queue to the connect wait state. This function returns a reference to the PublishQueuePosix object. ```APIDOC ## stateConnectWait ### Description Transitions the queue to the connect wait state. ### Method N/A (This appears to be a C++ class method call) ### Endpoint N/A ### Parameters None explicitly documented. ### Response Returns a reference to a [PublishQueuePosix](class_publish_queue_posix.html#ac5c7fb70b600e93c585caf85fbcf8665) object. ``` -------------------------------- ### stateWait Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/functions_func.html Transitions the queue to the general wait state. This function returns a reference to the PublishQueuePosix object. ```APIDOC ## stateWait ### Description Transitions the queue to the general wait state. ### Method N/A (This appears to be a C++ class method call) ### Endpoint N/A ### Parameters None explicitly documented. ### Response Returns a reference to a [PublishQueuePosix](class_publish_queue_posix.html#a120b8d168445713bfb825cedc613e314) object. ``` -------------------------------- ### publish Source: https://github.com/rickkas7/publishqueueposixrk/blob/main/docs/functions_func.html Publishes an event from the queue. This function returns a reference to the PublishQueuePosix object. ```APIDOC ## publish ### Description Publishes an event from the queue. ### Method N/A (This appears to be a C++ class method call) ### Endpoint N/A ### Parameters None explicitly documented. ### Response Returns a reference to a [PublishQueuePosix](class_publish_queue_posix.html#a2bcadc762c4c3e889920997f0e9cd1de) object. ```