Telemetry & MQTT
Run after iotmer_init() returns ESP_OK (and after any OTA reboot).
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) {
iotmer_telemetry_publish(&client, "{\"temp\":22.5}");
vTaskDelay(pdMS_TO_TICKS(5000));
}
Client identity
| Field | Value |
|---|---|
client_id | mqtt_username when set |
| Username / password | From NVS / last provision |
Topic paths use {workspace_slug}/{device_key}/… separately from client_id.
On CONNACK auth failure (rc 4/5), the SDK applies exponential backoff to avoid broker rate limits. Re-provision if credentials are stale.
Publish helpers
| Function | Topic | QoS | Retain |
|---|---|---|---|
iotmer_telemetry_publish() | …/telemetry | 1 | No |
iotmer_state_publish() | …/state | 1 | Yes |
iotmer_presence_publish() | …/presence | 1 | Yes |
Topic layout: MQTT topics & ACL. On-device event history (event.get) is separate from live …/event: Event logging.