mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-06 19:47:02 +03:00
turn of JSON timers when wifi is connected
This commit is contained in:
@@ -33,7 +33,6 @@ function stopCheckStatusInterval(){
|
||||
}
|
||||
|
||||
function stopRefreshAPInterval(){
|
||||
|
||||
if(refreshAPInterval != null){
|
||||
clearTimeout(refreshAPInterval);
|
||||
refreshAPInterval = null;
|
||||
@@ -41,7 +40,6 @@ function stopRefreshAPInterval(){
|
||||
RefreshAPIIntervalActive = false;
|
||||
}
|
||||
|
||||
|
||||
function startCheckStatusInterval(){
|
||||
StatusIntervalActive = true;
|
||||
checkStatusInterval = setTimeout(checkStatus, 950);
|
||||
@@ -52,7 +50,6 @@ function startRefreshAPInterval(){
|
||||
refreshAPInterval = setTimeout(refreshAP, 2800);
|
||||
}
|
||||
|
||||
|
||||
function RepeatCheckStatusInterval(){
|
||||
if(StatusIntervalActive)
|
||||
startCheckStatusInterval();
|
||||
@@ -155,7 +152,6 @@ $(document).ready(function(){
|
||||
});
|
||||
|
||||
$("#yes-disconnect").on("click", function() {
|
||||
|
||||
stopCheckStatusInterval();
|
||||
selectedSSID = "";
|
||||
|
||||
@@ -206,7 +202,6 @@ $(document).ready(function(){
|
||||
});
|
||||
|
||||
function performConnect(conntype){
|
||||
|
||||
//stop the status refresh. This prevents a race condition where a status
|
||||
//request would be refreshed with wrong ip info from a previous connection
|
||||
//and the request would automatically shows as succesful.
|
||||
@@ -277,10 +272,10 @@ function refreshAP(){
|
||||
});
|
||||
apList = data;
|
||||
refreshAPHTML(apList);
|
||||
|
||||
}
|
||||
});
|
||||
RepeatRefreshAPInterval();
|
||||
//TODO daduke
|
||||
// RepeatRefreshAPInterval();
|
||||
}
|
||||
|
||||
function refreshAPHTML(data){
|
||||
@@ -295,9 +290,6 @@ function refreshAPHTML(data){
|
||||
|
||||
function checkStatus(){
|
||||
$.getJSON( "/status.json", function( data ) {
|
||||
if(data.hasOwnProperty('autoexec1') && data['autoexec1'] != ""){
|
||||
$("#autoexec1_current").text(data["autoexec1"]);
|
||||
}
|
||||
if(data.hasOwnProperty('ssid') && data['ssid'] != ""){
|
||||
if(data["ssid"] === selectedSSID){
|
||||
//that's a connection attempt
|
||||
@@ -349,6 +341,10 @@ function checkStatus(){
|
||||
$("#gw").text(data["gw"]);
|
||||
$("#wifi-status").slideDown( "fast", function() {});
|
||||
}
|
||||
//TODO daduke
|
||||
console.log("stopping timers..");
|
||||
stopCheckStatusInterval();
|
||||
stopRefreshAPInterval
|
||||
}
|
||||
}
|
||||
else if(data.hasOwnProperty('urc') && data['urc'] === 2){
|
||||
|
||||
@@ -166,6 +166,7 @@ void wifi_manager_start(){
|
||||
/* start wifi manager task */
|
||||
xTaskCreate(&wifi_manager, "wifi_manager", 4096, NULL, WIFI_MANAGER_TASK_PRIORITY, &task_wifi_manager);
|
||||
}
|
||||
|
||||
uint8_t wifi_manager_get_flag(){
|
||||
uint8_t value=0;
|
||||
nvs_handle handle;
|
||||
@@ -240,6 +241,7 @@ esp_err_t wifi_manager_save_autoexec_flag(uint8_t flag){
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t wifi_manager_save_autoexec_config(char * value, char * name, int len){
|
||||
nvs_handle handle;
|
||||
char val[len+1];
|
||||
@@ -272,8 +274,8 @@ esp_err_t wifi_manager_save_autoexec_config(char * value, char * name, int len){
|
||||
return ESP_OK;
|
||||
|
||||
}
|
||||
esp_err_t wifi_manager_save_sta_config(){
|
||||
|
||||
esp_err_t wifi_manager_save_sta_config(){
|
||||
nvs_handle handle;
|
||||
esp_err_t esp_err;
|
||||
ESP_LOGI(TAG, "About to save config to flash");
|
||||
@@ -316,7 +318,6 @@ esp_err_t wifi_manager_save_sta_config(){
|
||||
}
|
||||
|
||||
bool wifi_manager_fetch_wifi_sta_config(){
|
||||
|
||||
nvs_handle handle;
|
||||
esp_err_t esp_err;
|
||||
|
||||
@@ -399,7 +400,6 @@ void wifi_manager_clear_ip_info_json(){
|
||||
|
||||
|
||||
void wifi_manager_generate_ip_info_json(update_reason_code_t update_reason_code){
|
||||
|
||||
wifi_config_t *config = wifi_manager_get_wifi_sta_config();
|
||||
if(config){
|
||||
|
||||
@@ -441,16 +441,14 @@ void wifi_manager_generate_ip_info_json(update_reason_code_t update_reason_code)
|
||||
else{
|
||||
wifi_manager_clear_ip_info_json();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void wifi_manager_clear_access_points_json(){
|
||||
strcpy(accessp_json, "[]\n");
|
||||
}
|
||||
void wifi_manager_generate_acess_points_json(){
|
||||
|
||||
void wifi_manager_generate_acess_points_json(){
|
||||
strcpy(accessp_json, "[");
|
||||
|
||||
|
||||
@@ -479,8 +477,6 @@ void wifi_manager_generate_acess_points_json(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool wifi_manager_lock_sta_ip_string(TickType_t xTicksToWait){
|
||||
if(wifi_manager_sta_ip_mutex){
|
||||
if( xSemaphoreTake( wifi_manager_sta_ip_mutex, xTicksToWait ) == pdTRUE ) {
|
||||
@@ -495,12 +491,12 @@ bool wifi_manager_lock_sta_ip_string(TickType_t xTicksToWait){
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void wifi_manager_unlock_sta_ip_string(){
|
||||
xSemaphoreGive( wifi_manager_sta_ip_mutex );
|
||||
}
|
||||
|
||||
void wifi_manager_safe_update_sta_ip_string(uint32_t ip){
|
||||
|
||||
if(wifi_manager_lock_sta_ip_string(portMAX_DELAY)){
|
||||
|
||||
struct ip4_addr ip4;
|
||||
@@ -520,7 +516,6 @@ char* wifi_manager_get_sta_ip_string(){
|
||||
return wifi_manager_sta_ip;
|
||||
}
|
||||
|
||||
|
||||
bool wifi_manager_lock_json_buffer(TickType_t xTicksToWait){
|
||||
if(wifi_manager_json_mutex){
|
||||
if( xSemaphoreTake( wifi_manager_json_mutex, xTicksToWait ) == pdTRUE ) {
|
||||
@@ -535,6 +530,7 @@ bool wifi_manager_lock_json_buffer(TickType_t xTicksToWait){
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void wifi_manager_unlock_json_buffer(){
|
||||
xSemaphoreGive( wifi_manager_json_mutex );
|
||||
}
|
||||
@@ -543,12 +539,8 @@ char* wifi_manager_get_ap_list_json(){
|
||||
return accessp_json;
|
||||
}
|
||||
|
||||
|
||||
esp_err_t wifi_manager_event_handler(void *ctx, system_event_t *event)
|
||||
{
|
||||
|
||||
|
||||
|
||||
switch(event->event_id) {
|
||||
|
||||
case SYSTEM_EVENT_WIFI_READY:
|
||||
@@ -625,7 +617,6 @@ wifi_config_t* wifi_manager_get_wifi_sta_config(){
|
||||
return wifi_manager_config_sta;
|
||||
}
|
||||
|
||||
|
||||
void wifi_manager_connect_async(){
|
||||
/* in order to avoid a false positive on the front end app we need to quickly flush the ip json
|
||||
* There'se a risk the front end sees an IP or a password error when in fact
|
||||
@@ -644,7 +635,6 @@ char* wifi_manager_get_ip_info_json(){
|
||||
}
|
||||
|
||||
void wifi_manager_destroy(){
|
||||
|
||||
vTaskDelete(task_wifi_manager);
|
||||
task_wifi_manager = NULL;
|
||||
|
||||
@@ -671,11 +661,8 @@ void wifi_manager_destroy(){
|
||||
wifi_manager_event_group = NULL;
|
||||
vQueueDelete(wifi_manager_queue);
|
||||
wifi_manager_queue = NULL;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void wifi_manager_filter_unique( wifi_ap_record_t * aplist, uint16_t * aps) {
|
||||
int total_unique;
|
||||
wifi_ap_record_t * first_free;
|
||||
@@ -727,7 +714,6 @@ void wifi_manager_filter_unique( wifi_ap_record_t * aplist, uint16_t * aps) {
|
||||
*aps = total_unique;
|
||||
}
|
||||
|
||||
|
||||
BaseType_t wifi_manager_send_message_to_front(message_code_t code, void *param){
|
||||
queue_message msg;
|
||||
msg.code = code;
|
||||
@@ -742,26 +728,19 @@ BaseType_t wifi_manager_send_message(message_code_t code, void *param){
|
||||
return xQueueSend( wifi_manager_queue, &msg, portMAX_DELAY);
|
||||
}
|
||||
|
||||
|
||||
void wifi_manager_set_callback(message_code_t message_code, void (*func_ptr)(void*) ){
|
||||
|
||||
if(cb_ptr_arr && message_code < MESSAGE_CODE_COUNT){
|
||||
cb_ptr_arr[message_code] = func_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_manager( void * pvParameters ){
|
||||
|
||||
|
||||
queue_message msg;
|
||||
BaseType_t xStatus;
|
||||
EventBits_t uxBits;
|
||||
uint8_t retries = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* initialize the tcp stack */
|
||||
tcpip_adapter_init();
|
||||
|
||||
@@ -1134,7 +1113,4 @@ void wifi_manager( void * pvParameters ){
|
||||
} /* end of for loop */
|
||||
|
||||
vTaskDelete( NULL );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user