turn of JSON timers when wifi is connected

This commit is contained in:
Christian Herzog
2019-09-17 21:10:05 +02:00
parent 15cd5e1724
commit 871ce36ee9
2 changed files with 12 additions and 40 deletions

View File

@@ -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){