Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move mesh wide status packages to shared-state-async #1107

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/shared-state-node_info/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ define Package/$(PKG_NAME)
TITLE:=Node information module for shared-state
MAINTAINER:= Javier <[email protected]>
DEPENDS:=+lua +luci-lib-jsonc +ubus-lime-utils \
+lime-system +ubus-lime-location shared-state
+lime-system +ubus-lime-location shared-state-async
PKGARCH:=all
endef

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/bin/sh

unique_append()
{
grep -qF "$1" "$2" || echo "$1" >> "$2"
}

unique_append \
'*/5 * * * * ((sleep $(($RANDOM % 120)); shared-state sync node_info &> /dev/null)&)'\
/etc/crontabs/root
uci set shared-state.node_info=dataType
uci set shared-state.node_info.name='node_info'
uci set shared-state.node_info.scope='community'
uci set shared-state.node_info.ttl='2400'
uci set shared-state.node_info.update_interval='33'
uci commit shared-state
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ function get_node_info()
end

local result = { [hostname] = get_node_info() }
io.popen("shared-state insert node_info", "w"):write(JSON.stringify(result))
io.popen("shared-state-async insert node_info", "w"):write(JSON.stringify(result))
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local utils = require('lime.utils')

local uci = nil

package.path = package.path .. ";packages/shared-state-node_info/files/usr/bin/?;;"
package.path = package.path .. ";packages/shared-state-node_info/files/usr/share/shared-state/publishers/?;;"
require ("shared-state-publish_node_info")

describe('Tests network_nodes #network_nodes', function ()
Expand Down
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 +libiwinfo-lua shared-state
+lime-system +libiwinfo-lua shared-state-async
PKGARCH:=all
endef

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
#!/bin/sh

unique_append()
{
grep -qF "$1" "$2" || echo "$1" >> "$2"
}

unique_append \
'*/5 * * * * ((sleep $(($RANDOM % 120)); shared-state sync wifi_links_info &> /dev/null)&)'\
/etc/crontabs/root
uci set shared-state.wifi_links_info=dataType
uci set shared-state.wifi_links_info.name='wifi_links_info'
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 @@ -2,7 +2,7 @@

--! LibreMesh
--! Copyright (C) 2019 Gioacchino Mazzurco <[email protected]>
--! Copyright (C) 2019 Javier Jorge <[email protected]>
--! Copyright (C) 2024 Javier Jorge <[email protected]>
--!
--! This program is free software: you can redistribute it and/or modify
--! it under the terms of the GNU Affero General Public License as
Expand All @@ -28,17 +28,20 @@ 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

local hostname = io.input("/proc/sys/kernel/hostname"):read("*line")
local result = { [hostname] = get_wifi_links_info() }
io.popen("shared-state insert wifi_links_info", "w"):write(JSON.stringify(result))

io.popen("shared-state-async insert wifi_links_info", "w"):write(JSON.stringify(result))
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local utils = require "lime.utils"
local node_status = require 'lime.node_status'
local iwinfo = require('iwinfo')

package.path = package.path .. ";packages/shared-state-wifi_links_info/files/usr/bin/?;;"
package.path = package.path .. ";packages/shared-state-wifi_links_info/files/usr/share/shared-state/publishers/?;;"
require ("shared-state-publish_wifi_links_info")

it('a simple test to get links info and assert requiered fields are present', function()
Expand All @@ -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)

Loading