12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- #include "freertos/FreeRTOS.h"
- #include "freertos/task.h"
- #include "esp_log.h"
- #include "config.h"
- #include "wifi.h"
- #include "mqtt.h"
- #include "readTemps.h"
- #include "rxTimer.h"
- #include "receiver.h"
- #include "ir_transmit.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", "IRTransceiver ESP32. Core:%d",xPortGetCoreID());
- // Wait for stable environment
- vTaskDelay(1000.0 / portTICK_PERIOD_MS);
- #ifdef RX_TIMER
- rxTimerInit(); // First we start the Timer (which samples Rx and handles uS-delays)
- #endif
- #ifdef ENABLE_DS18B20
- initTempReadings();
- #endif
- #ifdef WIFI_ENABLED
- initWifi(); // Init WIFI
- #endif
- #ifdef MQTT_ENABLED
- mqtt_init();
- #endif
- #ifdef IR_RECEIVER
- initReceiver(); // Init receiver-task
- #endif
- TickType_t vLastWakeTime = xTaskGetTickCount();
- // Do an initial delay to make the different tasks to work out of sync to each other (not send all data at same time)
- vTaskDelayUntil( &vLastWakeTime, 30000 / portTICK_PERIOD_MS );
- // ---------------- MAIN WHILE -------------------
- while(1) {
- vTaskDelayUntil( &vLastWakeTime, 1000 / portTICK_PERIOD_MS );
- sendToshibaIRData();
- }
- vTaskDelete(NULL);
- }
|