File espos_sk_delta.h¶
FileList > espos_sk > include > espos_sk_delta.h
Go to the source code of this file
#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include "esp_err.h"
Classes¶
| Type | Name |
|---|---|
| struct | espos_sk_delta_cfg_t |
| struct | espos_sk_delta_stats_t |
Public Types¶
| Type | Name |
|---|---|
| typedef struct espos_sk_delta | espos_sk_delta_t |
Public Functions¶
| Type | Name |
|---|---|
| espos_sk_delta_t * | espos_sk_delta_create (const espos_sk_delta_cfg_t * cfg) |
| void | espos_sk_delta_destroy (espos_sk_delta_t * d) |
| void | espos_sk_delta_flush (espos_sk_delta_t * d, uint32_t now_ms) Force the pending batch into a message now (e.g. |
| uint32_t | espos_sk_delta_next_due_ms (const espos_sk_delta_t * d, uint32_t now_ms, bool connected) ms until something is due (batch window / drain gap); UINT32_MAX if idle. |
| esp_err_t | espos_sk_delta_publish (espos_sk_delta_t * d, const char * path, const char * value_json, uint32_t now_ms) value_json is a complete JSON value (number, "string", true, {...}). |
| void | espos_sk_delta_requeue (espos_sk_delta_t * d, char * msg) Put a message back at the head (send failed); takes ownership. |
| void | espos_sk_delta_set_clock (espos_sk_delta_t * d, int64_t(*)(void *arg) wall_ms, void * arg) Give the engine a wall clock, and every message it hands out carries the time its values were actually MEASURED — updates[].timestamp , ISO 8601 UTC with milliseconds. |
| void | espos_sk_delta_set_label (espos_sk_delta_t * d, const char * label) |
| void | espos_sk_delta_set_timing (espos_sk_delta_t * d, uint32_t batch_ms, uint32_t drain_per_s) Change batching window / drain rate on a live engine. |
| void | espos_sk_delta_stats (const espos_sk_delta_t * d, espos_sk_delta_stats_t * out) |
| char * | espos_sk_delta_take (espos_sk_delta_t * d, uint32_t now_ms, bool connected) Sender side. |
| int | espos_sk_json_number (char * buf, size_t size, double v) |
| int | espos_sk_json_string (char * buf, size_t size, const char * s) |
Macros¶
| Type | Name |
|---|---|
| define | ESPOS_SK_PATH_MAX 96 |
| define | ESPOS_SK_PENDING_MAX 32 |
| define | ESPOS_SK_VALUE_MAX 256 |
Public Types Documentation¶
typedef espos_sk_delta_t¶
Public Functions Documentation¶
function espos_sk_delta_create¶
function espos_sk_delta_destroy¶
function espos_sk_delta_flush¶
Force the pending batch into a message now (e.g.
before disconnect).
function espos_sk_delta_next_due_ms¶
ms until something is due (batch window / drain gap); UINT32_MAX if idle.
function espos_sk_delta_publish¶
value_json is a complete JSON value (number, "string", true, {...}).
esp_err_t espos_sk_delta_publish (
espos_sk_delta_t * d,
const char * path,
const char * value_json,
uint32_t now_ms
)
function espos_sk_delta_requeue¶
Put a message back at the head (send failed); takes ownership.
function espos_sk_delta_set_clock¶
Give the engine a wall clock, and every message it hands out carries the time its values were actually MEASURED — updates[].timestamp , ISO 8601 UTC with milliseconds.
This matters most exactly where it is hardest: a message built while the server was unreachable sits in the ring for minutes or hours, and without a timestamp the server stamps it on arrival, so an outage's worth of data lands as one burst at reconnect. The engine records the monotonic instant each message was built and, at take() time, converts it with the clock's current offset — wall_now - (mono_now - batch_ms). That is correct even when the clock was set AFTER the message was buffered, which is the normal case for a device that boots without a network.
wall_ms returns unix milliseconds, or 0 while the device does not know the time; 0 means no timestamp is emitted at all, and the server falls back to stamping on arrival as it did before. Pass NULL to turn timestamps off. arg is handed back untouched. Called on the owner's task; the callback runs under whatever lock the owner holds around take(), so it must not block — espos_time_now_ms_or_zero is a lock-protected snapshot copy and is the intended argument.
function espos_sk_delta_set_label¶
function espos_sk_delta_set_timing¶
Change batching window / drain rate on a live engine.
function espos_sk_delta_stats¶
function espos_sk_delta_take¶
Sender side.
Returns a malloc'ed message to transmit now, or NULL. connected=false only batches into the ring.
function espos_sk_json_number¶
function espos_sk_json_string¶
Macro Definition Documentation¶
define ESPOS_SK_PATH_MAX¶
define ESPOS_SK_PENDING_MAX¶
define ESPOS_SK_VALUE_MAX¶
The documentation for this class was generated from the following file espos_sk/include/espos_sk_delta.h