diff --git a/components/squeezelite/decode_external.c b/components/squeezelite/decode_external.c index 276ba501..2728610d 100644 --- a/components/squeezelite/decode_external.c +++ b/components/squeezelite/decode_external.c @@ -22,6 +22,7 @@ #include "squeezelite.h" #include "bt_app_sink.h" #include "raop_sink.h" +#include #define LOCK_O mutex_lock(outputbuf->mutex) #define UNLOCK_O mutex_unlock(outputbuf->mutex) @@ -90,6 +91,8 @@ static void sink_data_handler(const uint8_t *data, uint32_t len) /**************************************************************************************** * BT sink command handler */ + +extern u16_t get_adjusted_volume(u16_t volume); static void bt_sink_cmd_handler(bt_sink_cmd_t cmd, ...) { va_list args; @@ -133,7 +136,7 @@ static void bt_sink_cmd_handler(bt_sink_cmd_t cmd, ...) break; case BT_SINK_VOLUME: { u16_t volume = (u16_t) va_arg(args, u32_t); - volume *= 65536 / 128; + volume = get_adjusted_volume(volume); set_volume(volume, volume); break; } diff --git a/components/wifi-manager/code.js b/components/wifi-manager/code.js index 857481fc..b5c869ab 100644 --- a/components/wifi-manager/code.js +++ b/components/wifi-manager/code.js @@ -193,7 +193,7 @@ $(document).ready(function(){ console.log(xhr.status); console.log(thrownError); if (thrownError != '') showMessage(thrownError, 'ERROR'); - } + }, complete: function(response) { var returnedResponse = JSON.parse(response.responseText); console.log(response.responseText); @@ -210,7 +210,7 @@ $(document).ready(function(){ console.log(xhr.status); console.log(thrownError); if (thrownError != '') showMessage(thrownError, 'ERROR'); - } + }, complete: function(response) { console.log('reboot call completed'); diff --git a/main/esp_app_main.c b/main/esp_app_main.c index 915d2517..970b25a3 100644 --- a/main/esp_app_main.c +++ b/main/esp_app_main.c @@ -43,6 +43,7 @@ #include "trace.h" #include "wifi_manager.h" #include "squeezelite-ota.h" +#include static EventGroupHandle_t wifi_event_group; bool enable_bt_sink=false; @@ -153,6 +154,21 @@ char * process_ota_url(){ //CONFIG_A2DP_CONTROL_DELAY_MS=500 //CONFIG_A2DP_CONNECT_TIMEOUT_MS=1000 //CONFIG_WIFI_MANAGER_MAX_RETRY=2 +u16_t get_adjusted_volume(u16_t volume){ + + char * str_factor = get_nvs_value_alloc_default(NVS_TYPE_STR, "volumefactor", "3", 0); + if(str_factor != NULL ){ + + float factor = atof(str_factor); + free(str_factor); + return (u16_t) (65536.0f * powf( (volume/ 128.0f), factor) ); + } + else { + ESP_LOGW(TAG,"Error retrieving volume factor. Returning unmodified volume level. "); + return volume; + } + +} void register_default_nvs(){ nvs_value_set_default(NVS_TYPE_STR, "bt_sink_name", CONFIG_BT_NAME, 0);