假设第四次获得扫描结果

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 http_get_wifi_scan(httpd_request_t *req)
{ {
static int n = 1;
OSStatus err = kNoErr; OSStatus err = kNoErr;
send_http("OK", 2, exit, &err); char* re = (n++)%4 == 0 ? "OK" : "NO";
send_http(re, 2, exit, &err);
exit: exit:
return err; return err;
} }

View File

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

File diff suppressed because one or more lines are too long