Skip to content

Commit

Permalink
gluon-web-network: support handling of active-low PoE passthrough
Browse files Browse the repository at this point in the history
The Aruba AP-303H offers a switchable PSE output on ETH3. The power
state is controlled using a GPIO pin like seen on CPE210 and Nanostation
alike.

However, the PSE state is active low, which the current code handles as
"Enable PoE Passthrough disable". This is not intuitive, thus support
the active low case in the Gluon Web-UI.

Signed-off-by: David Bauer <[email protected]>
  • Loading branch information
blocktrron committed Dec 12, 2024
1 parent b180fc2 commit d50679a
Showing 1 changed file with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,28 @@ uci:foreach("system", "gpio_switch", function(si)
end

local texts = {
["^PoE Power Port(%d*)$"] = function(m) return translatef("Enable PoE Power Port %s", m[1]) end,
["^PoE Passthrough$"] = function() return translate("Enable PoE Passthrough") end,
["^PoE Power Port(%d*)$"] = {
get_title = function(m) return translatef("Enable PoE Power Port %s", m[1]) end,
active_low = false,
},
["^PoE Passthrough$"] = {
get_title = function() return translate("Enable PoE Passthrough") end,
active_low = false,
},
-- Typo in AP-303H (ipq40xx-generic)
["^POE passtrough disable$"] = {
get_title = function() return translate("Enable PoE Passthrough") end,
active_low = true,
},
}

local name
for pattern, func in pairs(texts) do
local active_low = false
for pattern, text_obj in pairs(texts) do
local match = {si.name:match(pattern)}
if match[1] then
name = func(match)
name = text_obj.get_title(match)
active_low = text_obj.active_low
break
end
end
Expand All @@ -120,9 +133,17 @@ uci:foreach("system", "gpio_switch", function(si)

local poe = section:option(Flag, si[".name"], name)
poe.default = uci:get_bool("system", si[".name"], "value")
if active_low then
poe.default = not poe.default
end

function poe:write(data)
uci:set("system", si[".name"], "value", data)
local write_value = data

if active_low then
write_value = not write_value
end
uci:set("system", si[".name"], "value", write_value)
end
end
end)
Expand Down

0 comments on commit d50679a

Please sign in to comment.