mirror of https://github.com/aredn/aredn.git
Link led fixes (#212)
This commit is contained in:
parent
ce4f694563
commit
1ddedbb1e6
|
@ -134,26 +134,59 @@ function hardware.get_iface_name(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
function hardware.get_link_led()
|
function hardware.get_link_led()
|
||||||
local led = xpcall(
|
local err, result = xpcall(
|
||||||
function() return "/sys/class/leds/" .. hardware.get_board().led.rssilow.sysfs end,
|
function()
|
||||||
|
local led = hardware.get_board().led
|
||||||
|
if led then
|
||||||
|
if led.rssilow and led.rssilow.sysfs then
|
||||||
|
return "/sys/class/leds/" .. led.rssilow.sysfs
|
||||||
|
end
|
||||||
|
if led.user and led.user.sysfs then
|
||||||
|
return "/sys/class/leds/" .. led.user.sysfs
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Exceptions -
|
||||||
|
-- This is here to handle poor board definitions. We can remove these when board definitions are updated
|
||||||
|
local board_type = aredn.hardware.get_type()
|
||||||
|
if board_type == "airrouter" then
|
||||||
|
return "/sys/class/leds/ubnt:green:globe"
|
||||||
|
elseif board_type == "gl-ar150" then
|
||||||
|
return "/sys/class/leds/gl-ar150:orange:wlan"
|
||||||
|
elseif board_type == "gl-ar300m" then
|
||||||
|
return "/sys/class/leds/gl-ar300m:green:wlan"
|
||||||
|
elseif board_type == "gl-usb150" then
|
||||||
|
return "/sys/class/leds/gl-usb150:green:wlan"
|
||||||
|
elseif board_type == "gl-ar750" then
|
||||||
|
return "/sys/class/leds/gl-ar750:white:wlan5g"
|
||||||
|
elseif board_type == "rb-912uag-5hpnd" or board_type == "rb-911g-5hpnd" then
|
||||||
|
return "/sys/class/leds/rb:green:led1"
|
||||||
|
elseif board_type == "rb-lhg-5nd" or "rb-lhg-5hpnd" or "rb-lhg-5hpnd-xl" or "rb-ldf-5nd" then
|
||||||
|
return "/sys/class/leds/rb:green:rssi0"
|
||||||
|
end
|
||||||
|
--
|
||||||
|
return nil
|
||||||
|
end,
|
||||||
function()
|
function()
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
function hardware.has_poe()
|
function hardware.has_poe()
|
||||||
return xpcall(
|
local err, result = xpcall(
|
||||||
function() return hardware.get_board().gpioswitch.poe_passthrough.pin or true end,
|
function() return hardware.get_board().gpioswitch.poe_passthrough.pin or true end,
|
||||||
function() return false end
|
function() return false end
|
||||||
)
|
)
|
||||||
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
function hardware.has_usb()
|
function hardware.has_usb()
|
||||||
return xpcall(
|
local err, result = xpcall(
|
||||||
function() return hardware.get_board().gpioswitch.usb_power_switch.pin or true end,
|
function() return hardware.get_board().gpioswitch.usb_power_switch.pin or true end,
|
||||||
function() return false end
|
function() return false end
|
||||||
)
|
)
|
||||||
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
function hardware.get_rfband()
|
function hardware.get_rfband()
|
||||||
|
|
|
@ -43,17 +43,25 @@ function linkled()
|
||||||
else
|
else
|
||||||
-- Reset leds
|
-- Reset leds
|
||||||
write_all(link .. "/trigger", "none")
|
write_all(link .. "/trigger", "none")
|
||||||
write_all(link .. "/brightness", "0")
|
write_all(link .. "/brightness", "1")
|
||||||
|
|
||||||
|
-- Wait for 2 minutes before monitoring status. During this time the led is on
|
||||||
|
wait_for_ticks(120)
|
||||||
|
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
local nei = fetch_json("http://127.0.0.1:9090/neighbors")
|
local nei = fetch_json("http://127.0.0.1:9090/neighbors")
|
||||||
if nei and #nei.neighbors > 0 then
|
if nei and #nei.neighbors > 0 then
|
||||||
|
-- Led on when link established. Retest every 10 seconds
|
||||||
write_all(link .. "/brightness", "1")
|
write_all(link .. "/brightness", "1")
|
||||||
|
wait_for_ticks(10)
|
||||||
else
|
else
|
||||||
|
-- Flash led slowly - off 3 seconds, on 3 seconds - when no links
|
||||||
write_all(link .. "/brightness", "0")
|
write_all(link .. "/brightness", "0")
|
||||||
|
wait_for_ticks(3)
|
||||||
|
write_all(link .. "/brightness", "1")
|
||||||
|
wait_for_ticks(3)
|
||||||
end
|
end
|
||||||
wait_for_ticks(11)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue