12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #include "freertos/FreeRTOS.h"
- #include "freertos/task.h"
- #include "esp_log.h"
- #include "config.h"
- #include "wifi.h"
- #include "send.h"
- #include "mqtt.h"
- #include "relay_control.h"
- #include "kWhCounter.h"
- #include "http_client.h"
- // Chip info:
- // This is esp32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 1, 4MB external flash
- void app_main(void)
- {
- ESP_LOGI("MAIN", "HomeEnergyMeter ESP32. Core:%d",xPortGetCoreID());
- #ifdef ENABLE_RELAY_OUTPUT
- relay_control_init();
- #endif
- #ifdef ENABLE_KWH_COUNTER
- kWhCounter_init();
- #endif
- #ifdef WIFI_ENABLED
- initWifi(); // Init WIFI
- #endif
- #ifdef MQTT_ENABLED
- mqtt_init();
- #endif
- #ifdef ENABLE_SEND
- initSend();
- #endif
- vTaskDelay(10000 / portTICK_PERIOD_MS);
- while(1) {
- sendHTTPMessage();
- vTaskDelay(30000 / portTICK_PERIOD_MS);
- }
- vTaskDelete(NULL);
- }
|