Api add tactical name (#139)

This commit is contained in:
dman776 2021-09-09 08:32:24 -05:00 committed by GitHub
parent 7908c3e2d4
commit c179ce40b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 11 deletions

View File

@ -89,6 +89,14 @@ function model.getNodeName()
return css[1]['hostname']
end
-------------------------------------
-- Returns tactical name of the node
-------------------------------------
function model.getTacticalName()
css=aredn_uci.getNonStandardUciConfType("/etc/local/uci/", "hsmmmesh", "settings")
return css[1]['tactical']
end
-------------------------------------
-- Returns description of the node
-------------------------------------

View File

@ -50,4 +50,12 @@ function api.getUciConfSectionOption(conf,sect,option)
return curs:get(conf,sect,option)
end
function api.getNonStandardUciConfType(dir, conf,type)
local curs=uci.cursor(dir)
local ifce={}
curs:foreach(conf,type,function(s) table.insert(ifce,s) end)
return ifce
end
return api

View File

@ -289,6 +289,7 @@ function getTraceroute(target)
for i,v in pairs(lines) do
data = v:splitWhiteSpace()
entry = {}
if data[2] ~= "*" then
node = data[2]:gsub("^mid[0-9]*%.","") -- strip midXX.
node = node:gsub("^dtdlink%.","") -- strip dtdlink.
node = node:gsub("%.local%.mesh$","") -- strip .local.mesh
@ -300,6 +301,7 @@ function getTraceroute(target)
priortime = round2(data[4])
table.insert(routes, entry)
end
end
return routes
end

View File

@ -44,7 +44,7 @@ require("nixio")
local json = require("luci.jsonc")
require("iwinfo")
local API_VERSION="1.2"
local API_VERSION="1.3"
-- Function extensions
os.capture = capture
@ -54,6 +54,7 @@ function getSysinfo()
local info={}
info['api_version']=API_VERSION
info['node']=aredn_info.getNodeName()
info['tactical']=aredn_info.getTacticalName()
info['description']=aredn_info.getNodeDescription()
info['firmware_version']=aredn_info.getFirmwareVersion()
info['model']=aredn_info.getModel()