Files
project-vesper/vesper.ino

81 lines
2.4 KiB
C++

#include <WiFi.h>
#include <AsyncMqttClient.h>
#include <ArduinoJson.h>
#include <FS.h>
#include <SPIFFS.h>
#include <string>
#define DEV_ID "id-96638646"
struct melody_attributes {
std::string name; // Contains the name of each Melody saved
uint16_t id; // The (internal) ID of the selected melody
uint32_t duration; // Indicates the total Duration in Minutes
bool infinite_play; // Infinite Loop Indicator (If True the melody will loop forever or until stoped, with pauses of "interval duration in between loops")
uint16_t interval_duration; // Indicates the Duration of the Interval between finished loops, IF "inf" is true
uint8_t speed; // Indicates the Speed in 9 Steps. 1-9 (Steps can be adjusted in the bellEngine function)
};
melody_attributes melody;
volatile bool playing = false;
#include "functions.hpp"
#include "config.h" // Sustituir con datos de vuestra red
#include "MQTT.hpp"
#include "ESP32_Utils.hpp"
#include "ESP32_Utils_MQTT_Async.hpp"
#include "melody_handling.hpp"
TaskHandle_t myTaskHandle = NULL;
void setup()
{
// Initialize Serial Communication (for debuggin)
Serial.begin(115200);
delay(50);
// Initialize SPIFFS
if (!SPIFFS.begin(true)) { // 'true' means format SPIFFS if initialization fails
Serial.println("Failed to mount SPIFFS");
return;
}
Serial.println("SPIFFS mounted successfully");
delay(50);
// Initialize WiFi and MQTT
WiFi.onEvent(WiFiEvent);
InitMqtt();
ConnectWiFi_STA();
delay(1000);
xTaskCreatePinnedToCore(
bellEngine, // Task function
"bellEngine", // Task name
8192, // Stack size
NULL, // Task input parameters
1, // Task priority, be carefull when changing this
&myTaskHandle, // Task handle, add one if you want control over the task (resume or suspend the task)
1 // Core to run the task on
);
vTaskSuspend(myTaskHandle);
xTaskCreatePinnedToCore(
tempEngine, // Task function
"tempEngine", // Task name
8192, // Stack size
NULL, // Task input parameters
1, // Task priority, be carefull when changing this
NULL, // Task handle, add one if you want control over the task (resume or suspend the task)
1 // Core to run the task on
);
}
void loop()
{
}