今回は、Lua/Luci によるGUIとなります。lua/htmファイルはそのままFonera 2202にコピーします。luaファイルについては開発環境に追加するとbinaryにすることができますが、今回はメンテナンス性も考慮してソースコードのままとします。Binary化してのPackageが便利とは思いますが、まだそこまで構築方法の調査が進んでいません。
その1で安定していると書きましたが、負荷テストをしてみたところ、
- WSIM IO Data接続の場合には、10MBのファイルのダウンロードにおいて、PPPの取りこぼしが発生することがある。PPPのdisconnect/reconnectになる。
 - H12HWの場合には、10MBのファイルダウンロードは成功しましたが、接続したままの放置状態にしておくと、何度か接続が切れてしまうことがありました。
 
となりました。WSIMについては、logreadを読むとCPUの性能が足らない可能性があるかと思われます。H12HWについては、(田舎ですので)emobileの通信状態もしくはこのところの暑さで発熱の可能性もありますが、どちらについても原因の追及はできていません。
1. GUI概要
2. /usr/lib/lua/luci/controller/dialup.lua
|           --[[             module("luci.controller.dialup", package.seeall) function index()                     local page = entry({"fon_admin", "fon_dialup"}, template("dialup/dialup"),                     local epage = entry({"fon_admin", "fon_dialup", "edit"},                     local epage = entry({"fon_admin", "fon_dialup", "remove"},                     local cpage = entry({"fon_admin", "fon_dialup", "addentry"},                     local rpage = entry({"fon_admin", "fon_dialup", "ttyregist"},             end  |      
ダイヤルアップ接続のコントロール定義となります。メイン画面(dailup.htm)、編集画面(edit.htm)、追加画面(addentry.htm)、削除処理(remove.lua)、登録処理(ttyregist.lua)を記載します。viewのhtmファイルはtemplate(), model/cbiのluaファイルはcbi()を使います。
3. /usr/lib/lua/luci/view/dialup/dialup.htm
|           <!--               Revision history:             <% boxcolor="darkorange" %>             -- Get a temporary file name for vidpid list file.             -- Get the list of vidpids defined in the configuration file. And store it into a temporary file.             -- Open the vidpid list file.             -- Prepare FORM/ACTION URLs.             <table class="cbi-section-table">             <%                 vendor=uci:get("ttyusb."..line..".vendor")             <tbody>             <%             </tbody>             <!-- Add edntry and cancel buttons -->             <%              |      
ダイヤルアップ設定のメイン画面となります。/etc/config/ttyusb に登録されている各設定の一覧を表示し、「編集」、「削除」ボタンをそれぞれの設定に対して表示します。一覧の作成については、shell commandを起動しています。これはLuci utiliesを利用して書き直しを検討しています。
「編集」、「削除」については、POSTからそれぞれのluaが起動されます。「設定の追加」においては、対応するviewが起動されます。「削除」の場合には、確認のdialogは表示されません。中止(キャンセル)の場合には管理画面(fon_admin)に戻ります。
4. /usr/lib/lua/luci/view/dialup/addentry.htm
|           <!--             <% boxcolor="darkorange" %>             -- Prepare FORM/ACTION URLs.             <form method="POST" ACTION="<% write(url_ttyregist) %>"> <div class="cbi-map" id="cbi-fon">             <div class="cbi-section-node" id="cbi-fon-dialup-addentry"> <!-- Textbox for Vendor name -->             <!-- Textbox for Product name -->             <!-- Textbox for VIDPID (Vendor ID/Product ID) -->             <!-- Select List for tty driver -->               for idriver in string.gmatch(driver_list, "%w+") do             <!-- Select list for modem type: dialup or 3gumts -->               for imodem in string.gmatch(modem_list, "%w+") do             <!-- Textbox for PPP account username -->             <!-- Textbox for PPP account password -->             <!-- Textbox for connection chat command line -->             <!-- Select list for interface speed -->               for ispeed in string.gmatch(speed_list, "%w+") do             <!-- Textbox for modem inital command -->             </div>             <!--- Save and cancel buttons -->             </form>             <%+footer%>  |      
ダイヤルアップ設定の追加画面となります。既存の自動生成されるhtmlに合わせて header / footerおよびclassを指定します。個々の設定項目を取り込んで、ttyregistにPOSTします。保存の場合には、値は”save”としています。中止(キャンセル)の場合には、JavaScriptにて、admin画面に戻ります
5. /usr/lib/lua/luci/view/dialup/edit.htm
|           <!--             <% boxcolor="darkorange" %>             -- Get post 'fon_dialup.edit' value.             -- Prepare FOM/ACTION URLs.             -- Retrieve config values.             %> <form method="POST" ACTION="<% write(url_ttyregist) %>"> <div class="cbi-map" id="cbi-fon">             <div class="cbi-section-node" id="cbi-fon-dialup-edit"> <!-- Textbox for Vendor name -->             <!-- Textbox for Product name -->             <!-- Textbox for VIDPID (Vendor ID/Product ID) -->             <!-- Select List for tty driver -->               for idriver in string.gmatch(driver_list, "%w+") do             <!-- Select List for modem type: dialup or 3gumts -->               for imodem in string.gmatch(modem_list, "%w+") do             <!-- Textbox for PPP account username -->             <!-- Textbox for PPP account password -->             <!-- Textbox for connection chat command line -->             <!-- Select List for interface speed -->               for ispeed in string.gmatch(speed_list, "%w+") do             <!-- Textbox for modem inital command -->             </div>             <!-- Save and cancel buttons -->             </form> <br /> <%+footer%>  |      
選択したダイヤルアップ設定の編集画面となります。既存の自動生成されるhtmlに合わせて header / footerおよびclassを指定します。保存を押した場合には、ttyregistにPOSTします。
6. /usr/lib/lua/luci/model/cbi/dialup/remove.lua
|           --[[             local uci = require("luci.model.uci").cursor()             local val = http.formvalue("fon_dialup.remove")             -- The value of POST is the vidpid.             return  |      
/etc/config/ttyusbの該当する情報を削除するluaになります。POSTのvalueとして削除対象のvidpidが渡されます。
7. /usr/lib/lua/luci/model/cbi/dialup/ttyregist.lua
|           --[[             local uci = require("luci.model.uci").cursor()             local val = http.formvalue("fon_dialup.tty_cancel")             val = http.formvalue("fon_dialup.tty_save")             --[[ When the vidpid was modifed, old vidpid is passed as the form value.               uci:set("ttyusb", vidpid, "ttyusb")             http.redirect(".")              |      
/etc/config/ttyusbに対して、更新処理を行います。formvalueが”save”のときに更新処理を行います。vidpidが変更されている場合には、先に削除処理を実行します。その後で更新された情報を登録します。
9. /usr/lib/lua/luci/i18n/dialup.en.lua
|           dialup = "Dialup"              |      
GUIの英語メッセージとなります。
10. /usr/lib/lua/luci/i18n/dialup.ja.lua (UTF-8にします)
|           dialup = "ダイヤルアップ"              |      
GUIの日本語メッセージとなります。UTF-8にて保存します。
10. dialup iconファイルの設定
| # cd /www/luci-static/resources/icons           # wget http://www.iconarchive.com/icons/iconica/pastel/48/dialup-networking-icon.png # mv dialup-networking-icon.png dialup.png  |      
12. 更新履歴
- 2010/08/14: Initail release
 
0 件のコメント:
コメントを投稿