feat: publish/respond version string

This commit is contained in:
2026-05-17 14:36:45 +02:00
parent b9195a0dda
commit 3651dd9ef9
3 changed files with 17 additions and 6 deletions
+5 -2
View File
@@ -221,12 +221,15 @@ void app_main(void)
snprintf(broker_uri, sizeof(broker_uri), "mqtt://%s:%u", broker_host, broker_port);
// init MQTT
ESP_ERROR_CHECK(mqtt_publisher_init(sensor_id, broker_uri, s_evt));
const esp_partition_t *running = esp_ota_get_running_partition();
esp_app_desc_t app_desc;
const char *fw_version = (esp_ota_get_partition_description(running, &app_desc) == ESP_OK)
? app_desc.version : "unknown";
ESP_ERROR_CHECK(mqtt_publisher_init(sensor_id, broker_uri, s_evt, fw_version));
xEventGroupWaitBits(s_evt, MQTT_CONNECTED_BIT, pdFALSE, pdTRUE, portMAX_DELAY);
/* Confirm this firmware is healthy so the bootloader won't roll back */
esp_ota_img_states_t ota_state;
const esp_partition_t *running = esp_ota_get_running_partition();
if (esp_ota_get_state_partition(running, &ota_state) == ESP_OK &&
ota_state == ESP_OTA_IMG_PENDING_VERIFY) {
esp_ota_mark_app_valid_cancel_rollback();