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

29 lines
622 B
C

#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
#include "freertos/task.h"
#include "nvs_flash.h"
#include "mqtt.h"
#include "mqtt_client.h"
#include "wifi.h"
static const char *TAG = "main";
static char *topic = "test_topic";
void loop(esp_mqtt_client_handle_t mqtt_client)
{
ESP_LOGI(TAG, "Loop running...");
mqtt_publish(mqtt_client, topic, "Test message");
vTaskDelay(pdMS_TO_TICKS(1000));
}
void app_main(void)
{
ESP_ERROR_CHECK(nvs_flash_init());
wifi_connect();
esp_mqtt_client_handle_t mqtt_client = mqtt_connect();
while (1) {
loop(mqtt_client);
}
}