mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-30 01:52:51 +00:00
ucentral-state: improve led blink handling
Fixes: WIFI-14194 Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
@@ -138,14 +138,14 @@ function factory_reset_timeout() {
|
|||||||
|
|
||||||
let blink_timer;
|
let blink_timer;
|
||||||
function blink_timeout() {
|
function blink_timeout() {
|
||||||
if (!blink_timer)
|
|
||||||
return;
|
|
||||||
blink_timer.cancel();
|
|
||||||
blink_timer = null;
|
|
||||||
if (current_state == 'blink') {
|
if (current_state == 'blink') {
|
||||||
current_state = 'online';
|
current_state = 'online';
|
||||||
}
|
}
|
||||||
system('/etc/init.d/led turnon');
|
system('/etc/init.d/led turnon');
|
||||||
|
if (!blink_timer)
|
||||||
|
return;
|
||||||
|
blink_timer.cancel();
|
||||||
|
blink_timer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let state_handler = {
|
let state_handler = {
|
||||||
@@ -183,8 +183,13 @@ let state_handler = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
blink: function(args) {
|
blink: function(args) {
|
||||||
|
if (!args.duration) {
|
||||||
|
blink_timeout();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
system('/etc/init.d/led blink');
|
system('/etc/init.d/led blink');
|
||||||
blink_timer = uloop.timer((args.duration || 10) * 1000, blink_timeout);
|
if (args.duration != 0xffff)
|
||||||
|
blink_timer = uloop.timer((args.duration || 10) * 1000, blink_timeout);
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -193,10 +198,12 @@ let ubus_methods = {
|
|||||||
set: {
|
set: {
|
||||||
call: function(req) {
|
call: function(req) {
|
||||||
ulog(LOG_INFO, 'state %s -> %s\n', current_state, req.args.state);
|
ulog(LOG_INFO, 'state %s -> %s\n', current_state, req.args.state);
|
||||||
if (current_state == req.args.state)
|
if (current_state == req.args.state && req.args.state != 'blink')
|
||||||
return;
|
return;
|
||||||
if (!state_handler[req.args.state])
|
if (!state_handler[req.args.state])
|
||||||
return ubus.STATUS_INVALID_ARGUMENT;
|
return ubus.STATUS_INVALID_ARGUMENT;
|
||||||
|
if (current_state != req.args.state)
|
||||||
|
ulog(LOG_INFO, 'state %s -> %s\n', current_state, req.args.state);
|
||||||
current_state = req.args.state;
|
current_state = req.args.state;
|
||||||
blink_timeout();
|
blink_timeout();
|
||||||
ulog(LOG_INFO, 'set state -> ' + req.args.state + '\n');
|
ulog(LOG_INFO, 'set state -> ' + req.args.state + '\n');
|
||||||
|
|||||||
Reference in New Issue
Block a user