mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-08 20:47:08 +03:00
fix boot loop caused by competing wifi_manager and cmd_wifi
It is now possible to set a default autoexec command to automatically join wifi when wifi_manager is disabled. To test wifi stability without wifi_manager, use the following commands: nvs_set bypass_wm str -v "1" nvs_set autoexec str -v "1" nvs_set autoexec1 str -v "squeezelite -o I2S -b 500:2000 -d all=info -m nvs_set autoexec2 str -v "join <ssid> <password>" ESP32" restart Note that squeezelite occupies the "autoexec1" slot to avoid conflicts with the wifi manager web configuration page when it is re-enabled. To re-enable the wifi-manager, use the following commands: nvs_set bypass_wm str -v "0" restart -- Additional change: Credits page now has a button to enable the nvs editor even in ota mode
This commit is contained in:
@@ -28,7 +28,7 @@ var checkStatusInterval = null;
|
|||||||
|
|
||||||
var StatusIntervalActive = false;
|
var StatusIntervalActive = false;
|
||||||
var RefreshAPIIntervalActive = false;
|
var RefreshAPIIntervalActive = false;
|
||||||
|
var LastRecoveryState=null;
|
||||||
var output = '';
|
var output = '';
|
||||||
|
|
||||||
function stopCheckStatusInterval(){
|
function stopCheckStatusInterval(){
|
||||||
@@ -176,6 +176,16 @@ $(document).ready(function(){
|
|||||||
$( "#wifi" ).slideDown( "fast", 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() {
|
$("input#autoexec-cb").on("click", function() {
|
||||||
var data = { 'timestamp': Date.now() };
|
var data = { 'timestamp': Date.now() };
|
||||||
autoexec = (this.checked)?1:0;
|
autoexec = (this.checked)?1:0;
|
||||||
@@ -628,12 +638,21 @@ function checkStatus(){
|
|||||||
enableStatusTimer = true;
|
enableStatusTimer = true;
|
||||||
}
|
}
|
||||||
if (data.hasOwnProperty('recovery')) {
|
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) {
|
if (data["recovery"] === 1) {
|
||||||
recovery = true;
|
recovery = true;
|
||||||
$("#otadiv").show();
|
$("#otadiv").show();
|
||||||
$('a[href^="#tab-audio"]').hide();
|
$('a[href^="#tab-audio"]').hide();
|
||||||
$('a[href^="#tab-gpio"]').show();
|
$('a[href^="#tab-gpio"]').show();
|
||||||
$('a[href^="#tab-nvs"]').show();
|
|
||||||
$("footer.footer").removeClass('sl');
|
$("footer.footer").removeClass('sl');
|
||||||
$("footer.footer").addClass('recovery');
|
$("footer.footer").addClass('recovery');
|
||||||
$("#boot-button").html('Reboot');
|
$("#boot-button").html('Reboot');
|
||||||
@@ -644,7 +663,6 @@ function checkStatus(){
|
|||||||
$("#otadiv").hide();
|
$("#otadiv").hide();
|
||||||
$('a[href^="#tab-audio"]').show();
|
$('a[href^="#tab-audio"]').show();
|
||||||
$('a[href^="#tab-gpio"]').hide();
|
$('a[href^="#tab-gpio"]').hide();
|
||||||
$('a[href^="#tab-nvs"]').hide();
|
|
||||||
$("footer.footer").removeClass('recovery');
|
$("footer.footer").removeClass('recovery');
|
||||||
$("footer.footer").addClass('sl');
|
$("footer.footer").addClass('sl');
|
||||||
$("#boot-button").html('Recovery');
|
$("#boot-button").html('Recovery');
|
||||||
|
|||||||
@@ -300,7 +300,7 @@
|
|||||||
<h2>Firmware URL:</h2>
|
<h2>Firmware URL:</h2>
|
||||||
<textarea id="fwurl" maxlength="350"></textarea>
|
<textarea id="fwurl" maxlength="350"></textarea>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<input type="button" id="flash" class="btn btn-danger" value="Flash!" /><span id="flash-status"></span>
|
<input type="button" id="flash" class="btn btn-danger" value="Flash!" /><span id="flash-status"></span>
|
||||||
</div>
|
</div>
|
||||||
<div id="otadiv">
|
<div id="otadiv">
|
||||||
<div class="progress" id="progress">
|
<div class="progress" id="progress">
|
||||||
@@ -325,8 +325,12 @@
|
|||||||
<li>cJSON, © 2009-2017, Dave Gamble and cJSON contributors. Licensed under the MIT License.</li>
|
<li>cJSON, © 2009-2017, Dave Gamble and cJSON contributors. Licensed under the MIT License.</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<h2>Show NVS Editor</h2>
|
||||||
|
<div class="custom-control custom-switch">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="show-nvs" checked="checked">
|
||||||
|
<label class="custom-control-label" for="show-nvs"></label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<footer class="footer"><span id="foot-fw"></span><span id="foot-wifi"></span></footer>
|
<footer class="footer"><span id="foot-fw"></span><span id="foot-wifi"></span></footer>
|
||||||
<iframe width="0" height="0" border="0" name="dummyframe" id="dummyframe"></iframe>
|
<iframe width="0" height="0" border="0" name="dummyframe" id="dummyframe"></iframe>
|
||||||
|
|||||||
@@ -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){
|
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){
|
if(event_base== WIFI_EVENT){
|
||||||
switch(event_id) {
|
switch(event_id) {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
#include "tcpip_adapter.h"
|
#include "tcpip_adapter.h"
|
||||||
#include "esp_event.h"
|
#include "esp_event.h"
|
||||||
#include "led.h"
|
#include "led.h"
|
||||||
|
extern bool bypass_wifi_manager;
|
||||||
#define JOIN_TIMEOUT_MS (10000)
|
#define JOIN_TIMEOUT_MS (10000)
|
||||||
|
|
||||||
extern EventGroupHandle_t wifi_event_group;
|
extern EventGroupHandle_t wifi_event_group;
|
||||||
@@ -92,7 +92,7 @@ static void initialise_wifi(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tcpip_adapter_init();
|
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());
|
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||||
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
|
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
|
||||||
@@ -194,5 +194,7 @@ void register_wifi_join()
|
|||||||
void register_wifi()
|
void register_wifi()
|
||||||
{
|
{
|
||||||
register_wifi_join();
|
register_wifi_join();
|
||||||
initialise_wifi();
|
if(bypass_wifi_manager){
|
||||||
|
initialise_wifi();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ pthread_t thread_console;
|
|||||||
static void * console_thread();
|
static void * console_thread();
|
||||||
void console_start();
|
void console_start();
|
||||||
static const char * TAG = "console";
|
static const char * TAG = "console";
|
||||||
|
extern bool bypass_wifi_manager;
|
||||||
|
|
||||||
|
|
||||||
/* Prompt to be printed before each line.
|
/* Prompt to be printed before each line.
|
||||||
@@ -56,6 +56,12 @@ void process_autoexec(){
|
|||||||
uint8_t autoexec_flag=0;
|
uint8_t autoexec_flag=0;
|
||||||
|
|
||||||
char * str_flag = get_nvs_value_alloc(NVS_TYPE_STR, "autoexec");
|
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 ){
|
if(str_flag !=NULL ){
|
||||||
autoexec_flag=atoi(str_flag);
|
autoexec_flag=atoi(str_flag);
|
||||||
@@ -66,8 +72,18 @@ void process_autoexec(){
|
|||||||
ESP_LOGD(TAG,"Getting command name %s", autoexec_name);
|
ESP_LOGD(TAG,"Getting command name %s", autoexec_name);
|
||||||
autoexec_value= get_nvs_value_alloc(NVS_TYPE_STR, autoexec_name);
|
autoexec_value= get_nvs_value_alloc(NVS_TYPE_STR, autoexec_name);
|
||||||
if(autoexec_value!=NULL ){
|
if(autoexec_value!=NULL ){
|
||||||
ESP_LOGI(TAG,"Running command %s = %s", autoexec_name, autoexec_value);
|
if(!bypass_wifi_manager && strstr(autoexec_value, "join ")!=NULL ){
|
||||||
run_command(autoexec_value);
|
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);
|
ESP_LOGD(TAG,"Freeing memory for command %s name", autoexec_name);
|
||||||
free(autoexec_value);
|
free(autoexec_value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ EventGroupHandle_t wifi_event_group;
|
|||||||
bool enable_bt_sink=false;
|
bool enable_bt_sink=false;
|
||||||
bool enable_airplay=false;
|
bool enable_airplay=false;
|
||||||
bool jack_mutes_amp=false;
|
bool jack_mutes_amp=false;
|
||||||
|
bool bypass_wifi_manager=false;
|
||||||
const int CONNECTED_BIT = BIT0;
|
const int CONNECTED_BIT = BIT0;
|
||||||
#define JOIN_TIMEOUT_MS (10000)
|
#define JOIN_TIMEOUT_MS (10000)
|
||||||
|
|
||||||
@@ -216,10 +217,14 @@ void app_main()
|
|||||||
/* start the wifi manager */
|
/* start the wifi manager */
|
||||||
led_blink(LED_GREEN, 250, 250);
|
led_blink(LED_GREEN, 250, 250);
|
||||||
char * bypass_wm = get_nvs_value_alloc_default(NVS_TYPE_STR, "bypass_wm", "0", 0);
|
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)){
|
bypass_wifi_manager=(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.");
|
|
||||||
|
|
||||||
|
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 {
|
else {
|
||||||
|
ESP_LOGW(TAG,"\n\nwifi manager is ENABLED. Starting...\n\n");
|
||||||
wifi_manager_start();
|
wifi_manager_start();
|
||||||
wifi_manager_set_callback(EVENT_STA_GOT_IP, &cb_connection_got_ip);
|
wifi_manager_set_callback(EVENT_STA_GOT_IP, &cb_connection_got_ip);
|
||||||
wifi_manager_set_callback(WIFI_EVENT_STA_DISCONNECTED, &cb_connection_sta_disconnected);
|
wifi_manager_set_callback(WIFI_EVENT_STA_DISCONNECTED, &cb_connection_sta_disconnected);
|
||||||
|
|||||||
Reference in New Issue
Block a user