Skip to content

Commit

Permalink
Merge pull request #1045 from javierbrk/linkinfo
Browse files Browse the repository at this point in the history
shared-state-wifi_links_info add link frequency information
  • Loading branch information
G10h4ck authored Aug 31, 2023
2 parents c1b9ed3 + fb8432f commit 44043c1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/shared-state-wifi_links_info/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ define Package/$(PKG_NAME)
MAINTAINER:=
URL:=http://libremesh.org
DEPENDS:=+lua +luci-lib-jsonc +ubus-lime-utils \
+lime-system shared-state
+lime-system +libiwinfo-lua shared-state
PKGARCH:=all
endef

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
local JSON = require("luci.jsonc")
local node_status = require ("lime.node_status")
local network = require ("lime.network")
local iwinfo = require "iwinfo"


function get_wifi_links_info()
local stations = node_status.get_stations()
Expand All @@ -28,9 +30,10 @@ function get_wifi_links_info()
macparts = network.get_mac(station.iface)
src_macaddr = table.concat(macparts,":")
local station_stats = node_status.get_station_stats(station)
local freq = iwinfo.nl80211.frequency(station.iface)
table.insert(links, {src_mac=src_macaddr ,dst_mac=station.station_mac,
signal=station_stats.signal,chains=station_stats.chains,
rx_rate=station_stats.rx_rate,tx_rate=station_stats.tx_rate } )
rx_rate=station_stats.rx_rate,tx_rate=station_stats.tx_rate,freq=freq } )
end
return links
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ it('a simple test to get links info and assert requiered fields are present', fu
return iwinfo.mocks.iw_station_get_result_wlan1
end)
stub(node_status, "get_stations", function () return iwinfo.mocks.get_stations end)

stub(node_status, "get_stations", function () return iwinfo.mocks.get_stations end)
stub(iwinfo.nl80211,"frequency",function (iface) return 2400 end)
stub(network, "get_mac", function (iface)
if string.match(iface, "wlan0") then
return iwinfo.mocks.wlan0_mesh_mac
Expand All @@ -28,6 +29,7 @@ it('a simple test to get links info and assert requiered fields are present', fu
assert.is.same({-17,-18}, links_info[1].chains)
assert.is.equal(-14, links_info[1].signal)
assert.is.equal(13000, links_info[1].rx_rate)
assert.is.equal(2400, links_info[1].freq)
assert.is.equal("C0:00:00:00:00:00", links_info[1].src_mac)
end)

0 comments on commit 44043c1

Please sign in to comment.