main.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "freertos/FreeRTOS.h"
  2. #include "freertos/task.h"
  3. #include "esp_log.h"
  4. #include "config.h"
  5. #include "wifi.h"
  6. #include "mqtt.h"
  7. #include "readTemps.h"
  8. // Chip info:
  9. // This is esp32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 1, 4MB external flash
  10. void app_main(void)
  11. {
  12. ESP_LOGI("MAIN", "IRTransceiver ESP32. Core:%d",xPortGetCoreID());
  13. // Wait for stable environment
  14. vTaskDelay(2000.0 / portTICK_PERIOD_MS);
  15. #ifdef ENABLE_DS18B20
  16. initTempReadings();
  17. #endif
  18. #ifdef WIFI_ENABLED
  19. initWifi(); // Init WIFI
  20. #endif
  21. #ifdef MQTT_ENABLED
  22. mqtt_init();
  23. #endif
  24. TickType_t vLastWakeTime = xTaskGetTickCount();
  25. // Do an initial delay to make the different tasks to work out of sync to each other (not send all data at same time)
  26. vTaskDelayUntil( &vLastWakeTime, 30000 / portTICK_PERIOD_MS );
  27. // ---------------- MAIN WHILE -------------------
  28. while(1) {
  29. vTaskDelayUntil( &vLastWakeTime, 60000 / portTICK_PERIOD_MS );
  30. }
  31. vTaskDelete(NULL);
  32. }