Christian Herzog 5 lat temu
rodzic
commit
bb44b3f718
1 zmienionych plików z 17 dodań i 10 usunięć
  1. 17 10
      components/wifi-manager/code.js

+ 17 - 10
components/wifi-manager/code.js

@@ -643,16 +643,19 @@ function rssiToIcon(rssi){
 
 function refreshAP(force){
     if (!enableAPTimer && !force) return;
-    $.getJSON( "/ap.json", function( data ) {
-        if(data.length > 0){
-            //sort by signal strength
-            data.sort(function (a, b) {
-                var x = a["rssi"]; var y = b["rssi"];
-                return ((x < y) ? 1 : ((x > y) ? -1 : 0));
-            });
-            apList = data;
-            refreshAPHTML(apList);
-        }
+    $.getJSON( "/scan.json", async function( data ) {
+        await sleep(2000);
+        $.getJSON( "/ap.json", function( data ) {
+            if(data.length > 0){
+                //sort by signal strength
+                data.sort(function (a, b) {
+                    var x = a["rssi"]; var y = b["rssi"];
+                    return ((x < y) ? 1 : ((x > y) ? -1 : 0));
+                });
+                apList = data;
+                refreshAPHTML(apList);
+            }
+        });
     });
 }
 
@@ -975,3 +978,7 @@ function showMessage(message, severity, age=0) {
 function inRange(x, min, max) {
     return ((x-min)*(x-max) <= 0);
 }
+
+function sleep(ms) {
+  return new Promise(resolve => setTimeout(resolve, ms));
+}