#include #include #include "application_name.h" #include "esp_log.h" #include "esp_console.h" #include "../cmd_system.h" #include "argtable3/argtable3.h" #include "freertos/FreeRTOS.h" #include "freertos/event_groups.h" #include "pthread.h" #include "platform_esp32.h" #include "Configurator.h" #include "esp_app_format.h" #include "tools.h" #include "messaging.h" extern esp_err_t process_recovery_ota(const char * bin_url, char * bin_buffer, uint32_t length); extern int squeezelite_main_start(); static const char * TAG = "squeezelite_cmd"; #define SQUEEZELITE_THREAD_STACK_SIZE (8*1024) #define ADDITIONAL_SQUEEZELITE_ARGS 5 const __attribute__((section(".rodata_desc"))) esp_app_desc_t esp_app_desc = { .magic_word = ESP_APP_DESC_MAGIC_WORD, .version = PROJECT_VER, .project_name = CONFIG_PROJECT_NAME, .idf_ver = IDF_VER, #ifdef CONFIG_BOOTLOADER_APP_SECURE_VERSION .secure_version = CONFIG_BOOTLOADER_APP_SECURE_VERSION, #else .secure_version = 0, #endif #ifdef CONFIG_APP_COMPILE_TIME_DATE .time = __TIME__, .date = __DATE__, #else .time = "", .date = "", #endif }; extern void register_audio_config(void); // extern void register_rotary_config(void); extern void register_nvs(); extern cJSON * get_gpio_list_handler(bool refresh); cJSON * get_gpio_list(bool refresh){ #if CONFIG_WITH_CONFIG_UI return get_gpio_list_handler(refresh); #else return cJSON_CreateArray(); #endif } void register_optional_cmd(void) { // #if CONFIG_WITH_CONFIG_UI // register_rotary_config(); // #endif register_audio_config(); // register_ledvu_config(); } /** Arguments used by 'squeezelite' function */ static struct { struct arg_str *parameters; struct arg_end *end; } squeezelite_args; static struct { int argc; char ** argv; } thread_parms ; static void squeezelite_thread(void *arg){ ESP_LOGV(TAG ,"Number of args received: %u",thread_parms.argc ); ESP_LOGV(TAG ,"Values:"); for(int i = 0;i 1 ? MESSAGING_ERROR : MESSAGING_WARNING,"squeezelite exited with error code %d\n", ret); if (ret <= 1) { int wait = 60; // wait_for_commit(); // TODO: Add support for the commented code cmd_send_messaging("cfg-audio-tmpl",MESSAGING_ERROR,"Rebooting in %d sec\n", wait); vTaskDelay( pdMS_TO_TICKS(wait * 1000)); esp_restart(); } else { cmd_send_messaging("cfg-audio-tmpl",MESSAGING_ERROR,"Correct command line and reboot\n"); vTaskSuspend(NULL); } ESP_LOGV(TAG, "Exited from squeezelite's main(). Freeing argv structure."); for(int i=0;i", "command line for squeezelite. -h for help, --defaults to launch with default values."); // squeezelite_args.end = arg_end(1); // const esp_console_cmd_t launch_squeezelite = { // .command = "squeezelite", // .help = "Starts squeezelite", // .hint = NULL, // .func = &launchsqueezelite, // .argtable = &squeezelite_args // }; // ESP_ERROR_CHECK( esp_console_cmd_register(&launch_squeezelite) ); // } esp_err_t start_ota(const char * bin_url, char * bin_buffer, uint32_t length) { if(!bin_url || strlen(bin_url)==0){ ESP_LOGE(TAG,"missing URL parameter. Unable to start OTA"); return ESP_ERR_INVALID_ARG; } ESP_LOGW(TAG, "Called to update the firmware from url: %s",bin_url); configurator_set_string(&sys_State_msg,sys_State_ota_url_tag,sys_state,bin_url); configurator_raise_state_changed(); if(!configurator_waitcommit()){ ESP_LOGW(TAG,"Unable to commit configuration. "); } ESP_LOGW(TAG, "Rebooting to recovery to complete the installation"); return guided_factory(); return ESP_OK; }