Merge remote-tracking branch 'Riley-Gitty/main' into main

main
Jason Hawks 1 year ago
commit 743d6cb3ab

@ -13,34 +13,28 @@ m = Map("easymesh",
function detect_Node()
local data = {}
local lps = luci.util.execi(" batctl n 2>/dev/null | tail +2 | sed 's/^[ ][ ]*//g' | sed 's/[ ][ ]*/ /g' | sed 's/$/ /g' ")
for value in lps do
local row = {}
local pos = string.find(value, " ")
local IFA = string.sub(value, 1, pos - 1)
local value = string.sub(value, pos + 1, string.len(value))
pos = string.find(value, " ")
local pos = string.find(value, " ")
local Neighbora = string.sub(value, 1, pos - 1)
local value = string.sub(value, pos + 1, string.len(value))
pos = string.find(value, " ")
local pos = string.find(value, " ")
local lastseena = string.sub(value, 1, pos - 1)
local value = string.sub(value, pos + 1, string.len(value))
pos = string.find(value, " ")
row["IF"] = IFA
row["Neighbor"] = Neighbora
row["lastseen"] = lastseena
table.insert(data, row)
end
return data
local data = {}
-- Streamline the command to retrieve node information
local lps = luci.util.execi("batctl n 2>/dev/null | tail +2 | sed 's/^[ ]*//;s/[ ]*/ /g'")
for line in lps do
-- Split the line into parts using pattern matching
local ifa, neighbor, lastseen = string.match(line, "(%S+) (%S+) (%S+)")
if ifa and neighbor and lastseen then
-- Construct the row and add it to the data table
local row = {["IF"] = ifa, ["Neighbor"] = neighbor, ["lastseen"] = lastseen}
table.insert(data, row)
end
end
return data
end
function get_verbose_hw_info(iface)
local type = iwinfo.type(iface)
if not type then
return "Unknown interface"
return "Generic"
end
local driver = iwinfo[type]
@ -68,17 +62,16 @@ function get_verbose_hw_info(iface)
else
supported_modes_str = table.concat(supported_modes, "/")
end
local verbose_info = hw_name .. " (" .. supported_modes_str .. ")"
return verbose_info
end
local Nodes = luci.sys.exec("batctl n 2>/dev/null| tail +3 | wc -l")
local Node = detect_Node()
v = m:section(Table, Node, "" ,"<b>" .. translate("Active node") .. "" .. Nodes .. "</b>")
v:option(DummyValue, "IF", translate("IF"))
v:option(DummyValue, "Neighbor", translate("Neighbor"))
v:option(DummyValue, "lastseen", translate("lastseen"))
v = m:section(Table, Node, translate("Active Nodes") ,"<b>" .. translate("Number of Active Nodes: ") .. Nodes .. "</b>")
v:option(DummyValue, "IF", translate("Interface"))
v:option(DummyValue, "Neighbor", translate("Neighbor Nodes"))
v:option(DummyValue, "lastseen", translate("Last Seen Timestamp"))
-- Basic
s = m:section(TypedSection, "easymesh", translate("Mesh Gateway & Node WiFi Settings"), translate("Choose Mesh Gateway or Mesh Node WiFi Settings: Begin by completing this section on your mesh server and nodes. Ensure each radio's WiFi network name is consistent. For example: easymesh_AC, easymesh_N."))
@ -111,16 +104,14 @@ s:tab("advanced", translate("Advanced Settings"))
---- Eanble
o = s:taboption("setup", Flag, "enabled", translate("Enable"))
o.default = 0
o.rmempty = false
-- Move basic settings under the "Setup" tab
o = s:taboption("setup", ListValue, "role", translate("Mesh Mode"))
o:value("off", translate("Node"))
o:value("server", translate("Server"))
o:value("off", translate("Node"))
o.default = "server"
--o:value("client", translate("Client (advanced)"))
o:depends("enabled", 1)
o.rmempty = false
apRadio = s:taboption("setup", MultiValue, "apRadio", translate("Mesh Radio(s)"))
@ -132,43 +123,36 @@ uci:foreach("wireless", "wifi-device",
apRadio:value(iface, desc) -- Display radio interface with its hardware modes
end)
apRadio.default = "radio0"
apRadio:depends("enabled", 1)
apRadio.rmempty = false
apRadio.widget = "select"
o = s:taboption("setup", Value, "mesh_id", translate("Mesh SSID"))
o.default = "easymesh_AC"
o:depends("enabled", 1)
encryption = s:taboption("setup", Flag, "encryption", translate("Encryption WIP DROPDOWN"), translate(""))
encryption = s:taboption("setup", Flag, "encryption", translate("Enable Password"), translate(""))
encryption.default = 0
encryption.rmempty = false
encryption:depends("enabled", 1)
o = s:taboption("setup", Value, "key", translate("Mesh Password"))
o.default = "easymesh"
o:depends({enabled = "1", encryption = "1"})
o:depends("encryption", 1)
o.password = true
-- Move K/V/R settings to the "Advanced" tab
enable_kvr = s:taboption("advanced", Flag, "kvr", translate("K/V/R"), translate("Enable Key Value Roaming"))
enable_kvr.default = 1
enable_kvr.rmempty = false
mobility_domain = s:taboption("advanced", Value, "mobility_domain", translate("Mobility Domain"), translate("4-character hexadecimal ID"))
mobility_domain.default = "4f57"
--mobility_domain.datatype = "and(hexstring,rangelength(4,4))"
mobility_domain:depends("kvr", 1)
rssi_val = s:taboption("advanced", Value, "rssi_val", translate("Threshold for a good RSSI"))
rssi_val.default = "-60"
--rssi_val.datatype = "range(-1,-120)"
rssi_val:depends("kvr", 1)
low_rssi_val = s:taboption("advanced", Value, "low_rssi_val", translate("Threshold for a bad RSSI"))
low_rssi_val.default = "-88"
--low_rssi_val.datatype = "range(-1,-120)"
low_rssi_val:depends("kvr", 1)
---- Apply MESH settings
@ -204,47 +188,44 @@ o:value("node9", "node9")
o.datatype = "string"
o:depends("role", "off")
btnAPMode = s:taboption("apmode", Button, "_btn_apmode", translate("Join Mesh Network"), translate("WARNING: THIS WILL CHANGE THIS NODE'S IP ADDRESS, YOU WILL LOOSE ACCESS TO THIS UI"))
-- IP Mode (DHCP or Static)
ipmode = s:taboption("apmode", ListValue, "ipmode", translate("IP Mode"), translate("Choose if the node uses DHCP or a Static IP"))
ipmode:value("dhcp", translate("DHCP"))
ipmode:value("static", translate("Static"))
ipmode.default = "dhcp"
ipmode:depends("role", "off")
-- Static IP address
o = s:taboption("apmode", Value, "ipaddr", translate("Static IP Address"))
o.default = "192.168.70.254"
o.datatype = "ip4addr"
o:depends({ipmode="static",role="off"})
-- DNS (Mesh Gateway IP Address)
o = s:taboption("apmode", Value, "gatewayIP", translate("Mesh Gateway IP Address"))
o.default = "192.168.70.1"
o.datatype = "ip4addr"
o:depends({ipmode="static",role="off"})
-- IPv4 netmask
o = s:taboption("apmode", Value, "netmask", translate("IPv4 netmask"))
o.default = "255.255.255.0"
o.datatype = "ip4addr"
o:depends({ipmode="static",role="off"})
btnAPMode = s:taboption("apmode", Button, "_btn_apmode", translate("Enable Dumb AP Mode"), translate("WARNING: THIS WILL CHANGE THIS NODE'S IP ADDRESS, YOU WILL LOOSE ACCESS TO THIS UI"))
function btnAPMode.write()
io.popen("/easymesh/easymesh.sh dumbap &")
luci.sys.call("/easymesh/dumbap.sh")
end
btnAPMode:depends("role", "off")
---- ip address
--o = s:option(Value, "ipaddr", translate("Static IP Address"))
--o.default = "192.168.8.2"
--o.datatype = "ip4addr"
--o:depends("ap_mode", 1)
-- o = s:option(Value, "dns", translate("Mesh Gateway IP Address"))
-- o.default = "192.168.8.1"
-- o.datatype = "ip4addr"
-- o:depends("ap_mode", 1)
-- o = s:option(Value, "netmask", translate("IPv4 netmask"))
-- o.default = "255.255.255.0"
-- o.datatype = "ip4addr"
-- o:depends("ap_mode", 1)
-- MESH Node Control: apply mesh settings
ctrl = m:section(TypedSection, "easymesh", "Click Save Then Enable or Disable Your Mesh WiFi settings")
ctrl.anonymous = true
ctrl.addremove = false
function m.on_after_commit(self)
local enabled = m:formvalue("cbid.easymesh.easymesh.enabled")
m.on_before_apply = function(self)
local enabled = m:formvalue("cbid.easymesh.config.enabled")
if enabled and enabled == "1" then
luci.sys.call("/easymesh/easymesh.sh &")
luci.sys.call("/easymesh/easymesh.sh enable &")
else
luci.sys.call("/easymesh/easymesh.sh &")
luci.sys.call("/easymesh/easymesh.sh disable &")
end
end
function o.write(self, section, value)
Flag.write(self, section, value)
-- Run init start
-- luci.sys.call("uci commit")
-- luci.sys.call("/etc/init.d/easymesh start &")
end
return m

@ -410,14 +410,17 @@ disable_easymesh() {
uci del easymesh.config.running
}
if [ "$1" = "dumbap" ]; then
sleep 5
if [ "$1" = "enable" ]; then
enable_easymesh
exit 0
elif [ "$1" = "disable" ]; then
disable_easymesh
exit 0
elif [ "$1" = "dumbap" ]; then
set_apmode
exit 0
fi
# Check if enabled
if [ "$(uci -q get easymesh.config.enabled)" = 1 ]; then
enable_easymesh
else
disable_easymesh
echo "Invalid argument. Please use 'start', 'stop' or 'dumbap'"
exit 1
fi

Loading…
Cancel
Save