modules/base: work around wireless status changes
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 21 Oct 2014 21:38:51 +0000 (23:38 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 21 Oct 2014 21:39:08 +0000 (23:39 +0200)
The latest netifd updates changed the ubus wireless status reporting in a
way that breaks the current LuCI integration. Work around the changed
format by translating the extended UCI section syntax back to the plain one.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
modules/base/luasrc/model/network.lua

index 0aac416ace55ecac69d46ccd446627af94cbaad5..6119abd73c76fb8d473217d5b98ffa6aa3963dc7 100644 (file)
@@ -135,13 +135,25 @@ function _wifi_iface(x)
 end
 
 function _wifi_state(key, val, field)
+       local radio, radiostate, ifc, ifcstate
+
        if not next(_ubuswificache) then
                _ubuswificache = _ubus:call("network.wireless", "status", {}) or {}
+
+               -- workaround extended section format
+               for radio, radiostate in pairs(_ubuswificache) do
+                       for ifc, ifcstate in pairs(radiostate.interfaces) do
+                               if ifcstate.section and ifcstate.section:sub(1, 1) == '@' then
+                                       local s = _uci_real:get_all('wireless.%s' % ifcstate.section)
+                                       if s then
+                                               ifcstate.section = s['.name']
+                                       end
+                               end
+                       end
+               end
        end
 
-       local radio, radiostate
        for radio, radiostate in pairs(_ubuswificache) do
-               local ifc, ifcstate
                for ifc, ifcstate in pairs(radiostate.interfaces) do
                        if ifcstate[key] == val then
                                return ifcstate[field]