Skip to content

Commit

Permalink
Merge pull request #1039 from a-gave/feat/wifi-unstuck-wa_add-hook
Browse files Browse the repository at this point in the history
wifi-unstuck-wa: allow parametrizable values for interval and timeout
  • Loading branch information
a-gave authored Aug 22, 2023
2 parents 24ae02f + e41d259 commit 46e52ca
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/lime-docs/files/www/docs/lime-example.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ config lime wifi # Settings in this section applies to all radios.
option ieee80211s_mesh_id 'LiMe' # Mesh cloud identifier (close to SSID in concept). Used by the nodes to join and participate in the mesh network.
# option ieee80211s_encryption 'psk2/aes' # in order to use encrypted mesh, the wpad-mini package have to be replaced with wpad-mesh-wolfssl package either manually or by the selected network-profile
# option ieee80211s_key 'SomePsk2AESKey'
option unstuck_interval '10' # Interval in minutes that defines how often to run the workaround script provided by the package wifi-unstuck-wa that rescan all available frequencies in active radios.
option unstuck_timeout '300' # Timeout in seconds that defines how long the mentioned above workaround should go.

#########################################################
### WiFi specific band options
Expand Down
2 changes: 2 additions & 0 deletions packages/lime-system/files/etc/config/lime-defaults
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ config lime wifi
option adhoc_bssid 'ca:fe:00:c0:ff:ee'
option ieee80211s_mesh_fwding '0'
option ieee80211s_mesh_id 'LiMe'
option unstuck_interval '10'
option unstuck_timeout '300'

config lime-wifi-band '2ghz'
option channel '11'
Expand Down
8 changes: 7 additions & 1 deletion packages/lime-system/files/usr/lib/lua/lime/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ end
function config.main()
--! Get mac address and set mac-based configuration file name
local network = require("lime.network")
local utils = require("lime.utils")

config.UCI_MAC_NAME = "lime-" .. table.concat(network.primary_mac(),"")
print("Mac-config: " .. config.UCI_MAC_NAME)

Expand All @@ -203,6 +205,11 @@ function config.main()

local modules_name = { "hardware_detection", "wireless", "network", "firewall", "system",
"generic_config" }

if utils.isModuleAvailable("lime.wifi_unstuck_wa") then
table.insert(modules_name, "wifi_unstuck_wa")
end

local modules = {}

for i, name in pairs(modules_name) do modules[i] = require("lime."..name) end
Expand All @@ -219,7 +226,6 @@ function config.main()
print("executed hook:", hookCmd, os.execute(hookCmd))
end

local utils = require("lime.utils") -- here to break circular require
local cfgpath = config.get_config_path()
--! flush all config changes
local uci = config.get_uci_cursor()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ wu.FREQ_2GHZ_LIST = "2412 2462"
wu.FREQ_5GHZ_LIST = "5180 5240"

-- if iw runs for 5 min, it is likely hanging
wu.TIMEOUT = 300
wu.TIMEOUT = tonumber( config.get("wifi", "unstuck_timeout", 300 ))

function wu.get_stickable_ifaces()
local uci = config.get_uci_cursor()
Expand Down Expand Up @@ -103,4 +103,19 @@ function wu.do_workaround()
wu.wait_and_kill_on_timeout(pid_time_started)
end

function wu.configure()
interval = tonumber( config.get("wifi", "unstuck_interval", -1) )

if interval and interval > 0 then
--! use sed to replace interval in /etc/crontabs/root
io.popen("sed -i 's/\\*\\/\\d\\+ \\* \\* \\* \\* ((wifi-unstuck &> \\/dev\\/"..
"null)&)/*\\/"..interval.." * * * * ((wifi-unstuck \\&> \\/dev\\/null)\\&)/g"..
"' /etc/crontabs/root")
end
end

function wu.clean()
-- nothing to clean, but needs to be declared to comply with the API
end

return wu
2 changes: 1 addition & 1 deletion packages/wifi-unstuck-wa/tests/test_wifi_unstuck.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local config = require 'lime.config'
local test_utils = require 'tests.utils'
local unstuck_wa = require 'wifi_unstuck_wa'
local unstuck_wa = require 'lime.wifi_unstuck_wa'
local iwinfo = require 'iwinfo'
local nixio = require 'nixio'

Expand Down

0 comments on commit 46e52ca

Please sign in to comment.