Skip to content

API Reference (Telemetry-Relevant Subset)

This section summarizes the parts of the Coldwave and flake::Service APIs that are most relevant for telemetry.

Coldwave C API (excerpt)

All functions are declared in <coldwave/coldwave.h>.

FunctionDescription
int coldwave_init(const coldwave_init_t* init, const char* srv_uuid, flake::Service** srv)Initialize Coldwave. Fills *srv with a flake::Service instance on success (E_OK).
int coldwave_register_service(const char* srv_uuid, flake::Service** srv)Register an additional service instance (secondary object).
int coldwave_backend_attach(const char* cbe_fqdn, unsigned char* cbe_ca_cert, unsigned cbe_ca_cert_len)Attach to the Coldwave Backend (CBE) using the given FQDN and CA certificate.
int coldwave_backend_detach(void)Detach from the backend.
bool coldwave_backend_attached(void)Returns true if the backend is currently attached.
unsigned coldwave_get_remaining_budget(void)Remaining monthly data budget in bytes for the client; returns 0 if not initialized or not a client node.
void coldwave_reset_budget(void)Reset the monthly budget manager.
int coldwave_suspend(void) / int coldwave_resume(void)Suspend / resume Coldwave activity (e.g. for low-power modes).

Relevant fields in coldwave_init_t / coldwave_client_options_t:

FieldTypeDescription
node_typecoldwave_node_tNode role (cwClient or cwRouter). Telemetry devices typically use cwClient.
app_semverconst char*Firmware SemVer string.
device_idconst char*Unique device ID (IMEI or similar).
product_idconst char*4-character product ID.
hw_idconst char*Hardware identifier (SoC family, board variant).
opt.client.monthly_data_limit_bytesunsignedMonthly data budget in bytes.
opt.client.remaining_data_budget_bytesunsignedRemaining monthly budget at startup (optional).
opt.client.dasired_sync_interval_sintTarget sync interval in seconds.

flake::Service (excerpt)

All methods are declared in <flake/Service.h>.

Core methods for telemetry:

MemberDescription
template<uint32_t PropTag, typename T> int set(T value)Set the value of a property identified by PropTag. Returns E_OK on success, E_REFUSED if the value cannot be converted or if called from within a forbidden callback context.
template<uint32_t PropTag> PropType<PropTag> get(PropType<PropTag> defval = ...)Get the value of a property, or defval if not available.
template<uint32_t PropTag> int on(PropCallback<PropTag> cb)Register a property callback for a tag (called when the property is written by the backend).
template<uint32_t PropTag> int on(PropCallback<PropTag & ~TAG_ACTIONABLE> cb, PropType<PropTag> min, PropType<PropTag> max)Register a property callback with range validation for non-actionable properties.
template<uint32_t PropTag> int onRead(PropCallBackStreamRead cb)Register stream read callback for a stream property.
template<uint32_t PropTag> int onWrite(PropCallBackStreamWrite cb)Register stream write callback for a stream property.
template<uint32_t PropTag> int onOpenClose(PropCallBackStreamOpenClose cb)Register stream open/close callback.
int openProperty(const uint32_t propTag, Stream** stream)Open a stream for the given property tag (for large or streaming telemetry).
int sync(int timeout_ms = FLAKE_DEFAULT_TIMEOUT_MS)Exchange pending property updates and messages with the backend.
void defer() / int syncDeferred(unsigned timeout_ms, bool block) / bool hasDeferred()Low-level control of deferred sync batches.
unsigned pendingBytes()Get the number of pending bytes waiting to be sent.
void reset()Reset the service state.