Skip to content

Attaching to the Coldwave Backend

Once Coldwave is initialized and your connectivity stack is up, attach to the backend:

cpp
// FQDN and CA certificate of your Coldwave Backend
const char* cbe_fqdn     = COLDWAVE_BACKEND_URL;
unsigned char* ca_cert   = nullptr;          // may be nullptr for some PTP setups
unsigned       ca_len    = 0;                // depends on your transport

int rc = coldwave_backend_attach(cbe_fqdn, ca_cert, ca_len);
if (rc != E_OK) {
    // handle attach error
}

// Wait until the backend connection is established
while (!coldwave_backend_attached()) {
    osDelay(100);
}

Notes:

  • For network (CW_NETWORK) sessions, cbe_ca_cert is mandatory.
  • For point-to-point (CW_PTP) transports, cbe_ca_cert may be nullptr; in that case an unencrypted UDP connection is used, or DTLS if a certificate is supplied.
  • coldwave_backend_attached() returns true once the device is logically connected to the backend.

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