Skip to content

Attaching to the Coldwave Backend

Backend FQDN and (optional) CA certificate are part of coldwave_init_t::backend and have already been consumed by coldwave_init(). To trigger the actual connection, call:

cpp
int rc = coldwave_backend_attach();
if (rc != CW_OK) {
    // CW_ERR_NOT_INITIALIZED   – coldwave_init() did not succeed
    // CW_ERR_ALREADY_ATTACHED  – attach already pending / online
    // CW_ERR_NO_BACKEND        – no backend.fqdn was provided at init
    // handle attach error
}

// The call is non-blocking; the connection is established asynchronously.
// Wait until the backend connection is online if you need it before proceeding:
while (!coldwave_backend_attached()) {
    osDelay(100);
}

Notes:

  • A non-null backend.ca_cert enables TLS/DTLS; passing nullptr falls back to unencrypted UDP (PTP only).
  • coldwave_backend_attached() returns true once the device is logically connected to the backend.
  • Tear the connection down with coldwave_backend_detach(); the flake CoreWorker stays alive and coldwave_backend_attach() can be called again without going through coldwave_init() once more.

After this point, service->sync() can exchange property updates with the backend.