diff --git a/components/wifi-manager/code.js b/components/wifi-manager/code.js
index 0fac0c10..af504e7e 100644
--- a/components/wifi-manager/code.js
+++ b/components/wifi-manager/code.js
@@ -28,7 +28,7 @@ var checkStatusInterval = null;
var StatusIntervalActive = false;
var RefreshAPIIntervalActive = false;
-
+var LastRecoveryState=null;
var output = '';
function stopCheckStatusInterval(){
@@ -176,6 +176,16 @@ $(document).ready(function(){
$( "#wifi" ).slideDown( "fast", function() {})
});
+ $("input#show-nvs").on("click", function() {
+ this.checked=this.checked?1:0;
+ if(this.checked){
+ $('a[href^="#tab-nvs"]').show();
+ } else {
+ $('a[href^="#tab-nvs"]').hide();
+ }
+
+ });
+
$("input#autoexec-cb").on("click", function() {
var data = { 'timestamp': Date.now() };
autoexec = (this.checked)?1:0;
@@ -628,12 +638,21 @@ function checkStatus(){
enableStatusTimer = true;
}
if (data.hasOwnProperty('recovery')) {
+ if(LastRecoveryState != data["recovery"]){
+ LastRecoveryState = data["recovery"];
+ $("input#show-nvs")[0].checked=LastRecoveryState==1?true:false;
+ }
+ if($("input#show-nvs")[0].checked){
+ $('a[href^="#tab-nvs"]').show();
+ } else{
+ $('a[href^="#tab-nvs"]').hide();
+ }
+
if (data["recovery"] === 1) {
recovery = true;
$("#otadiv").show();
$('a[href^="#tab-audio"]').hide();
$('a[href^="#tab-gpio"]').show();
- $('a[href^="#tab-nvs"]').show();
$("footer.footer").removeClass('sl');
$("footer.footer").addClass('recovery');
$("#boot-button").html('Reboot');
@@ -644,7 +663,6 @@ function checkStatus(){
$("#otadiv").hide();
$('a[href^="#tab-audio"]').show();
$('a[href^="#tab-gpio"]').hide();
- $('a[href^="#tab-nvs"]').hide();
$("footer.footer").removeClass('recovery');
$("footer.footer").addClass('sl');
$("#boot-button").html('Recovery');
diff --git a/components/wifi-manager/index.html b/components/wifi-manager/index.html
index 6252b19b..1ac91529 100644
--- a/components/wifi-manager/index.html
+++ b/components/wifi-manager/index.html
@@ -300,7 +300,7 @@
Firmware URL:
-
+
@@ -325,8 +325,12 @@
cJSON, © 2009-2017, Dave Gamble and cJSON contributors. Licensed under the MIT License.
+
Show NVS Editor
+
+
+
+
-
diff --git a/components/wifi-manager/wifi_manager.c b/components/wifi-manager/wifi_manager.c
index 7623b50e..11e22c8d 100644
--- a/components/wifi-manager/wifi_manager.c
+++ b/components/wifi-manager/wifi_manager.c
@@ -543,14 +543,6 @@ char* wifi_manager_get_ap_list_json(){
static void event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data){
-// if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
-// led_blink_pushed(LED_GREEN, 250, 250);
-// esp_wifi_connect();
-// xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
-// } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
-// led_unpush(LED_GREEN);
-// xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
-// }
if(event_base== WIFI_EVENT){
switch(event_id) {
diff --git a/main/cmd_wifi.c b/main/cmd_wifi.c
index 4d7549eb..c7e9528b 100644
--- a/main/cmd_wifi.c
+++ b/main/cmd_wifi.c
@@ -32,7 +32,7 @@
#include "tcpip_adapter.h"
#include "esp_event.h"
#include "led.h"
-
+extern bool bypass_wifi_manager;
#define JOIN_TIMEOUT_MS (10000)
extern EventGroupHandle_t wifi_event_group;
@@ -92,7 +92,7 @@ static void initialise_wifi(void)
return;
}
tcpip_adapter_init();
- wifi_event_group = xEventGroupCreate();
+ // Now moved to esp_app_main: wifi_event_group = xEventGroupCreate();
ESP_ERROR_CHECK(esp_event_loop_create_default());
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
@@ -194,5 +194,7 @@ void register_wifi_join()
void register_wifi()
{
register_wifi_join();
- initialise_wifi();
+ if(bypass_wifi_manager){
+ initialise_wifi();
+ }
}
diff --git a/main/console.c b/main/console.c
index a254f118..0d54d8d6 100644
--- a/main/console.c
+++ b/main/console.c
@@ -32,7 +32,7 @@ pthread_t thread_console;
static void * console_thread();
void console_start();
static const char * TAG = "console";
-
+extern bool bypass_wifi_manager;
/* Prompt to be printed before each line.
@@ -56,6 +56,12 @@ void process_autoexec(){
uint8_t autoexec_flag=0;
char * str_flag = get_nvs_value_alloc(NVS_TYPE_STR, "autoexec");
+ if(!bypass_wifi_manager){
+ ESP_LOGW(TAG, "Procesing autoexec commands while wifi_manager active. Wifi related commands will be ignored.");
+ }
+#if RECOVERY_APPLICATION
+ ESP_LOGD(TAG, "Processing autoexec commands in recovery mode. Squeezelite commands will be ignored.")
+#endif
if(str_flag !=NULL ){
autoexec_flag=atoi(str_flag);
@@ -66,8 +72,18 @@ void process_autoexec(){
ESP_LOGD(TAG,"Getting command name %s", autoexec_name);
autoexec_value= get_nvs_value_alloc(NVS_TYPE_STR, autoexec_name);
if(autoexec_value!=NULL ){
- ESP_LOGI(TAG,"Running command %s = %s", autoexec_name, autoexec_value);
- run_command(autoexec_value);
+ if(!bypass_wifi_manager && strstr(autoexec_value, "join ")!=NULL ){
+ ESP_LOGW(TAG,"Ignoring wifi join command.");
+ }
+#if RECOVERY_APPLICATION
+ else if(!strstr(autoexec_value, "squeezelite " ) ){
+ ESP_LOGW(TAG,"Ignoring command. ");
+ }
+#endif
+ else {
+ ESP_LOGI(TAG,"Running command %s = %s", autoexec_name, autoexec_value);
+ run_command(autoexec_value);
+ }
ESP_LOGD(TAG,"Freeing memory for command %s name", autoexec_name);
free(autoexec_value);
}
diff --git a/main/esp_app_main.c b/main/esp_app_main.c
index e8528eb6..4d9d36ec 100644
--- a/main/esp_app_main.c
+++ b/main/esp_app_main.c
@@ -49,6 +49,7 @@ EventGroupHandle_t wifi_event_group;
bool enable_bt_sink=false;
bool enable_airplay=false;
bool jack_mutes_amp=false;
+bool bypass_wifi_manager=false;
const int CONNECTED_BIT = BIT0;
#define JOIN_TIMEOUT_MS (10000)
@@ -216,10 +217,14 @@ void app_main()
/* start the wifi manager */
led_blink(LED_GREEN, 250, 250);
char * bypass_wm = get_nvs_value_alloc_default(NVS_TYPE_STR, "bypass_wm", "0", 0);
- if((strcmp(bypass_wm,"1")==0 ||strcasecmp(bypass_wm,"y")==0)){
- ESP_LOGW(TAG,"wifi manager is disabled. Please use wifi commands to connect to your wifi access point.");
+ bypass_wifi_manager=(strcmp(bypass_wm,"1")==0 ||strcasecmp(bypass_wm,"y")==0);
+
+
+ if(bypass_wifi_manager){
+ ESP_LOGW(TAG,"\n\nwifi manager is disabled. Please use wifi commands to connect to your wifi access point.\n\n");
}
else {
+ ESP_LOGW(TAG,"\n\nwifi manager is ENABLED. Starting...\n\n");
wifi_manager_start();
wifi_manager_set_callback(EVENT_STA_GOT_IP, &cb_connection_got_ip);
wifi_manager_set_callback(WIFI_EVENT_STA_DISCONNECTED, &cb_connection_sta_disconnected);