#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" #include "toshiba_ir.h" // Chip info: // This is esp32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 1, 4MB external flash /* I (43709) TOSHIBA: MQTT: F20D03FC0170A300D2 I (43709) TOSHIBA: Data: F2 0D 03 FC 01 70 A3 00 D2 I (43709) TOSHIBA: Mode:1 Temp:24 Fan:4 I (43839) TOSHIBA: MQTT: F20D03FC0170A300D2 I (43839) TOSHIBA: Data: F2 0D 03 FC 01 70 A3 00 D2 I (43839) TOSHIBA: Mode:1 Temp:24 Fan:4 */ 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 vTaskDelay(1000 / portTICK_PERIOD_MS); initIrTransmit(); 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, 5000 / portTICK_PERIOD_MS ); ESP_LOGI("MAIN","Lets go..."); // ---------------- MAIN WHILE ------------------- while(1) { vTaskDelayUntil( &vLastWakeTime, 10000 / portTICK_PERIOD_MS ); // Start temp measuring task xTaskCreatePinnedToCore(readAndSendTemps, "readAndSendTemps", 1024*10, NULL, 2, NULL,1); /*ESP_LOGI("MAIN","Send a test-IR Tx Data"); const uint8_t data[kToshibaNumberOfBytes] = { 0xF2, 0x0D, 0x03, 0xFC, 0x01, 0x30, 0xA3, 0x00, 0x92 }; // F2 0D 03 FC 01 30 A3 00 92 xQueueSend( toshibaTxQueue, &(data[0]), 0 );*/ } vTaskDelete(NULL); }