123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #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"
- // Chip info:
- // This is esp32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 1, 4MB external flash
- void getChipInfo(void) {
- esp_chip_info_t chip_info;
- esp_chip_info(&chip_info);
- ESP_LOGI("MAIN", "Model: %s", chip_info.model == CHIP_ESP32 ? "ESP32" : "Unknown");
- ESP_LOGI("MAIN", "Features: WiFi%s%s, %d cores",
- (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
- (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "",
- chip_info.cores);
- ESP_LOGI("MAIN", "Revision: %d", chip_info.revision);
- }
- void app_main(void)
- {
- ESP_LOGI("MAIN", "GarageTransceiver ESP32. Core:%d",xPortGetCoreID());
- getChipInfo();
- // Wait for stable environment
- vTaskDelay(2000.0 / portTICK_PERIOD_MS);
- #ifdef RX_TIMER_ENABLED
- 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
- 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, 60000 / portTICK_PERIOD_MS );
- // Do periodic work here, if needed
-
- }
- vTaskDelete(NULL);
- }
|