#include #include #include "esp_log.h" #include "esp_console.h" #include "esp_pthread.h" #include "argtable3/argtable3.h" #include "freertos/FreeRTOS.h" #include "freertos/event_groups.h" #include "pthread.h" #include "platform_esp32.h" #include "platform_config.h" #include "esp_app_format.h" static const char * TAG = "squeezelite_cmd"; #define SQUEEZELITE_THREAD_STACK_SIZE (6*1024) const __attribute__((section(".rodata_desc"))) esp_app_desc_t esp_app_desc = { .magic_word = ESP_APP_DESC_MAGIC_WORD, .version = PROJECT_VER, .project_name = 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 int main(int argc, char **argv); static int launchsqueezelite(int argc, char **argv); pthread_t thread_squeezelite; pthread_t thread_squeezelite_runner; /** 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_runner_thread(){ ESP_LOGI(TAG ,"Calling squeezelite"); main(thread_parms.argc,thread_parms.argv); return NULL; } #define ADDITIONAL_SQUEEZELITE_ARGS 5 static void * squeezelite_thread(){ int * exit_code; static bool isRunning=false; if(isRunning) { ESP_LOGE(TAG,"Squeezelite already running. Exiting!"); return NULL; } isRunning=true; ESP_LOGV(TAG ,"Number of args received: %u",thread_parms.argc ); ESP_LOGV(TAG ,"Values:"); 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) ); }