Skip to main content

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

FieldValue
client_idmqtt_username when set
Username / passwordFrom 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

FunctionTopicQoSRetain
iotmer_telemetry_publish()…/telemetry1No
iotmer_state_publish()…/state1Yes
iotmer_presence_publish()…/presence1Yes

Topic layout: MQTT topics & ACL. On-device event history (event.get) is separate from live …/event: Event logging.