esp32/domestic-climate-monitor/main/main.c

29 lines
580 B
C
Raw Normal View History

2026-01-13 18:30:18 +00:00
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
#include "freertos/task.h"
#include "nvs_flash.h"
2026-02-07 18:22:45 +00:00
#include "mqtt.h"
#include "mqtt_client.h"
2026-01-13 18:30:18 +00:00
#include "wifi.h"
static const char *TAG = "main";
2026-02-07 18:22:45 +00:00
void loop(esp_mqtt_client_handle_t mqtt_client)
{
2026-01-13 18:30:18 +00:00
ESP_LOGI(TAG, "Loop running...");
2026-02-07 18:22:45 +00:00
mqtt_publish(mqtt_client, "Test message");
2026-01-13 18:30:18 +00:00
vTaskDelay(pdMS_TO_TICKS(1000));
}
2026-02-07 18:22:45 +00:00
void app_main(void)
{
ESP_ERROR_CHECK(nvs_flash_init());
wifi_connect();
esp_mqtt_client_handle_t mqtt_client = mqtt_connect();
2026-01-13 18:30:18 +00:00
while (1) {
2026-02-07 18:22:45 +00:00
loop(mqtt_client);
2026-01-13 18:30:18 +00:00
}
}