From 25c4b954a6037811ecafcf8189ab79b0f74d0aed Mon Sep 17 00:00:00 2001 From: Patrick Grimm Date: Wed, 10 Jul 2013 17:52:38 +0000 Subject: [PATCH] luci-olsr: add snr for olsr neighbours and update Legend --- applications/luci-olsr/luasrc/controller/olsr.lua | 6 +++--- applications/luci-olsr/luasrc/tools/olsr.lua | 14 ++++++++++++++ .../luci-olsr/luasrc/view/status-olsr/legend.htm | 17 +++++++++++++---- .../luci-olsr/luasrc/view/status-olsr/neighbors.htm | 7 +++++-- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/applications/luci-olsr/luasrc/controller/olsr.lua b/applications/luci-olsr/luasrc/controller/olsr.lua index bef7e52eb..daedcf54d 100644 --- a/applications/luci-olsr/luasrc/controller/olsr.lua +++ b/applications/luci-olsr/luasrc/controller/olsr.lua @@ -227,9 +227,9 @@ function action_neigh(json) for assocmac, assot in pairs(val.list) do assocmac = string.lower(assocmac or "") if rmac == assocmac then - signal = tonumber(assot.signal) - noise = tonumber(assot.noise) - snr = signal/noise + signal = tonumber(assot.signal)*-1 + noise = tonumber(assot.noise)*-1 + snr = noise - signal end end end diff --git a/applications/luci-olsr/luasrc/tools/olsr.lua b/applications/luci-olsr/luasrc/tools/olsr.lua index 425d09a31..dfd8262f0 100644 --- a/applications/luci-olsr/luasrc/tools/olsr.lua +++ b/applications/luci-olsr/luasrc/tools/olsr.lua @@ -26,3 +26,17 @@ function etx_color(etx) return color end +function snr_color(snr) + local color = "#bb3333" + if snr == 0 then + color = "#bb3333" + elseif snr > 30 then + color = "#00cc00" + elseif snr > 20 then + color = "#ffcb05" + elseif snr > 5 then + color = "#ff6600" + end + return color +end + diff --git a/applications/luci-olsr/luasrc/view/status-olsr/legend.htm b/applications/luci-olsr/luasrc/view/status-olsr/legend.htm index 55b839f52..7575c122f 100644 --- a/applications/luci-olsr/luasrc/view/status-olsr/legend.htm +++ b/applications/luci-olsr/luasrc/view/status-olsr/legend.htm @@ -3,9 +3,18 @@
  • LQ: <%:Success rate of packages received from the neighbour%>
  • NLQ: <%:Success rate of packages sent to the neighbour%>
  • ETX: <%:Expected retransmission count%>
  • -
  • <%:Green%>:<%:Very good (ETX < 2)%>
  • -
  • <%:Yellow%>:<%:Good (2 < ETX < 4)%>
  • -
  • <%:Orange%>:<%:Still usable (4 < ETX < 10)%>
  • -
  • <%:Red%>:<%:Bad (ETX > 10)%>
  • + +
  • SNR: <%:Signal Noise Ratio%>
  • + diff --git a/applications/luci-olsr/luasrc/view/status-olsr/neighbors.htm b/applications/luci-olsr/luasrc/view/status-olsr/neighbors.htm index 0fb9bc0a3..f3b374536 100644 --- a/applications/luci-olsr/luasrc/view/status-olsr/neighbors.htm +++ b/applications/luci-olsr/luasrc/view/status-olsr/neighbors.htm @@ -24,6 +24,7 @@ if luci.http.formvalue("status") == "1" then link.linkCost = 0 end local color = olsrtools.etx_color(link.linkCost) + local snr_color = olsrtools.snr_color(link.snr) defaultgw_color = "" if link.defaultgw == 1 then defaultgw_color = "#ffff99" @@ -43,6 +44,7 @@ if luci.http.formvalue("status") == "1" then signal = string.format("%.3f", link.signal), noise = string.format("%.3f", link.noise), color = color, + snr_color = snr_color, dfgcolor = defaultgw_color, proto = link.proto } @@ -100,7 +102,7 @@ end '%s' + '%s' + '', - neigh.dfgcolor, neigh.ifn, neigh.lip, neigh.lmac, neigh.dfgcolor, neigh.lq, neigh.dfgcolor, neigh.nlq, neigh.color, neigh.cost, neigh.color, neigh.signal, neigh.noise, neigh.snr || '?' + neigh.dfgcolor, neigh.ifn, neigh.lip, neigh.lmac, neigh.dfgcolor, neigh.lq, neigh.dfgcolor, neigh.nlq, neigh.color, neigh.cost, neigh.snr_color, neigh.signal, neigh.noise, neigh.snr || '?' ); } @@ -140,6 +142,7 @@ end end color = olsrtools.etx_color(link.linkCost) + snr_color = olsrtools.snr_color(link.snr) defaultgw_color = "" if link.defaultgw == 1 then @@ -158,7 +161,7 @@ end <%=string.format("%.3f", link.linkQuality)%> <%=string.format("%.3f", link.neighborLinkQuality)%> <%=string.format("%.3f", link.linkCost)%> - Noise: <%=string.format("%.3f", link.noise)%>"><%=string.format("%.3f", link.snr)%> + Noise: <%=string.format("%.3f", link.noise)%>"><%=string.format("%.3f", link.snr)%> <% i = ((i % 2) + 1) -- 2.11.0