mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-13 15:07:01 +03:00
Fix spotify configuration UI- release
This commit is contained in:
@@ -83,25 +83,28 @@ static void bt_app_task_handler(void *arg)
|
||||
|
||||
esp_bt_controller_mem_release(ESP_BT_MODE_BLE);
|
||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||
|
||||
if ((err = esp_bt_controller_init(&bt_cfg)) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s initialize controller failed: %s\n", __func__, esp_err_to_name(err));
|
||||
goto exit;
|
||||
}
|
||||
if(esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_IDLE ){
|
||||
|
||||
|
||||
if ((err = esp_bt_controller_init(&bt_cfg)) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s initialize controller failed: %s\n", __func__, esp_err_to_name(err));
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if ((err = esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT)) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(err));
|
||||
goto exit;
|
||||
}
|
||||
if ((err = esp_bt_controller_enable(ESP_BT_MODE_BTDM)) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(err));
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if ((err = esp_bluedroid_init()) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s initialize bluedroid failed: %s\n", __func__, esp_err_to_name(err));
|
||||
goto exit;
|
||||
}
|
||||
if ((err = esp_bluedroid_init()) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s initialize bluedroid failed: %s\n", __func__, esp_err_to_name(err));
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if ((err = esp_bluedroid_enable()) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s enable bluedroid failed: %s\n", __func__, esp_err_to_name(err));
|
||||
goto exit;
|
||||
if ((err = esp_bluedroid_enable()) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s enable bluedroid failed: %s\n", __func__, esp_err_to_name(err));
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* Bluetooth device name, connection mode and profile set up */
|
||||
|
||||
@@ -634,7 +634,7 @@ cJSON * config_alloc_get_cjson(const char *key){
|
||||
}
|
||||
return conf_json;
|
||||
}
|
||||
esp_err_t config_set_cjson_str(const char *key, cJSON *value){
|
||||
esp_err_t config_set_cjson_str_and_free(const char *key, cJSON *value){
|
||||
char * value_str = cJSON_PrintUnformatted(value);
|
||||
if(value_str==NULL){
|
||||
ESP_LOGE(TAG, "Unable to print cJSON for key [%s]", key);
|
||||
|
||||
@@ -53,7 +53,7 @@ void config_init();
|
||||
void * config_alloc_get_default(nvs_type_t type, const char *key, void * default_value, size_t blob_size);
|
||||
void * config_alloc_get_str(const char *key, char *lead, char *fallback);
|
||||
cJSON * config_alloc_get_cjson(const char *key);
|
||||
esp_err_t config_set_cjson_str(const char *key, cJSON *value);
|
||||
esp_err_t config_set_cjson_str_and_free(const char *key, cJSON *value);
|
||||
void config_get_uint16t_from_str(const char *key, uint16_t *value, uint16_t default_value);
|
||||
void config_delete_key(const char *key);
|
||||
void config_set_default(nvs_type_t type, const char *key, void * default_value, size_t blob_size);
|
||||
|
||||
@@ -593,7 +593,6 @@ static int is_valid_gpio_number(int gpio, const char * name, FILE *f, bool manda
|
||||
return 0;
|
||||
}
|
||||
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;
|
||||
@@ -610,25 +609,30 @@ 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);
|
||||
@@ -761,10 +765,7 @@ 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user