bugfix: aredn sysinfo.json fails with mesh rf off

added json meshrf->status->on/off
fixes:  #317
This commit is contained in:
Joe Ayers 2018-12-22 09:26:31 -08:00 committed by Joe AE6XE
parent 27f4356a46
commit 6728fba06b
1 changed files with 15 additions and 10 deletions

View File

@ -84,11 +84,16 @@ info['node_details']['firmware_mfg']=fw_mfg
info['node_details']['firmware_version']=getFirmwareVersion() info['node_details']['firmware_version']=getFirmwareVersion()
-- Mesh RF info -- Mesh RF info
info["meshrf"]={} info['meshrf']={}
info["meshrf"]["ssid"]=getSSID()
local radio=getMeshRadioDevice() local radio=getMeshRadioDevice()
info["meshrf"]["channel"]=getChannel(radio) if ( radio ~= nill and radio ~= "" ) then
info["meshrf"]['chanbw']=getChannelBW(radio) info['meshrf']['status']="on"
info['meshrf']['ssid']=getSSID()
info['meshrf']['channel']=getChannel(radio)
info['meshrf']['chanbw']=getChannelBW(radio)
else
info['meshrf']['status']="off"
end
-- Tunnel info -- Tunnel info
info['tunnels']={} info['tunnels']={}
@ -97,11 +102,11 @@ local tunnel_installed=false
if file_exists("/usr/sbin/vtund") then if file_exists("/usr/sbin/vtund") then
tunnel_installed="true" tunnel_installed="true"
end end
info['tunnels']["tunnel_installed"]=tunnel_installed info['tunnels']['tunnel_installed']=tunnel_installed
-- ACTIVE TUNNELS -- ACTIVE TUNNELS
local atc="" local atc=""
atc=os.capture("ifconfig|grep tun|wc -l") atc=os.capture("ifconfig|grep tun|wc -l")
info['tunnels']["active_tunnel_count"]=atc:chomp() info['tunnels']['active_tunnel_count']=atc:chomp()
-- Location info -- Location info
-- LAT/LON -- LAT/LON
@ -110,7 +115,7 @@ info['lat']=lat
info['lon']=lon info['lon']=lon
-- GRID SQUARE -- GRID SQUARE
info["grid_square"]=getGridSquare() info['grid_square']=getGridSquare()
-- UPTIME AND LOADAVGS -- UPTIME AND LOADAVGS
mynix=nixio.sysinfo() mynix=nixio.sysinfo()
@ -140,7 +145,7 @@ for pos, i in pairs(ift) do
table.insert(tif,nim) table.insert(tif,nim)
end end
end end
info["interfaces"]=tif info['interfaces']=tif
-- HOSTS -- HOSTS
if string.find(nixio.getenv("QUERY_STRING"):lower(),"hosts=1") then if string.find(nixio.getenv("QUERY_STRING"):lower(),"hosts=1") then
@ -177,7 +182,7 @@ if string.find(nixio.getenv("QUERY_STRING"):lower(),"hosts=1") then
host['error']="Cannot read hosts file" host['error']="Cannot read hosts file"
table.insert(hosts,host) table.insert(hosts,host)
end end
info["hosts"]=hosts info['hosts']=hosts
end end
-- SERVICES -- SERVICES
@ -205,7 +210,7 @@ if string.find(nixio.getenv("QUERY_STRING"):lower(),"services=1") then
service['error']="Cannot read services file" service['error']="Cannot read services file"
table.insert(services,service) table.insert(services,service)
end end
info["services"]=services info['services']=services
end end
-- LOCALLY HOSTED SERVICES ONLY -- LOCALLY HOSTED SERVICES ONLY