Developing lightweight computation at the DSG edge

Commit 0747c836 authored by Pau Escrich's avatar Pau Escrich
Browse files

Add latitude/longitude/elevation/contact fields to the node basic configuration web interface

Geoposition data is syncronized with libremap-agent if enabled
parent 87070dc0
......@@ -36,7 +36,15 @@ config 'qmp' 'node'
# Temporay key file for session (autogenerated in each boot).
option key '/tmp/qmp_key'
# Map information
option elevation '0'
option latitude '0.0'
option longitude '0.0'
# Contact information (e-mail)
option contact 'admin@qmp.cat'
# -----------------------------
# Node services to be started
# -----------------------------
......
......@@ -38,6 +38,9 @@ qmp_configure_system() {
# configuring hosts
qmp_set_hosts
# configure maps
qmp_set_maps
}
qmp_set_hosts() {
......@@ -58,6 +61,24 @@ qmp_set_hosts() {
fi
}
qmp_set_maps() {
[ $(qmp_uci_get services.libremap) -eq 1 ] && {
qmp_uci_get_raw libremap.location && {
local lat="$(qmp_uci_get node.latitude)"
local lon="$(qmp_uci_get node.latitude)"
local elev="$(qmp_uci_get node.elevation)"
[ -n "$lat" ] && [ -n "$lon" ] && {
elev=${elev:-0}
qmp_uci_set_raw libremap.location.latitude="$lat"
qmp_uci_set_raw libremap.location.latitude="$lon"
qmp_uci_set_raw libremap.location.elev="$elev"
}
}
}
}
# -----------------------------------
# Services section
# -----------------------------------
......
......@@ -30,14 +30,20 @@ node_section.addremove = False
community_id = node_section:option(Value,"community_id", translate("Node name"), translate("The name for this node (use alphanumeric characters, without spaces)."))
community_id.default = "qMp"
community_id.datatype = "hostname"
primary_device = node_section:option(Value,"primary_device", translate("Primary network device"), translate("The name of the node's primary network device. The last four digits of this device's MAC address will be appended to the node name."))
primary_device.default = "eth0"
primary_device.datatype = "network"
geopos_lat = node_section:option(Value,"latitude", translate("Latitude"), translate("Latitude geoposition to use in the maps (optional)."))
geopos_lon = node_section:option(Value,"longitude", translate("Longitude"), translate("Longitude geoposition to use in the maps (optional)."))
geopos_elv = node_section:option(Value,"elevation", translate("Elevation"), translate("Elevation of the node relative to the ground level (optional)."))
contact = node_section:option(Value,"contact", translate("Contact e-mail"), translate("An e-mail to contact you if needed (optional)."))
function m.on_commit(self,map)
http.redirect("/luci-static/resources/qmp/wait_short.html")
luci.sys.call('/etc/qmp/qmp_control.sh configure_system > /tmp/qmp_control_system.log &')
luci.sys.exec('/etc/qmp/qmp_control.sh configure_system > /tmp/qmp_control_system.log &')
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment