end
local function compare(a, b)
- if tonumber(a.ETX) == 0 then
+ local c = tonumber(a.ETX)
+ local d = tonumber(b.ETX)
+
+ if not c or c == 0 then
return false
end
- if tonumber(b.ETX) == 0 then
+ if not d or d == 0 then
return true
end
- return tonumber(a.ETX) < tonumber(b.ETX)
+ return c < d
end
table.sort(data.Links, compare)
end
local function compare(a, b)
- if tonumber(a.ETX) == 0 then
+ local c = tonumber(a.ETX)
+ local d = tonumber(b.ETX)
+
+ if not c or c == 0 then
return false
end
- if tonumber(b.ETX) == 0 then
+ if not d or d == 0 then
return true
end
- return tonumber(a.ETX) < tonumber(b.ETX)
+ return c < d
end
table.sort(data.Routes, compare)
local lines = luci.util.split(tbl, "\n")
local name = table.remove(lines, 1):sub(8)
local keys = luci.util.split(table.remove(lines, 1), "\t")
+ local split = #keys - 1
data[name] = {}
for j, line in ipairs(lines) do
- local fields = luci.util.split(line, "\t")
+ local fields = luci.util.split(line, "\t", split)
data[name][j] = {}
for k, key in pairs(keys) do
data[name][j][key] = fields[k]
end
+
+ if data[name][j].Linkcost then
+ data[name][j].LinkQuality,
+ data[name][j].NLQ,
+ data[name][j].ETX =
+ data[name][j].Linkcost:match("(.*)/(.*)\t(.*)")
+ end
end
end