Openwrtの修正Luciインタフェース
11787 ワード
1.名詞の解釈 Lua:解釈スクリプト言語openwrt実践|Luaクイック入門チュートリアル Uci:(Unified Configuration Interface)、OpenWrtでは のようなすべてのシステム構成を実現するための統合インタフェースである. Luci:(Lua Con霍霍gurationInterface)、Luaによって実現されたOpenwrtウェブページシステム構成インタフェースOpenwrt開発とLuci紹介 MVCフレームワーク:(model+view+controller)、新しい機能ページを開発するには、開発者はMVCフレームワークに基づいて簡単なLuaスクリプトを書くだけで、残りの部分はOpenwrtが自動的に を完了します. CBI:(コンフィギュレーションBinding Interface)、CBIモデルが 2.例
Luciインタフェースにウェルカムページと2つのボタンを追加し、システムshellスクリプト制御舵機を呼び出す(ハードウェアはWidoraを使用)第1ステップ: を登録する.第2ステップ:viewディレクトリの下に対応するswitchを追加する.htmファイルは、ウェルカムインタフェース(ネット上で任意にコピー) を表示します.第3歩:pwmを作成する.shスクリプト 再起動有効 3.その他の参考
OpenWrtルータ上のLuCIのモジュールOpenWrt Luciの作成テクニックを開発する
/etc/config/network
の部分構成config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
lua\luci\model\cbi
openwrtにあるCBIコントロールはluci cbiモジュールの詳細を簡単に説明するLuciインタフェースにウェルカムページと2つのボタンを追加し、システムshellスクリプト制御舵機を呼び出す(ハードウェアはWidoraを使用)
/usr/lib/lua/luci/controller/admin/switch.lua
に選択モジュール-- vim switch.lua
module("luci.controller.admin.switch", package.seeall)
function index()
entry({"admin", "switch"}, firstchild(), "Light", 30).dependent=false
entry({"admin", "switch", "welcome"}, template("switch"), _("Welcome"), 1) -- view switch.htm
entry({"admin", "switch", "on"}, call("turn_on"), _("TurnON"), 2) --
entry({"admin", "switch", "off"}, call("turn_off"), _("TurnOFF"), 3)
end
function turn_on()
luci.util.exec("/usr/pwm.sh 1500000") --
end
function turn_off()
luci.util.exec("/usr/pwm.sh 2500000") --
end
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
function getTime() {
var dateObj = new Date();
var year = dateObj.getFullYear();//
var month = dateObj.getMonth()+1;// ( : +1)
var date = dateObj.getDate();//
var day = dateObj.getDay();
var weeks = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var week = weeks[day];// day , 。
var hours = dateObj.getHours();//
var minutes = dateObj.getMinutes();//
var seconds = dateObj.getSeconds();//
if(month<10){
month = "0"+month;
}
if(date<10){
date = "0"+date;
}
if(hours<10){
hours = "0"+hours;
}
if(minutes<10){
minutes = "0"+minutes;
}
if(seconds<10){
seconds = "0"+seconds;
}
var newDate = year+"-"+month+"-"+date+"   "+hours+":"+minutes+":"+seconds+"   "+week;
document.getElementById("date1").innerHTML = "Welcome To Switch    " + newDate;// div
setTimeout('getTime()', 500);// 500ms getTime()
}
script>
<title>Welcometitle>
head>
<body onload="getTime()">
<div style="width:100%;text-align:center" id="date1">div>
body>
<body text=#d22370 bgcolor=#282923>
<marquee direction=left>You say that you love rainmarquee> <p>
<marquee direction=right>but you open your umbrella when it rains...marquee> <p>
<marquee direction =left behavior=scroll>You say that you love the sun,marquee > <p>
<marquee direction=right>but you find a shadow spot when the sun shines...marquee> <p>
<marquee direction =left behavior=scroll>You say that you love the wind,marquee > <p>
<marquee direction =right behavior=scroll>But you close your windows when wind blows...marquee > <p>
marquee > <p>
body>
html>
#vim /usr/pwm.sh
cd /sys/class/pwm/pwmchip0
echo 0 > export
cd pwm0
echo 1 > enable
echo 20000000 > period
echo ${1} > duty_cycle
exit 0
#chmod 755 pwm.sh
OpenWrtルータ上のLuCIのモジュールOpenWrt Luciの作成テクニックを開発する