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