Telemetry & MQTT connection
After iotmer_init returns ESP_OK (and after any OTA reboot completes), the application performs the MQTT connection phase.
Minimal sequence
iotmer_config_t cfg = IOTMER_CONFIG_DEFAULT();
iotmer_client_t client;
ESP_ERROR_CHECK(iotmer_init(&client, &cfg));
ESP_ERROR_CHECK(iotmer_connect(&client));
while (!client.connected) {
vTaskDelay(pdMS_TO_TICKS(100));
}
ESP_ERROR_CHECK(iotmer_subscribe_commands(&client, on_command, NULL));
while (1) {
(void)iotmer_telemetry_publish(&client, "{\"temp\": 22.5}");
vTaskDelay(pdMS_TO_TICKS(5000));
}
MQTT client identity
The SDK sets:
client_id=mqtt_usernamewhen non-empty (broker identity; topic paths use{workspace_slug}/{device_key}separately).- Username and password from NVS / last provision response.
If the broker rejects the connection, update stored credentials (HTTPS provision or console credential rotation followed by provision). On repeated CONNACK auth failures the SDK applies exponential backoff between reconnect attempts to limit broker flapping / rate limiting impact.
Publishing
iotmer_telemetry_publish(client, json)— QoS 1, non-retained.iotmer_state_publish(client, json)— same semantics for device state.
Topic layout must match the console ACL — see MQTT topics & console ACL.