mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-29 17:42:41 +00:00
ucentral-state: properly track online state
Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
@@ -18,6 +18,7 @@ let ubus = libubus.connect();
|
||||
let uci = libuci.cursor();
|
||||
let config;
|
||||
let offline_timer;
|
||||
let current_state;
|
||||
|
||||
function self_healing() {
|
||||
|
||||
@@ -74,8 +75,9 @@ function offline_handler() {
|
||||
function online_handler() {
|
||||
ulog(LOG_INFO, 'going online\n');
|
||||
ubus.call('network.interface.admin_ui', 'down');
|
||||
if (offline_timer)
|
||||
if (offline_timer) {
|
||||
offline_timer.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
function config_load() {
|
||||
@@ -175,8 +177,11 @@ let state_handler = {
|
||||
let ubus_methods = {
|
||||
set: {
|
||||
call: function(req) {
|
||||
if (current_state == req.args.state)
|
||||
return;
|
||||
if (!state_handler[req.args.state])
|
||||
return ubus.STATUS_INVALID_ARGUMENT;
|
||||
current_state = req.args.state;
|
||||
blink_timeout();
|
||||
ulog(LOG_INFO, 'set state -> ' + req.args.state + '\n');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user