Developing lightweight computation at the DSG edge

Commit df07f7c9 authored by p4u's avatar p4u
Browse files

Uncomented reboot. If not, first time does not work

parent 9212f982
......@@ -80,23 +80,32 @@ function action_status()
end
function action_neighbours()
local orig = bmx6json.get("originators").originators or nil
local orig_list = bmx6json.get("originators").originators or nil
if orig == nil then
if orig_list == nil then
luci.template.render("bmx6/error", {txt="Cannot fetch data from bmx6 json"})
return nil
end
local neighbours = {}
local nb = nil
local nd = nil
for _,o in ipairs(orig) do
nb = bmx6json.get("originators/"..o.name).originators or {}
nd = bmx6json.get("descriptions/"..o.name).descriptions or {}
table.insert(neighbours,{orig=nb,desc=nd})
local originators = {}
local desc = nil
local orig = nil
local name = ""
for _,o in ipairs(orig_list) do
orig = bmx6json.get("originators/"..o.name) or {}
desc = bmx6json.get("descriptions/"..o.name) or {}
if string.find(o.name,'.') then
name = luci.util.split(o.name,'.')[1]
else
name = o.name
end
table.insert(originators,{name=name,orig=orig,desc=desc})
end
luci.template.render("bmx6/neighbours", {neighbours=neighbours})
luci.template.render("bmx6/neighbours", {originators=originators})
end
function action_links()
......@@ -121,7 +130,8 @@ function action_chat()
local rcvd_dir = sms_dir .. "/rcvdSms"
local send_file = sms_dir .. "/sendSms/chat"
local sms_list = bmx6json.get("rcvdSms")
local data = ""
local sender = ""
local sms_file = ""
local chat = {}
local to_send = nil
local sent = ""
......@@ -132,19 +142,23 @@ function action_chat()
return nil
end
if sms_list ~= nil then
sms_list = sms_list.rcvdSms
else
sms_list = {}
end
for _,s in ipairs(sms_list) do
data = luci.util.split(s.name,':')
if #data == 2 and data[2] == "chat" then
fd = io.open(rcvd_dir.."/"..s.name,"r")
chat[data[1]] = fd:read()
fd:close()
sms_list = luci.util.split(luci.util.exec("ls "..rcvd_dir.."/*:chat"))
for _,sms_path in ipairs(sms_list) do
if #sms_path > #rcvd_dir then
sms_file = luci.util.split(sms_path,'/')
sms_file = sms_file[#sms_file]
sender = luci.util.split(sms_file,':')[1]
-- Trying to clean the name
if string.find(sender,".") ~= nil then
sender = luci.util.split(sender,".")[1]
end
fd = io.open(sms_path,"r")
chat[sender] = fd:read()
fd:close()
end
end
to_send = luci.http.formvalue("toSend")
......
<%+header%>
<meta http-equiv="refresh" content="10" />
<meta http-equiv="refresh" content="60" />
<h2><a id="content" name="content"><%:Chat%></a></h2>
This is sms a chat where all bmx6 nodes can participate. The data is replayed using routing packets, so there is a limit of 2040 bytes. Use it only to send short messages.
<br />
<p>This is sms a chat where all bmx6 nodes can participate. The data is replayed using routing packets, so there is a limit of 2040 bytes. Use it only to send short messages.</p>
<p>Each participant can only send one sms at same time.</p>
<br />
<strong>Received SMS</strong>
<br />
<pre style="background-color:#dadbe6;">
<% for orig,sms in pairs(chat) do %>
<%=orig%>: <%=sms%>
<u><%=orig%></u>:<%=sms%>
<% end %>
</pre>
<form action=".">
<input type="submit" value="refresh" />
</form>
<br />
<form action="." method="post">
<input type="text" name="toSend" />
<input type="submit" value="sms send" />
<input type="submit" value="send sms" />
</form>
<br />
......
<%+header%>
<style type="text/css">
table {
width:90%;
border-top:1px solid #e5eaf8;
border-right:1px solid #e5eaf8;
margin:1em auto;
border-collapse:collapse;
}
td {
color:#678197;
border-bottom:1px solid #e6eff8;
border-left:1px solid #e6eff8;
padding:.3em 1em;
text-align:center;
}
th {
background:#f4f9fe;
text-align:center;
font:bold 1.2em/2em "Century Gothic","Trebuchet MS",Arial,Helvetica,sans-serif;
color:#66a3d3;
}
#neighbour {
position:relative;
margin:5px;
}
#nb_id {
background-color: #35ca2c;
font: bold;
#orig_id {
background-color: black;
color: white;
text-ident:10px;
}
</style>
<h2><a id="content" name="content"><%:Neighbours%></a></h2>
<% for i,n in ipairs(neighbours) do %>
<div id="neighbour">
<div id="nb_id"><%=n.orig.globalId%></div>
</div>
<table>
<tr>
<th scope="col">Name</th>
<th scope="col">IP</th>
<th scope="col">Via Dev</th>
<th scope="col">Via IP</th>
<th scope="col">Routes</th>
<th scope="col">Metric</th>
<th scope="col">Last Desc</th>
<th scope="col">Last Ref</th>
</tr>
<% for i,o in ipairs(originators) do %>
<% if #o.orig.viaIp > 2 then %>
<tr>
<td><%=o.name%></td>
<td><%=o.orig.primaryIp%></td>
<td><%=o.orig.viaDev%></td>
<td><%=o.orig.viaIp%></td>
<td><%=o.orig.routes%></td>
<td><%=o.orig.metric%></td>
<td><%=o.orig.lastDesc%></td>
<td><%=o.orig.lastRef%></td>
</tr>
<%end%>
<%end%>
</table>
<br />
<%+footer%>
<%+header%>
<link rel="stylesheet" type="text/css" href="/luci-static/resources/bmx6/style.css" />
<style type="text/css">
table.int {
border-width: 0px;
border-spacing: 2px;
border-style: inset;
border-color: black;
border-collapse: collapse;
background-color: #dadbe6;
margin-left: 50px;
}
table.int tr {
border-width: 1px;
padding: 4px;
border-style: solid;
border-color: black;
background-color: #dadbe9;
}
table.int td {
border-width: 0px;
padding: 4px;
border-style: solid;
border-color: black;
background-color: #dadbe9;
text-align: center;
}
</style>
<h2>Status of bmx6</h2>
<h2><a id="content" name="content"><%:Status%></a></h2>
<h3>Status of bmx6</h3>
<table class="int">
<table>
<tr>
<td><strong>Version</strong></td>
<td><strong>Compatibility</strong></td>
<td><strong>CodeVersion</strong></td>
<td><strong>Global Id</strong></td>
<td><strong>Primary Ip</strong></td>
<td><strong>Local Id</strong></td>
<td><strong>Uptime</strong></td>
<td><strong>CPU</strong></td>
<td><strong>Nodes</strong></td>
<th>Version</th>
<th>Compatibility</th>
<th>CodeVersion</th>
<th>Global Id</th>
<th>Primary Ip</th>
<th>Local Id</th>
<th>Uptime</th>
<th>CPU</th>
<th>Nodes</th>
</tr>
<tr>
<td><%=status.version%></td>
......@@ -59,17 +31,17 @@
<br />
<br />
<h3>Status of interfaces</h3>
<table class="int">
<h2>Status of interfaces</h2>
<table>
<tr>
<td><strong>Name</strong></td>
<td><strong>State</strong></td>
<td><strong>Type</strong></td>
<td><strong>Rate (Min/Max)</strong></td>
<td><strong>Local IP</strong></td>
<td><strong>Global IP</strong></td>
<td><strong>Multicast IP</strong></td>
<td><strong>Primary</strong></td>
<th>Name</th>
<th>State</th>
<th>Type</th>
<th>Rate (Min/Max)</th>
<th>Local IP</th>
<th>Global IP</th>
<th>Multicast IP</th>
<th>Primary</th>
</tr>
<% for i,v in ipairs(interfaces) do %>
<tr>
......
#neighbour {
position:relative;
}
#nb_id {
background-color: #35ca2c;
float:left;
font: bold;
}
......@@ -12,22 +12,22 @@ configure() {
. $QMP_DIR/qmp_wireless.sh
qmp_configure_wifi_initial
qmp_configure_wifi
wifi
# wifi
echo "[Configuring networking]"
. $QMP_DIR/qmp_functions.sh
qmp_configure
# /etc/init.d/qmp-fix-vlan start
/etc/init.d/network restart
# /etc/init.d/network restart
# ifup -a
QMP_HOSTNAME=$(uci get system.@system[0].hostname)
echo "Update hostname for: '$QMP_HOSTNAME'"
echo "$QMP_HOSTNAME" > /proc/sys/kernel/hostname
/etc/init.d/olsrd restart
/etc/init.d/bmx6 restart
# /etc/init.d/olsrd restart
# /etc/init.d/bmx6 restart
touch "$CONTROL_FILE"
# echo "Done, rebooting system to complete configuration"
echo "Done, rebooting system to complete configuration"
reboot
}
start() {
......
......@@ -425,7 +425,6 @@ qmp_configure_network() {
uci set $conf.lan.proto="static"
uci set $conf.lan.ipaddr="$(uci get qmp.networks.lan_address)"
uci set $conf.lan.netmask="$(uci get qmp.networks.lan_netmask)"
uci set $conf.lan.dns="(uci get qmp.networks.dns)"
if qmp_uci_test qmp.interfaces.mesh_devices && qmp_uci_test qmp.networks.mesh_protocol_vids; then
......@@ -508,6 +507,15 @@ qmp_configure_bmx6() {
uci set $conf.bmx6_json_plugin=plugin
uci set $conf.bmx6_json_plugin.plugin=bmx6_json.so
uci set $conf.bmx6_sms_plugin=plugin
uci set $conf.bmx6_sms_plugin.plugin=bmx6_sms.so
# chat and map files must be syncronized using sms
cfg_sms=$(uci add $conf syncSms)
uci set $conf.${cfg_sms}.syncSms=chat
cfg_sms=$(uci add $conf syncSms)
uci set $conf.${cfg_sms}.syncSms=map
uci set $conf.ipVersion=ipVersion
uci set $conf.ipVersion.ipVersion="6"
uci set $conf.ipVersion.throwRules="0"
......
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