diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-07-19 17:59:05 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-07-19 17:59:05 +0200 |
commit | 8dd2df29c47ab0ce594246ebc477bddb8043bcb7 (patch) | |
tree | 1d4eda134f5d7b34021ba27c4e2cc236d28937ae /modules/luci-mod-network/luasrc | |
parent | 5510bdae399c131f8911f4d4b39ec6832252c161 (diff) |
luci-mod-network: improve wifi scan status reporting
Attempt to properly report the scan status by treating 404 replies as
not yet completed scans and empty array replies as successful scans
that did not yield any results.
Fixes: #2874
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-network/luasrc')
-rw-r--r-- | modules/luci-mod-network/luasrc/controller/admin/network.lua | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/modules/luci-mod-network/luasrc/controller/admin/network.lua b/modules/luci-mod-network/luasrc/controller/admin/network.lua index fac8d95a20..b20607e2e9 100644 --- a/modules/luci-mod-network/luasrc/controller/admin/network.lua +++ b/modules/luci-mod-network/luasrc/controller/admin/network.lua @@ -311,7 +311,7 @@ local function _wifi_get_scan_results(cache_key) return results.values[cache_key] end - return { } + return nil end function wifi_scan_trigger(radio, update) @@ -343,10 +343,13 @@ 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 @@ -361,7 +364,7 @@ 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 |