Merge branch 'master-v4.3' of https://github.com/wizmo2/squeezelite-esp32 into led_visu-v4.3

This commit is contained in:
Wizmo2
2023-04-16 10:44:57 -04:00
3123 changed files with 468750 additions and 15292 deletions

View File

@@ -602,8 +602,9 @@ static int is_valid_gpio_number(int gpio, const char * name, FILE *f, bool manda
}
return 0;
}
#ifdef CONFIG_CSPOT_SINK
static int do_cspot_config(int argc, char **argv){
char * name = NULL;
int nerrors = arg_parse_msg(argc, argv,(struct arg_hdr **)&cspot_args);
if (nerrors != 0) {
return 1;
@@ -620,32 +621,37 @@ static int do_cspot_config(int argc, char **argv){
cJSON * cspot_config = config_alloc_get_cjson("cspot_config");
if(!cspot_config){
nerrors++;
fprintf(f,"error: Unable to get cspot config.\n");
fprintf(f,"error: Unable to get default cspot config.\n");
}
else {
cjson_update_string(&cspot_config,cspot_args.deviceName->hdr.longopts,cspot_args.deviceName->count>0?cspot_args.deviceName->sval[0]:NULL);
// cjson_update_number(&cspot_config,cspot_args.volume->hdr.longopts,cspot_args.volume->count>0?cspot_args.volume->ival[0]:0);
cjson_update_number(&cspot_config,cspot_args.bitrate->hdr.longopts,cspot_args.bitrate->count>0?cspot_args.bitrate->ival[0]:0);
if(cspot_args.deviceName->count>0){
cjson_update_string(&cspot_config,cspot_args.deviceName->hdr.longopts,cspot_args.deviceName->sval[0]);
}
if(cspot_args.bitrate->count>0){
cjson_update_number(&cspot_config,cspot_args.bitrate->hdr.longopts,cspot_args.bitrate->ival[0]);
}
if(!nerrors ){
fprintf(f,"Storing cspot parameters.\n");
nerrors+=(config_set_cjson_str("cspot_config",cspot_config) !=ESP_OK);
nerrors+=(config_set_cjson_str_and_free("cspot_config",cspot_config) !=ESP_OK);
}
if(nerrors==0){
fprintf(f,"Device name changed to %s\n",name);
if(nerrors==0 ){
if(cspot_args.deviceName->count>0){
fprintf(f,"Device name changed to %s\n",cspot_args.deviceName->sval[0]);
}
if(cspot_args.bitrate->count>0){
fprintf(f,"Bitrate changed to %u\n",cspot_args.bitrate->ival[0]);
}
}
if(!nerrors ){
fprintf(f,"Done.\n");
}
FREE_AND_NULL(name);
fflush (f);
cmd_send_messaging(argv[0],nerrors>0?MESSAGING_ERROR:MESSAGING_INFO,"%s", buf);
fclose(f);
FREE_AND_NULL(buf);
return nerrors;
}
#endif
static int do_ledvu_cmd(int argc, char **argv){
ledvu_struct_t ledvu={ .type = "WS2812", .gpio = -1, .length = 0};
@@ -800,6 +806,7 @@ cJSON * known_model_cb(){
}
return values;
}
#ifdef CONFIG_CSPOT_SINK
cJSON * cspot_cb(){
cJSON * values = cJSON_CreateObject();
if(!values){
@@ -819,13 +826,11 @@ cJSON * cspot_cb(){
if(cspot_values){
cJSON_AddNumberToObject(values,cspot_args.bitrate->hdr.longopts,cJSON_GetNumberValue(cspot_values));
}
// cspot_values = cJSON_GetObjectItem(cspot_config,cspot_args.volume->hdr.longopts);
// if(cspot_values){
// cJSON_AddNumberToObject(values,cspot_args.volume->hdr.longopts,cJSON_GetNumberValue(cspot_values));
// }
cJSON_Delete(cspot_config);
return values;
}
#endif
cJSON * i2s_cb(){
cJSON * values = cJSON_CreateObject();
@@ -1247,7 +1252,7 @@ static void register_known_templates_config(){
cmd_to_json_with_cb(&cmd,&known_model_cb);
ESP_ERROR_CHECK(esp_console_cmd_register(&cmd));
}
#ifdef CONFIG_CSPOT_SINK
static void register_cspot_config(){
cspot_args.deviceName = arg_str1(NULL,"deviceName","","Device Name");
cspot_args.bitrate = arg_int1(NULL,"bitrate","96|160|320","Streaming Bitrate (kbps)");
@@ -1263,6 +1268,7 @@ static void register_cspot_config(){
cmd_to_json_with_cb(&cmd,&cspot_cb);
ESP_ERROR_CHECK(esp_console_cmd_register(&cmd));
}
#endif
static void register_i2s_config(void){
i2s_args.model_name = arg_str1(NULL,"model_name",STR_OR_BLANK(get_dac_list()),"DAC Model Name");
i2s_args.clear = arg_lit0(NULL, "clear", "Clear configuration");
@@ -1422,8 +1428,11 @@ static void register_squeezelite_config(void){
void register_config_cmd(void){
if(!is_dac_config_locked()){
register_known_templates_config();
}
#ifdef CONFIG_CSPOT_SINK
register_cspot_config();
#endif
register_audio_config();
// register_squeezelite_config();
register_bt_source_config();