main.c 1.3 KB

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