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