28 lines
580 B
C
28 lines
580 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";
|
|
|
|
void loop(esp_mqtt_client_handle_t mqtt_client)
|
|
{
|
|
ESP_LOGI(TAG, "Loop running...");
|
|
mqtt_publish(mqtt_client, "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);
|
|
}
|
|
}
|