/* Hello World Example This example code is in the Public Domain (or CC0 licensed, at your option.) Unless required by applicable law or agreed to in writing, this software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #include #include "sdkconfig.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_system.h" #include "esp_spi_flash.h" #include "nvs_flash.h" #include "esp_err.h" #include "esp_log.h" #include "app_task_hello.h" #include "app_task_display.h" // #include "app_task_wifi.h" // #include "app_task_mqtt.h" // #include "app_task_sensors.h" #include "app_main.h" #include "shell_port.h" // #include "msg_queue.h" static app_main_handle_t sg_app_main_handle = { 0 }; static void _init_esp() { // Initialize NVS esp_err_t ret = nvs_flash_init(); if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { ESP_ERROR_CHECK(nvs_flash_erase()); ret = nvs_flash_init(); } ESP_ERROR_CHECK(ret); } void app_main(void) { // app_task_wifi_t wifi_info = {0}; // msg_queue_init(); printf("Hello world!\n"); vTaskDelay(10); _init_esp(); app_task_display_start(); // app_hello_task_start(); // app_task_wifi_start(); // app_task_mqtt_start(); // app_task_sensors_start(); userShellInit(); /* Print chip information */ esp_chip_info_t chip_info; esp_chip_info(&chip_info); printf("This is %s chip with %d CPU core(s), WiFi%s%s, ", CONFIG_IDF_TARGET, chip_info.cores, (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "", (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : ""); printf("silicon revision %d, ", chip_info.revision); printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024), (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external"); printf("Minimum free heap size: %d bytes\n", esp_get_minimum_free_heap_size()); // uint8_t ret = msg_queue_create("mqtt_task"); // printf("ret = %d\r\n", ret); // msg_data_t msg_data = {0}; for (int i = 10;;) { // printf("Restarting in %d seconds...\n", i); // app_task_wifi_get_info(&wifi_info); // sg_app_main_handle.have_network = wifi_info.is_wifi_conneted; // FillTest(&dev, CONFIG_WIDTH, CONFIG_HEIGHT); vTaskDelay(5000 / portTICK_PERIOD_MS); } printf("Restarting now.\n"); fflush(stdout); esp_restart(); } uint8_t app_main_handle_get_nework_state() { return sg_app_main_handle.have_network; } static void _show_build_time(int argc, char** argv) { printf("build at %s %s\n", __DATE__, __TIME__); } SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), show_build_time, _show_build_time, show the build time); static void _reboot(int argc, char** argv) { esp_restart(); } SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), reboot, _reboot, reboot system);