Skip to content

Commit

Permalink
shared-state: adds wifi key to info data type
Browse files Browse the repository at this point in the history
  • Loading branch information
javierajorge committed May 12, 2024
1 parent 331e5f0 commit 4f5c936
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ uci set shared-state.wifi_links_info.scope='community'
uci set shared-state.wifi_links_info.ttl='2400'
uci set shared-state.wifi_links_info.update_interval='33'
uci commit shared-state

## Refference state data type
uci set shared-state.wifi_links_info_ref=dataType
uci set shared-state.wifi_links_info_ref.name='wifi_links_info_ref'
uci set shared-state.wifi_links_info_ref.scope='community'
uci set shared-state.wifi_links_info_ref.ttl='2400'
uci set shared-state.wifi_links_info_ref.update_interval='50'
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ function get_wifi_links_info()
local links = {}
for _, station in ipairs(stations) do
macparts = network.get_mac(station.iface)
src_macaddr = table.concat(macparts,":")
src_macaddr = string.lower(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,
local chanenel = iwinfo.nl80211.channel(station.iface)
local key_table = {string.lower(string.gsub(src_macaddr,":","")),string.lower(string.gsub(station.station_mac,":",""))}
table.sort(key_table)
links[table.concat(key_table)]= {src_mac=src_macaddr ,dst_mac=string.lower(station.station_mac),
signal=station_stats.signal,chains=station_stats.chains,iface=station.iface,
rx_rate=station_stats.rx_rate,tx_rate=station_stats.tx_rate,freq=freq } )
rx_rate=station_stats.rx_rate,tx_rate=station_stats.tx_rate,freq=freq, channel = chanenel }
end
utils.printJson(links)
return links
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ it('a simple test to get links info and assert requiered fields are present', fu
local links_info = {}

links_info = get_wifi_links_info()
assert.is.equal(26000, links_info[1].tx_rate)
assert.is.equal("C0:4A:00:BE:7B:09", links_info[1].dst_mac)
assert.is.same({-17,-18}, links_info[1].chains)
assert.is.equal(-14, links_info[1].signal)
assert.is.equal("wlan0-mesh", links_info[1].iface)
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)
assert.is.equal(26000, links_info["c00000000000c04a00be7b09"].tx_rate)
assert.is.equal("c0:4a:00:be:7b:09", links_info["c00000000000c04a00be7b09"].dst_mac)
assert.is.same({-17,-18}, links_info["c00000000000c04a00be7b09"].chains)
assert.is.equal(-14, links_info["c00000000000c04a00be7b09"].signal)
assert.is.equal("wlan0-mesh", links_info["c00000000000c04a00be7b09"].iface)
assert.is.equal(13000, links_info["c00000000000c04a00be7b09"].rx_rate)
assert.is.equal(2400, links_info["c00000000000c04a00be7b09"].freq)
assert.is.equal("c0:00:00:00:00:00", links_info["c00000000000c04a00be7b09"].src_mac)
end)

0 comments on commit 4f5c936

Please sign in to comment.