mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-31 02:17:58 +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 uci = libuci.cursor(); | ||||||
| let config; | let config; | ||||||
| let offline_timer; | let offline_timer; | ||||||
|  | let current_state; | ||||||
|  |  | ||||||
| function self_healing() { | function self_healing() { | ||||||
|  |  | ||||||
| @@ -74,8 +75,9 @@ function offline_handler() { | |||||||
| function online_handler() { | function online_handler() { | ||||||
| 	ulog(LOG_INFO, 'going online\n'); | 	ulog(LOG_INFO, 'going online\n'); | ||||||
| 	ubus.call('network.interface.admin_ui', 'down'); | 	ubus.call('network.interface.admin_ui', 'down'); | ||||||
| 	if (offline_timer) | 	if (offline_timer) { | ||||||
| 		offline_timer.cancel(); | 		offline_timer.cancel(); | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| function config_load() { | function config_load() { | ||||||
| @@ -175,8 +177,11 @@ let state_handler = { | |||||||
| let ubus_methods = { | let ubus_methods = { | ||||||
| 	set: { | 	set: { | ||||||
| 		call: function(req) { | 		call: function(req) { | ||||||
|  | 			if (current_state == req.args.state) | ||||||
|  | 				return; | ||||||
| 			if (!state_handler[req.args.state]) | 			if (!state_handler[req.args.state]) | ||||||
| 				return ubus.STATUS_INVALID_ARGUMENT; | 				return ubus.STATUS_INVALID_ARGUMENT; | ||||||
|  | 			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
	 John Crispin
					John Crispin