main.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #include "rxTimer.h"
  9. #include "receiver.h"
  10. // Chip info:
  11. // This is esp32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 1, 4MB external flash
  12. void app_main(void)
  13. {
  14. ESP_LOGI("MAIN", "IRTransceiver ESP32. Core:%d",xPortGetCoreID());
  15. // Wait for stable environment
  16. vTaskDelay(1000.0 / portTICK_PERIOD_MS);
  17. rxTimerInit(); // First we start the Timer (which samples Rx and handles uS-delays)
  18. #ifdef ENABLE_DS18B20
  19. initTempReadings();
  20. #endif
  21. #ifdef WIFI_ENABLED
  22. initWifi(); // Init WIFI
  23. #endif
  24. #ifdef MQTT_ENABLED
  25. mqtt_init();
  26. #endif
  27. initReceiver(); // Init receiver-task
  28. TickType_t vLastWakeTime = xTaskGetTickCount();
  29. // Do an initial delay to make the different tasks to work out of sync to each other (not send all data at same time)
  30. vTaskDelayUntil( &vLastWakeTime, 30000 / portTICK_PERIOD_MS );
  31. // ---------------- MAIN WHILE -------------------
  32. while(1) {
  33. vTaskDelayUntil( &vLastWakeTime, 60000 / portTICK_PERIOD_MS );
  34. }
  35. vTaskDelete(NULL);
  36. }