mirror of https://github.com/aredn/aredn.git
Improve LQM distance management 02/11/2023 (#705)
This commit is contained in:
parent
160345187d
commit
c70a23f7a8
|
@ -247,6 +247,7 @@ function lqm()
|
||||||
local dtdlinks = {}
|
local dtdlinks = {}
|
||||||
local rflinks = {}
|
local rflinks = {}
|
||||||
local hidden_nodes = {}
|
local hidden_nodes = {}
|
||||||
|
local last_coverage = -1
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
now = nixio.sysinfo().uptime
|
now = nixio.sysinfo().uptime
|
||||||
|
@ -506,10 +507,6 @@ function lqm()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local distance = -1
|
|
||||||
local alt_distance = -1
|
|
||||||
local coverage = -1
|
|
||||||
|
|
||||||
-- Count the RF links we have
|
-- Count the RF links we have
|
||||||
local rfcount = 0
|
local rfcount = 0
|
||||||
for _, track in pairs(tracker)
|
for _, track in pairs(tracker)
|
||||||
|
@ -816,6 +813,8 @@ function lqm()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local distance = -1
|
||||||
|
|
||||||
-- Update the block state and calculate the routable distance
|
-- Update the block state and calculate the routable distance
|
||||||
for _, track in pairs(tracker)
|
for _, track in pairs(tracker)
|
||||||
do
|
do
|
||||||
|
@ -825,16 +824,14 @@ function lqm()
|
||||||
track.pending = now + pending_timeout
|
track.pending = now + pending_timeout
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Find the most distant, unblocked, routable, RF node
|
-- Find the most distant, unblocked, RF node
|
||||||
if track.type == "RF" and not track.blocked and track.distance then
|
if track.type == "RF" then
|
||||||
if not is_pending(track) and track.routable then
|
if track.distance then
|
||||||
if track.distance > distance then
|
if track.distance > distance and (not track.blocked or is_pending(track)) then
|
||||||
distance = track.distance
|
distance = track.distance
|
||||||
end
|
end
|
||||||
else
|
elseif is_pending(track) then
|
||||||
if track.distance > alt_distance then
|
distance = config.max_distance
|
||||||
alt_distance = track.distance
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -846,20 +843,19 @@ function lqm()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
distance = distance + 1
|
-- Default distances if we haven't calcuated anything
|
||||||
alt_distance = alt_distance + 1
|
if distance < 0 then
|
||||||
|
if config.auto_distance > 0 then
|
||||||
|
distance = config.auto_distance
|
||||||
|
else
|
||||||
|
distance = config.max_distance
|
||||||
|
end
|
||||||
|
end
|
||||||
-- Update the wifi distance
|
-- Update the wifi distance
|
||||||
if distance > 0 then
|
local coverage = math.min(255, math.floor((distance * 2 * 0.0033) / 3))
|
||||||
coverage = math.min(255, math.floor((distance * 2 * 0.0033) / 3)) -- airtime
|
if coverage ~= last_coverage then
|
||||||
os.execute(IW .. " " .. phy .. " set coverage " .. coverage .. " > /dev/null 2>&1")
|
os.execute(IW .. " " .. phy .. " set coverage " .. coverage .. " > /dev/null 2>&1")
|
||||||
elseif alt_distance > 1 then
|
last_coverage = coverage
|
||||||
coverage = math.min(255, math.floor((alt_distance * 2 * 0.0033) / 3))
|
|
||||||
os.execute(IW .. " " .. phy .. " set coverage " .. coverage .. " > /dev/null 2>&1")
|
|
||||||
elseif config.auto_distance > 0 then
|
|
||||||
os.execute(IW .. " " .. phy .. " set distance " .. config.auto_distance .. " > /dev/null 2>&1")
|
|
||||||
else
|
|
||||||
os.execute(IW .. " " .. phy .. " set distance auto > /dev/null 2>&1")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set the RTS/CTS state depending on whether everyone can see everyone
|
-- Set the RTS/CTS state depending on whether everyone can see everyone
|
||||||
|
|
Loading…
Reference in New Issue