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

gluon-web-network: support handling of active-low PoE passthrough #3355

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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*)$"] = {
["func"] = function(m) return translatef("Enable PoE Power Port %s", m[1]) end,
["active_low"] = false,
},
["^PoE Passthrough$"] = {
["func"] = function() return translate("Enable PoE Passthrough") end,
["active_low"] = false,
},
-- Typo in AP-303H (ipq40xx-generic)
["^POE passtrough disable$"] = {
["func"] = 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.func(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