RainMaker Common¶
Utilities¶
Factory Storage¶
Functions¶
-
esp_err_t
esp_rmaker_factory_init(void)¶ Initialize Factory NVS
This initializes the Factory NVS partition which will store data that should not be cleared even after a reset to factory.
- Return
ESP_OK on success.
- Return
error on failure.
-
void *
esp_rmaker_factory_get(const char *key)¶ Get value from factory NVS
This will search for the specified key in the Factory NVS partition, allocate the required memory to hold it, copy the value and return the pointer to it. It is responsibility of the caller to free the memory when the value is no more required.
- Return
pointer to the value on success.
- Return
NULL on failure.
- Parameters
[in] key: The key of the value to be read from factory NVS.
-
size_t
esp_rmaker_factory_get_size(const char *key)¶ Get size of value from factory NVS
This will search for the specified key in the Factory NVS partition, and return the size of the value associated with the key.
- Return
size of the value on success.
- Return
0 on failure.
- Parameters
[in] key: The key of the value to be read from factory NVS.
-
esp_err_t
esp_rmaker_factory_set(const char *key, void *value, size_t len)¶ Set a value in factory NVS
This will write the value for the specified key into factory NVS.
- Return
ESP_OK on success.
- Return
error on failure.
- Parameters
[in] key: The key for the value to be set in factory NVS.[in] value: Pointer to the value.[in] len: Length of the value.
Work Queue¶
Functions¶
-
esp_err_t
esp_rmaker_work_queue_init(void)¶ Initializes the Work Queue
This initializes the work queue, which is basically a mechanism to run tasks in the context of a dedicated thread. You can start queueing tasks after this, but they will get executed only after calling esp_rmaker_work_queue_start().
- Return
ESP_OK on success.
- Return
error in case of failure.
-
esp_err_t
esp_rmaker_work_queue_deinit(void)¶ De-initialize the Work Queue
This de-initializes the work queue. Note that the work queue needs to be stopped using esp_rmaker_work_queue_stop() before calling this.
- Return
ESP_OK on success.
- Return
error in case of failure.
-
esp_err_t
esp_rmaker_work_queue_start(void)¶ Start the Work Queue
This starts the Work Queue thread which then starts executing the tasks queued.
- Return
ESP_OK on success.
- Return
error in case of failure.
-
esp_err_t
esp_rmaker_work_queue_stop(void)¶ Stop the Work Queue
This stops a running Work Queue.
- Return
ESP_OK on success.
- Return
error in case of failure.
-
esp_err_t
esp_rmaker_work_queue_add_task(esp_rmaker_work_fn_t work_fn, void *priv_data)¶ Queue execution of a function in the Work Queue’s context
This API queues a work function for execution in the Work Queue Task’s context.
- Return
ESP_OK on success.
- Return
error in case of failure.
- Parameters
[in] work_fn: The Work function to be queued.[in] priv_data: Private data to be passed to the work function.
Common Events¶
Header File¶
Enumerations¶
-
enum
esp_rmaker_common_event_t¶ Values:
-
RMAKER_EVENT_REBOOT¶ Node reboot has been triggered. The associated event data is the time in seconds (type: uint8_t) after which the node will reboot. Note that this time may not be accurate as the events are received asynchronously.
-
RMAKER_EVENT_WIFI_RESET¶ Wi-Fi credentials reset. Triggered after calling esp_rmaker_wifi_reset()
-
RMAKER_EVENT_FACTORY_RESET¶ Node reset to factory defaults. Triggered after calling esp_rmaker_factory_reset()
-
RMAKER_MQTT_EVENT_CONNECTED¶ Connected to MQTT Broker
-
RMAKER_MQTT_EVENT_DISCONNECTED¶ Disconnected from MQTT Broker
-
RMAKER_MQTT_EVENT_PUBLISHED¶ MQTT message published successfully. Event data will contain the message ID (integer) of published message.
-
RMAKER_EVENT_TZ_POSIX_CHANGED¶ POSIX Timezone Changed. Associated data would be NULL terminated POSIX Timezone Eg. “PST8PDT,M3.2.0,M11.1.0”
-
RMAKER_EVENT_TZ_CHANGED¶ Timezone Changed. Associated data would be NULL terminated Timezone. Eg. “America/Los_Angeles” Note that whenever this event is received, the RMAKER_EVENT_TZ_POSIX_CHANGED event will also be received, but not necessarily vice versa.
-
RMAKER_MQTT_EVENT_MSG_DELETED¶ MQTT message deleted from the outbox if the message couldn’t have been sent and acknowledged. Event data will contain the message ID (integer) of deleted message. Valid only if CONFIG_MQTT_REPORT_DELETED_MESSAGES is enabled.
-