#include 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(Ð); // Connect to Network ESP_LOGV("OS", "Loading Network Config"); espmega.iot->loadNetworkConfig(); ESP_LOGV("OS", "Connecting to Network"); 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); // Enable Display espmega.enableInternalDisplay(&Serial); espmega.display->bindInputCard(&espmega.inputs); espmega.display->bindOutputCard(&espmega.outputs); } void loop() { espmega.loop(); } void input_callback(uint8_t pin, uint8_t state) { if(state!=1) return; espmega.outputs.toggleState(pin); }