var count = 0;
poll = L.poll(3, L.url('admin/network/wireless_scan_results', dev), null, function(s, results) {
+
if (Array.isArray(results)) {
var bss = [];
]);
});
- cbi_update_table(tbl, bss, E('em', { class: 'spinning' }, _('No scan results available yet...')));
+ cbi_update_table(tbl, bss, E('em' {}, _('No networks in range')));
+ }
+ else {
+ cbi_update_table(tbl, [], E('em', { class: 'spinning' }, _('No scan results available yet...')));
}
+
if (count++ >= 3) {
count = 0;
L.post(L.url('admin/network/wireless_scan_trigger', dev, 1), null, function() {});
return results.values[cache_key]
end
- return { }
+ return nil
end
function wifi_scan_trigger(radio, update)
end
if update then
- for _, bss in ipairs(_wifi_get_scan_results(cache_key)) do
- if not bssids[bss.bssid] then
- bss.stale = true
- data[#data + 1] = bss
+ local cached = _wifi_get_scan_results(cache_key)
+ if cached then
+ for _, bss in ipairs(cached) do
+ if not bssids[bss.bssid] then
+ bss.stale = true
+ data[#data + 1] = bss
+ end
end
end
end
function wifi_scan_results(radio)
local results = radio and _wifi_get_scan_results("scan_%s" % radio)
- if results and #results > 0 then
+ if results then
luci.http.prepare_content("application/json")
luci.http.write_json(results)
else