#include "globals.h"
#include <WiFi.h>
#include <PubSubClient.h>

// Prototypes
void setupWiFi();
void reconnectMQTT();
void setupWebServer();
void setupOTA();
void taskCore1(void *pvParameters);
void taskCore2(void *pvParameters);
String createJsonMessage2(int sensorValue);

void setup() {
  Serial.begin(115200);

  // Configura o Wi-Fi e MQTT
  setupWiFi();
  setupMQTT();
  reconnectMQTT();

  // Inicializa o servidor web e OTA
  setupWebServer();
  setupOTA();

  // Cria as tarefas para os núcleos
  xTaskCreatePinnedToCore(
    taskCore1,
    "TaskCore1",
    10000,
    NULL,
    1,
    NULL,
    0);

  xTaskCreatePinnedToCore(
    taskCore2,
    "TaskCore2",
    10000,
    NULL,
    1,
    NULL,
    1);
}

void loop() {
  // A função loop ficará vazia, pois as tarefas são executadas nos núcleos
}