mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-11-02 03:17:48 +00:00
ucentral-state: add admin_ui support
Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
@@ -0,0 +1,109 @@
|
|||||||
|
{
|
||||||
|
"uuid": 2,
|
||||||
|
"radios": [
|
||||||
|
{
|
||||||
|
"band": "2G",
|
||||||
|
"country": "US",
|
||||||
|
"channel-mode": "HE",
|
||||||
|
"channel-width": 20,
|
||||||
|
"channel": 1
|
||||||
|
}, {
|
||||||
|
"band": "5G",
|
||||||
|
"country": "US",
|
||||||
|
"channel-mode": "HE",
|
||||||
|
"channel-width": 80,
|
||||||
|
"channel": 36
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"interfaces": [
|
||||||
|
{
|
||||||
|
"name": "WAN",
|
||||||
|
"role": "upstream",
|
||||||
|
"services": [ "lldp" ],
|
||||||
|
"ethernet": [
|
||||||
|
{
|
||||||
|
"select-ports": [
|
||||||
|
"WAN*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ipv4": {
|
||||||
|
"addressing": "dynamic"
|
||||||
|
},
|
||||||
|
"ssids": [
|
||||||
|
{
|
||||||
|
"name": "OpenWifi",
|
||||||
|
"wifi-bands": [
|
||||||
|
"2G"
|
||||||
|
],
|
||||||
|
"bss-mode": "ap",
|
||||||
|
"encryption": {
|
||||||
|
"proto": "psk2",
|
||||||
|
"key": "OpenWifi",
|
||||||
|
"ieee80211w": "optional"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "LAN",
|
||||||
|
"role": "downstream",
|
||||||
|
"services": [ "ssh", "lldp" ],
|
||||||
|
"ethernet": [
|
||||||
|
{
|
||||||
|
"select-ports": [
|
||||||
|
"LAN*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ipv4": {
|
||||||
|
"addressing": "static",
|
||||||
|
"subnet": "192.168.1.1/24",
|
||||||
|
"dhcp": {
|
||||||
|
"lease-first": 10,
|
||||||
|
"lease-count": 100,
|
||||||
|
"lease-time": "6h"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ssids": [
|
||||||
|
{
|
||||||
|
"name": "OpenWifi",
|
||||||
|
"wifi-bands": [
|
||||||
|
"2G"
|
||||||
|
],
|
||||||
|
"bss-mode": "ap",
|
||||||
|
"encryption": {
|
||||||
|
"proto": "psk2",
|
||||||
|
"key": "OpenWifi",
|
||||||
|
"ieee80211w": "optional"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metrics": {
|
||||||
|
"statistics": {
|
||||||
|
"interval": 120,
|
||||||
|
"types": [ "ssids", "lldp", "clients" ]
|
||||||
|
},
|
||||||
|
"health": {
|
||||||
|
"interval": 120
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"services": {
|
||||||
|
"lldp": {
|
||||||
|
"describe": "uCentral",
|
||||||
|
"location": "universe"
|
||||||
|
},
|
||||||
|
"ssh": {
|
||||||
|
"port": 22
|
||||||
|
},
|
||||||
|
"admin-ui": {
|
||||||
|
"wifi-ssid": "Maverick",
|
||||||
|
"wifi-key": "aaaaaaaa",
|
||||||
|
"offline-trigger": 60
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,12 +5,13 @@
|
|||||||
"band": "2G",
|
"band": "2G",
|
||||||
"country": "US",
|
"country": "US",
|
||||||
"channel-mode": "HE",
|
"channel-mode": "HE",
|
||||||
"channel-width": 40
|
"channel-width": 20
|
||||||
}, {
|
}, {
|
||||||
"band": "5G",
|
"band": "5G",
|
||||||
"country": "US",
|
"country": "US",
|
||||||
"channel-mode": "HE",
|
"channel-mode": "HE",
|
||||||
"channel-width": 80
|
"channel-width": 80,
|
||||||
|
"channel": 36
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -68,6 +69,11 @@
|
|||||||
"services": {
|
"services": {
|
||||||
"ssh": {
|
"ssh": {
|
||||||
"port": 22
|
"port": 22
|
||||||
|
},
|
||||||
|
"admin-ui": {
|
||||||
|
"wifi-ssid": "Maverick",
|
||||||
|
"wifi-bands": [ "5G" ],
|
||||||
|
"offline-trigger": 30,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ define Package/ucentral-state/install
|
|||||||
$(INSTALL_BIN) ./files/ucentral-state $(1)/usr/sbin/
|
$(INSTALL_BIN) ./files/ucentral-state $(1)/usr/sbin/
|
||||||
$(INSTALL_BIN) ./files/ucentral-pstore $(1)/usr/sbin/
|
$(INSTALL_BIN) ./files/ucentral-pstore $(1)/usr/sbin/
|
||||||
$(INSTALL_BIN) ./files/ucentral-state.init $(1)/etc/init.d/ucentral-state
|
$(INSTALL_BIN) ./files/ucentral-state.init $(1)/etc/init.d/ucentral-state
|
||||||
|
$(INSTALL_BIN) ./files/ucentral-state.config $(1)/etc/config/state
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call BuildPackage,ucentral-state))
|
$(eval $(call BuildPackage,ucentral-state))
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ uloop.init();
|
|||||||
let ubus = libubus.connect();
|
let ubus = libubus.connect();
|
||||||
let uci = libuci.cursor();
|
let uci = libuci.cursor();
|
||||||
let config;
|
let config;
|
||||||
|
let offline_timer;
|
||||||
|
|
||||||
|
function self_healing() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
let healthcheck;
|
let healthcheck;
|
||||||
healthcheck = {
|
healthcheck = {
|
||||||
@@ -31,6 +36,7 @@ healthcheck = {
|
|||||||
complete: function() {
|
complete: function() {
|
||||||
printf('healtcheck completed\n');
|
printf('healtcheck completed\n');
|
||||||
healthcheck.run(healthcheck.delay);
|
healthcheck.run(healthcheck.delay);
|
||||||
|
self_healing();
|
||||||
},
|
},
|
||||||
|
|
||||||
spawn: function() {
|
spawn: function() {
|
||||||
@@ -63,11 +69,31 @@ state = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function offline_handler() {
|
||||||
|
printf('going offline\n');
|
||||||
|
ubus.call('network.interface.admin_ui', 'up');
|
||||||
|
}
|
||||||
|
|
||||||
|
function online_handler() {
|
||||||
|
printf('going online\n');
|
||||||
|
ubus.call('network.interface.admin_ui', 'down');
|
||||||
|
if (offline_timer)
|
||||||
|
offline_timer.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
function config_load() {
|
function config_load() {
|
||||||
uci.load('ustats');
|
printf('loading config\n');
|
||||||
config = uci.get_all('ustats');
|
uci.load('state');
|
||||||
|
config = uci.get_all('state');
|
||||||
|
|
||||||
healthcheck.run((config?.health?.interval || 0) * 1000);
|
healthcheck.run((config?.health?.interval || 0) * 1000);
|
||||||
state.run((config?.stats?.interval || 0) * 1000);
|
state.run((config?.stats?.interval || 0) * 1000);
|
||||||
|
|
||||||
|
let status = ubus.call('ucentral', 'status');
|
||||||
|
if (status?.connected)
|
||||||
|
online_handler();
|
||||||
|
else if (config.ui.offline_trigger)
|
||||||
|
offline_timer = uloop.timer(config.ui.offline_trigger * 1000, offline_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
function led_write(led, property, value) {
|
function led_write(led, property, value) {
|
||||||
@@ -105,11 +131,13 @@ function blink_timeout() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let state_handler = {
|
let state_handler = {
|
||||||
connect: function() {
|
offline: function() {
|
||||||
let led = led_find('led-running');
|
let led = led_find('led-running');
|
||||||
if (!led)
|
if (!led)
|
||||||
return ubus.STATUS_INVALID_ARGUMENT;
|
return ubus.STATUS_INVALID_ARGUMENT;
|
||||||
led_write(led, 'trigger', 'heartbeat');
|
led_write(led, 'trigger', 'heartbeat');
|
||||||
|
if (config.ui.offline_trigger)
|
||||||
|
offline_timer = uloop.timer(config.ui.offline_trigger * 1000, offline_handler);
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -118,6 +146,7 @@ let state_handler = {
|
|||||||
if (!led)
|
if (!led)
|
||||||
return ubus.STATUS_INVALID_ARGUMENT;
|
return ubus.STATUS_INVALID_ARGUMENT;
|
||||||
led_write(led, 'trigger', 'default-on');
|
led_write(led, 'trigger', 'default-on');
|
||||||
|
online_handler();
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -168,5 +197,6 @@ let ubus_methods = {
|
|||||||
|
|
||||||
ubus.publish('state', ubus_methods);
|
ubus.publish('state', ubus_methods);
|
||||||
config_load();
|
config_load();
|
||||||
|
|
||||||
uloop.run();
|
uloop.run();
|
||||||
uloop.done();
|
uloop.done();
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
config admin ui
|
||||||
|
|
||||||
|
config stats stats
|
||||||
|
option interval 600
|
||||||
|
|
||||||
|
config health health
|
||||||
|
option interval 120
|
||||||
Reference in New Issue
Block a user