satitm-walkway-iot-firmware/src/main.cpp

52 lines
1.4 KiB
C++
Raw Permalink Normal View History

2024-10-08 08:27:01 +00:00
#include <main.hpp>
ESPMegaPRO espmega = ESPMegaPRO();
void setup()
{
// Initialize the ESPMegaPRO
ESP_LOGV("OS", "Initializing ESPMegaPRO");
espmega.begin();
espmega.inputs.preloadInputBuffer();
// Initialize IoT Modules
ESP_LOGV("OS", "Initializing IoT Modules");
espmega.setTimezone("ICT-7");
espmega.enableIotModule();
// Setup Ethernet
ESP_LOGV("OS", "Initializing Ethernet");
ETH.begin();
ESP_LOGD("OS", "Binding Ethernet Interface");
espmega.iot->bindEthernetInterface(&ETH);
// Connect to Network
2024-10-11 15:09:14 +00:00
ESP_LOGV("OS", "Loading Network Config");
2024-10-08 08:27:01 +00:00
espmega.iot->loadNetworkConfig();
2024-10-11 15:09:14 +00:00
ESP_LOGV("OS", "Connecting to Network");
2024-10-08 08:27:01 +00:00
espmega.iot->connectNetwork();
// Connect to the MQTT Broker
ESP_LOGV("OS", "Connecting to MQTT Broker");
espmega.iot->loadMqttConfig();
vTaskDelay(3000 / portTICK_PERIOD_MS); // Wait for the network to stabilize
espmega.iot->connectToMqtt();
// Enable Web Server
ESP_LOGV("OS", "Enabling Web Server");
espmega.enableWebServer(80);
// Register all cards with iot
ESP_LOGV("OS", "Registering Cards with IoT");
espmega.iot->registerCard(0);
espmega.iot->registerCard(1);
2024-10-13 16:34:03 +00:00
// Enable Display
espmega.enableInternalDisplay(&Serial);
espmega.display->bindInputCard(&espmega.inputs);
espmega.display->bindOutputCard(&espmega.outputs);
2024-10-08 08:27:01 +00:00
}
void loop()
{
espmega.loop();
}
2024-10-08 16:24:02 +00:00
void input_callback(uint8_t pin, uint8_t state)
{
2024-10-11 15:09:14 +00:00
if(state!=1) return;
2024-10-08 16:28:31 +00:00
espmega.outputs.toggleState(pin);
2024-10-08 16:24:02 +00:00
}