假设第四次获得扫描结果

This commit is contained in:
zogodo
2019-09-28 22:14:10 +08:00
parent 5607f25d09
commit b457d576e4
3 changed files with 12 additions and 10 deletions

View File

@@ -148,8 +148,10 @@ exit:
static int http_get_wifi_scan(httpd_request_t *req)
{
static int n = 1;
OSStatus err = kNoErr;
send_http("OK", 2, exit, &err);
char* re = (n++)%4 == 0 ? "OK" : "NO";
send_http(re, 2, exit, &err);
exit:
return err;
}

View File

@@ -319,26 +319,26 @@ function SubmitNetwork() {
}
}
var get_ret = false;
function Rescan() {
HttpPost("/wifi/scan", function (re) {
alert(re);
if (re == "OK") {
get_ret = true;
rescan_btn.innerHTML = "Scanning...";
rescan_btn.disabled = true;
window.setTimeout(GetScanResult, 1000);
} else {
alert(re);
}
});
}
var tt = 5;
function GetScanResult() {
HttpGet("/wifi/scan", function (re) {
console.log(re);
if (get_ret && tt <= 0) {
get_ret = 0
if (re == "OK") {
rescan_btn.innerHTML = "Rescan";
rescan_btn.disabled = false;
return;
}
window.setTimeout(GetScanResult, 1000);
tt--;
});
}

File diff suppressed because one or more lines are too long