Developing lightweight computation at the DSG edge

Commit 49cc41df authored by hitz's avatar hitz
Browse files

Fixed some issues

parent 809a9f85
......@@ -22,9 +22,14 @@ define Package/bmx6-luci
endef
define Package/bmx6-luci/description
bmx6 web interface for luci
bmx6 web interface for luci (json)
endef
define Package/bmx6-luci/conffiles
/etc/config/luci-bmx6
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
......@@ -35,16 +40,6 @@ endef
define Build/Compile
endef
define Package/bmx6-luci/postinst
#!/bin/sh
uci set bmx6.luci=bmx6
uci set bmx6.luci.ignore=0
uci set bmx6.luci.level1=admin
uci set bmx6.luci.level2=bmx6
uci set bmx6.luci.json=http://127.0.0.1:8086/
uci commit bmx6
endef
define Package/bmx6-luci/install
$(CP) ./files/* $(1)/
endef
......
module("luci.controller.bmx6", package.seeall)
function index()
-- ToDo: Put this code in a function
local place = {}
local ucim = require "luci.model.uci"
local uci = ucim.cursor()
-- checking if ignore is on
if uci.cursor():get("bmx6","luci","ignore") == "1" then
return nil
end
-- getting value from uci database
local l1 = uci:get("bmx6","luci","level1")
local l2 = uci:get("bmx6","luci","level2")
local l3 = uci:get("bmx6","luci","level3")
-- default values
if l1 == nil then main = "bmx6" end
table.insert(place,l1)
-- level2 and level3 are optional
if l2 ~= nil then table.insert(place,l2) end
if l3 ~= nil then table.insert(place,l3) end
---------------------------
-- Starting with the pages
---------------------------
local page = nil
--- status (this is default one)
if #place == 1 then
page = node(place[1])
page.title = place[1]
elseif #place == 2 then
page = node(place[1],place[2])
page.title = place[2]
else
page = node(place[1],place[2],place[3])
page.title = place[3]
-- ToDo: Put this code in a function
local ucim = require "luci.model.uci"
local uci = ucim.cursor()
local place = {}
-- checking if ignore is on
if uci:get("luci-bmx6","luci","ignore") == "1" then
return nil
end
page.target = call("action_stat")
page.subindex = "false"
--- interfaces
if #place == 1 then
page = node(place[1],"interfaces")
elseif #place == 2 then
page = node(place[1],place[2],"interfaces")
else
page = node(place[1],place[2],place[3],"interfaces")
end
page.target = call("action_int")
page.title = "Interfaces"
page.subindex = "true"
--- neighbours
if #place == 1 then
page = node(place[1],"neighbours")
elseif #place == 2 then
page = node(place[1],place[2],"neighbours")
else
page = node(place[1],place[2],place[3],"neighbours")
-- getting value from uci database
local uci_place = uci:get("luci-bmx6","luci","place")
-- default values
if uci_place == nil then
place = {"bmx6"}
else
local util = require "luci.util"
place = util.split(uci_place," ")
end
page.target = call("action_nb")
page.title = "Neighbours"
page.subindex = "true"
--- wireless links
if #place == 1 then
page = node(place[1],"links")
elseif #place == 2 then
page = node(place[1],place[2],"links")
else
page = node(place[1],place[2],place[3],"links")
end
page.target = call("action_wl")
page.title = "Wireless Links"
page.subindex = "true"
---------------------------
-- Starting with the pages
---------------------------
--- status (this is default one)
entry(place,call("action_status"),place[#place])
--- interfaces
table.insert(place,"Interfaces")
entry(place,call("action_interfaces"),"Interfaces")
table.remove(place)
--- neighbours
table.insert(place,"Neighbours")
entry(place,call("action_neighbours"),"Neighbours")
table.remove(place)
--- wireless links
table.insert(place,"Wireless")
entry(place,call("action_wireless"),"Wireless")
table.remove(place)
end
function action_stat()
local data = get_bmx_data("interfaces")
if data == nil then return nil end
luci.template.render("bmx6/status", {data=data.interfaces})
function action_status()
local data = get_bmx_data("interfaces")
if data == nil then return nil end
luci.template.render("bmx6/status", {data=data.interfaces})
end
function action_int()
local data = get_bmx_data("interfaces")
if data == nil then return nil end
luci.template.render("bmx6/interfaces", {data=data.interfaces})
function action_interfaces()
local data = get_bmx_data("interfaces")
if data == nil then return nil end
luci.template.render("bmx6/interfaces", {data=data.interfaces})
end
function action_nb()
local data = get_bmx_data("neighbours")
if data == nil then return nil end
luci.template.render("bmx6/neighbours", {data=data.neighbours})
function action_neighbours()
local data = get_bmx_data("neighbours")
if data == nil then return nil end
luci.template.render("bmx6/neighbours", {data=data.neighbours})
end
function action_wl()
local data = get_bmx_data("wireless")
if data == nil then return nil end
function action_wireless()
local data = get_bmx_data("wireless")
if data == nil then return nil end
luci.template.render("bmx6/wireless", {data=data.interfaces})
end
-- Private
----------------
-- Private
----------------
-- Returns a LUA object from bmx6 JSON daemon
function get_bmx_data(field)
require("luci.ltn12")
require("luci.json")
local uci = require "luci.model.uci"
local url = uci.cursor():get("bmx6","luci","json")
if url == nil then
print_error("bmx6 json url not configured, cannot fetch bmx6 daemon data")
return nil
end
local raw = luci.sys.httpget(url..field)
local data = nil
if raw:len() > 10 then
local decoder = luci.json.Decoder()
luci.ltn12.pump.all(luci.ltn12.source.string(raw), decoder:sink())
data = decoder:get()
else
print_error("Cannot get data from bmx6 daemon")
return nil
end
return data
end
require("luci.ltn12")
require("luci.json")
local uci = require "luci.model.uci"
local url = uci.cursor():get("luci-bmx6","luci","json")
if url == nil then
print_error("bmx6 json url not configured, cannot fetch bmx6 daemon data")
return nil
end
local raw = luci.sys.httpget(url..field)
local data = nil
if raw:len() > 10 then
local decoder = luci.json.Decoder()
luci.ltn12.pump.all(luci.ltn12.source.string(raw), decoder:sink())
data = decoder:get()
else
print_error("Cannot get data from bmx6 daemon")
return nil
end
return data
end
function print_error(txt)
luci.util.perror(txt)
luci.template.render("bmx6/error", {txt=txt})
luci.util.perror(txt)
luci.template.render("bmx6/error", {txt=txt})
end
......@@ -23,13 +23,13 @@ define Package/qmp-small-node
TITLE:=Required addons for small qmp mesh nodes ( 4MByte )
URL:=http://qmp.cat
DEPENDS:= \
+luci-ssl \
+uhttpd +luci +luci-lib-nixio \
+horst \
+iputils-arping +iputils-clockdiff +iputils-ping +iputils-tracepath \
+ahcpd \
+radvd \
+wide-dhcpv6-client +wide-dhcpv6-control +wide-dhcpv6-server \
+bmx6 +bmx6-uci-config \
+bmx6 +bmx6-uci-config +bmx6-luci \
+olsrd +olsrd-mod-txtinfo +olsrd-mod-httpinfo +olsrd-mod-watchdog +olsrd-mod-arprefresh \
+luci-i18n-catalan +luci-i18n-spanish +luci-i18n-french \
+babeld \
......@@ -40,7 +40,6 @@ define Package/qmp-small-node
+kmod-niit \
+kmod-ipip \
+kmod-tun \
+kmod-madwifi \
endef
......@@ -53,3 +52,4 @@ endef
$(eval $(call BuildPackage,qmp-small-node))
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