+++ /dev/null
-<html>\r
-<head>\r
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\r
- <link href="./mimic.css" rel="stylesheet" type="text/css">\r
-\r
-<style id="user-style-nyatla-bg-img">\r
- body{\r
- width:95%;\r
- height:95%;\r
- }\r
- .table{\r
- width:450px;\r
- }\r
- .text_row{\r
- margin:2px 2px 2px 2px;\r
- padding:2px 2px 2px 2px;\r
- background-color:#eeeeee;\r
- }\r
- \r
- .input_row{\r
- margin:2px 2px 2px 2px;\r
- padding:2px 2px 2px 2px;\r
- background-color:#bbffbb;\r
- }\r
- .td1{\r
- width:120px;\r
- }\r
- .input_row input{\r
- width:200px;\r
- }\r
- \r
-</style>\r
-<script type="text/javascript">\r
-\r
-var app;\r
-function getElem(id){return document.getElementById(id);}\r
-\r
-function str2HexArray(i_str,delim,len,digit)\r
-{\r
- var l=i_str.split(delim);\r
- if(l.length==len){\r
- var r=new Array();\r
- for(var i=0;i<len;i++){\r
- var v=parseInt(l[i],digit);\r
- if(!isNaN(v) && v>=0 && v<=255){\r
- r.push(v);\r
- }else{\r
- throw "str2HexArray failed.";\r
- }\r
- }\r
- return r;\r
- }\r
- throw "str2HexArray failed.";\r
-}\r
-\r
-function int2hex2(val)\r
-{\r
- var r=val.toString(16);\r
- if(r.length<2){\r
- r="0"+r;\r
- }\r
- return r;\r
-}\r
-function arrayToHex(ar)\r
-{\r
- if(ar==null){\r
- return null;\r
- }\r
- var ret="";\r
- for(var i=0;i<ar.length;i++){\r
- ret+=int2hex2(ar[i]);\r
- }\r
- return ret;\r
-}\r
-function xhrGetJson(i_url)\r
-{\r
- var xhr = window.XDomainRequest ? new XDomainRequest() : new XMLHttpRequest();\r
- try{\r
- xhr.open("GET",i_url,false);\r
- xhr.send(null);\r
- return eval("("+xhr.responseText+")");\r
- } catch (e){\r
- throw "XhrRequest failed.'"+e.toString()+"'";\r
- }\r
-}\r
-\r
-\r
-var Ui=new Object();\r
-Ui.IpAddrInput=function(id)\r
-{\r
- this._tags={\r
- input:getElem(id)\r
- };\r
- this.events={\r
- onchange:null\r
- };\r
- var _t=this;\r
- this._tags.input.onChange=function()\r
- {\r
- if(_t.events.onchange!=null){\r
- _t.events.onchange();\r
- }\r
- }\r
-}\r
-Ui.IpAddrInput.prototype=\r
-{\r
- events:null,\r
- _tags:null,\r
- getIpAddr:function(){\r
- return str2HexArray(this._tags.input.value,".",4,10);\r
- },\r
- getText:function(){\r
- return this._tags.input.value;\r
- },\r
- setIpValue:function(v1)\r
- {\r
- function int2str(val)\r
- {\r
- return val.toString(10);\r
- } \r
- this._tags.input.value=\r
- int2str((v1>>24)&0xff)+"."+int2str((v1>>16)&0xff)+"."+int2str((v1>>8)&0xff)+"."+int2str((v1>>0)&0xff);\r
- } \r
-}\r
-Ui.MacAddr=function(id)\r
-{\r
- this._tags={\r
- input:getElem(id)\r
- };\r
- this.events={\r
- onchange:null\r
- };\r
- var _t=this;\r
- this._tags.input.onChange=function()\r
- {\r
- if(_t.events.onchange!=null){\r
- _t.events.onchange();\r
- }\r
- } \r
-}\r
-Ui.MacAddr.prototype=\r
-{\r
- events:null,\r
- _tags:null,\r
- getMacAddr:function(){\r
- return str2HexArray(this._tags.input.value,":",6,16);\r
- },\r
- getText:function()\r
- {\r
- return this._tags.input.value;\r
- },\r
- setMacValue:function(v1,v2)\r
- {\r
- this._tags.input.value=\r
- int2hex2((v1>>24)&0xff)+":"+int2hex2((v1>>16)&0xff)+":"+int2hex2((v1>>8)&0xff)+":"+int2hex2((v1>>0)&0xff)+":"\r
- +int2hex2((v2>>24)&0xff)+":"+int2hex2((v2>>16)&0xff);\r
- }\r
-}\r
-\r
-Ui.AccessMode=function(id)\r
-{\r
- this._tags={\r
- select:getElem(id)\r
- };\r
- this.events={\r
- onchange:null\r
- };\r
- var _t=this;\r
- this._tags.select.onChange=function()\r
- {\r
- if(_t.events.onchange!=null){\r
- _t.events.onchange();\r
- }\r
- } \r
-}\r
-Ui.AccessMode.prototype=\r
-{\r
- events:null,\r
- _tags:null,\r
- getMode:function(){\r
- return this._tags.select.selectedIndex ;\r
- },\r
- setValue:function(v1)\r
- {\r
- this._tags.select.selectedIndex =v1;\r
- }\r
-}\r
-\r
-\r
-\r
-Ui.UpdateButton=function(id)\r
-{\r
- this._tags={\r
- button:getElem(id)\r
- };\r
- this.events={\r
- onclick:null\r
- }\r
- var _t=this;\r
- this._tags.button.onclick=function()\r
- {\r
- if(_t.events.onclick!=null){\r
- _t.events.onclick();\r
- } \r
- }\r
- this._tags.button.disabled=false;\r
-}\r
-Ui.UpdateButton.prototype=\r
-{\r
- events:null,\r
- _tags:null,\r
- disable:function()\r
- {\r
- this._tags.button.disabled=true; \r
- }\r
-}\r
-\r
-\r
-function Application()\r
-{\r
- var ui={\r
- macaddr:new Ui.MacAddr("macaddrinput"),\r
- update:new Ui.UpdateButton("updatebtn"),\r
- ipaddr:new Ui.IpAddrInput("ipinput"),\r
- subnetmask:new Ui.IpAddrInput("subnetinput"),\r
- dgateway:new Ui.IpAddrInput("dginput"),\r
- mvm_ac:new Ui.AccessMode("mvmselect"),\r
- setup_ac:new Ui.AccessMode("setupselect")\r
- }\r
- ui.update.events.onclick=function(){\r
- //値チェック\r
- try{\r
- var sq=0;\r
- var mac=ui.macaddr.getMacAddr();\r
- sq=1;\r
- var ip=ui.ipaddr.getIpAddr();\r
- sq=2;\r
- var subnet=ui.subnetmask.getIpAddr();\r
- sq=3;\r
- var dgate=ui.dgateway.getIpAddr();\r
- sq=4;\r
- var pm=arrayToHex(mac)+"ffff"\r
- +arrayToHex(ip)\r
- +arrayToHex(subnet)\r
- +arrayToHex(dgate)\r
- +"00500000"\r
- +int2hex2(ui.mvm_ac.getMode())+int2hex2(ui.setup_ac.getMode())+"ffff";\r
- sq=5;\r
- //LPCXPressoへ送信\r
- var ret=xhrGetJson("./setup.api?c=update&p="+pm);\r
- sq=6;\r
- if(ret.result!=0x0){\r
- alert("MiMic configration update is failed. code=0x"+ret.result);\r
- }else{\r
- alert("MiMic configration is changed.\nChanges becomes effective after a restart MiMic.");\r
- }\r
- }catch(e){\r
- switch(sq){\r
- case 0: alert("Invalid MAC address '"+ui.macaddr.getText()+"'");break;\r
- case 1: alert("Invalid IP address '"+ui.ipaddr.getText()+"'");break;\r
- case 2: alert("Invalid subnet mask '"+ui.subnetmask.getText()+"'");break;\r
- case 3: alert("Invalid default gateway'"+ui.dgateway.getText()+"'");break;\r
- case 6: alert("MiMic configuration process failed at XHR.");break;\r
- default:\r
- alert("MiMic configuration process failed by '"+e.toString()+"'.");break;\r
- }\r
- }\r
- \r
- }\r
- try{\r
- var cfg=xhrGetJson("./setup.api?c=get");\r
- getElem("versiondiv").innerHTML=cfg.application;\r
- ui.macaddr.setMacValue(cfg.mac00010203,cfg.mac0405xxxx);\r
- ui.ipaddr.setIpValue(cfg.ip);\r
- ui.subnetmask.setIpValue(cfg.mask);\r
- ui.dgateway.setIpValue(cfg.droute);\r
- ui.mvm_ac.setValue((cfg.access>>24)&0xff);\r
- ui.setup_ac.setValue((cfg.access>>16)&0xff);\r
- }catch(e){\r
- ui.update.disable();\r
- alert("MiMic configurator failed initialization.'"+e.toString()+"'");\r
- } \r
-}\r
-\r
-\r
-function init()\r
-{\r
- app=new Application();\r
-}\r
-\r
-\r
-\r
- \r
-\r
-\r
-\r
-\r
-</script>\r
-</head>\r
-<body onload="init();">\r
-<h1>MiMic RemoteMCU configuration</h1>\r
-<hr/>\r
- <h2>Information</h2>\r
- <table class="table">\r
- <tr class="text_row" ><td class="td1">Version</td><td id="versiondiv"></td></tr>\r
- </table>\r
- <h2>Ethernet</h2>\r
- <table class="table">\r
- <tr class="input_row"><td class="td1">MAC address</td><td><input id="macaddrinput" type="text"/></td></tr>\r
- <tr class="input_row"><td class="td1">IP address</td><td><input id="ipinput" type="text"/></td></tr>\r
- <tr class="input_row"><td class="td1">subnet mask</td><td><input id="subnetinput" type="text"/></td></tr>\r
- <tr class="input_row"><td class="td1">default gateway</td><td><input id="dginput" type="text"/></td></tr>\r
- </table>\r
- <h2>Access control</h2>\r
- <table class="table">\r
- <tr class="input_row"><td class="td1">setup.api</td><td><select id="setupselect"><option value="0">Subnet only</option><option value="1">All</option></select></div>\r
- <tr class="input_row"><td class="td1">mvm.api</td><td><select id="mvmselect"><option value="0">Subnet only</option><option value="1">All</option></select></div>\r
- </table>\r
- <input id="updatebtn" type="button" value="update configulation" />\r
-<div class="footer">\r
-<a href="http://nyatla.jp/mimic/wp" alt="http://nyatla.jp/mimic/wp">\r
-<img src="./mimiclogo.png"/></a>\r
-MiMic<br/>\r
-Copyright (C) 2011 nyatla.jp All Rights Reserved.\r
-</div>\r
-</body>\r