<%+header%>
<%
local fs = require "nixio.fs"
nosms = 1
if not fs.stat("/etc/nosim") then
	nosms = 0
end
havegps = 0
if fs.stat("/etc/havegps") then
	havegps = 1
end
-%>
<style>g {color:grey; font-size:75%; vertical-align: super;}</style>
<script type="text/javascript" src="<%=resource%>/xhr.js?v=git-23.159.15540-7154b89"></script>
<script type="text/javascript">//<![CDATA[

	modemtype=0;
	cell=0;
	portx="-";
	phonenx = "";
	hided = 0;

	XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "modem", "get_csq")%>', null,
		function(x, rv)
		{
			document.getElementById('date').innerHTML=rv.date;
			
			document.getElementById('csq').innerHTML=rv.csq;
			document.getElementById('per').innerHTML=rv.per;
			document.getElementById('rssi').innerHTML=rv.rssi;
			document.getElementById('modem').innerHTML=rv.modem;
			document.getElementById('cops').innerHTML=rv.cops;
			document.getElementById('mode').innerHTML=rv.mode;
			document.getElementById('lac').innerHTML=rv.lac;
			document.getElementById('cid').innerHTML=rv.cid;
			document.getElementById('lacn').innerHTML=rv.lacn;
			document.getElementById('cidn').innerHTML=rv.cidn;
			document.getElementById('mcc').innerHTML=rv.mcc;
			document.getElementById('mnc').innerHTML=rv.mnc;
			document.getElementById('rnc').innerHTML=rv.rnc;
			document.getElementById('rncn').innerHTML=rv.rncn;
			document.getElementById('down').innerHTML=rv.down;
			document.getElementById('up').innerHTML=rv.up;
			document.getElementById('ecio').innerHTML=rv.ecio;
			document.getElementById('rscp').innerHTML=rv.rscp;
			document.getElementById('ecio1').innerHTML=rv.ecio1;
			document.getElementById('rscp1').innerHTML=rv.rscp1;
			document.getElementById('conntype').innerHTML=rv.conntype;
			document.getElementById('chan').innerHTML=rv.channel;
			document.getElementById('lband').innerHTML=rv.lband;
			document.getElementById('conmon').innerHTML=rv.netmode;
			document.getElementById('tempur').innerHTML=rv.tempur;
			
			document.getElementById('pci').innerHTML=rv.pci;
			document.getElementById('sinr').innerHTML=rv.sinr;
			
			document.getElementById('imei').innerHTML=rv.imei;
			document.getElementById('imsi').innerHTML=rv.imsi;
			document.getElementById('iccid').innerHTML=rv.iccid;
			document.getElementById('phone').innerHTML=rv.phone;


			<% if havegps == 1 then %>
			document.getElementById('lat').innerHTML=rv.lat;
			document.getElementById('long').innerHTML=rv.long;
			<% end %>
			// document.getElementById('idvp').innerHTML=rv.modid;
			// document.getElementById('proto').innerHTML=rv.proto;
			// document.getElementById('port').innerHTML=rv.port;

			// document.getElementById('crate').innerHTML=rv.crate;
			// if (phonenx == "")
			// {
			// 	document.getElementById('phone').value=rv.phone;
			// 	document.getElementById('phonen').value=rv.phonen;
			// 	phonenx = document.getElementById('phone').value;
			// 	document.getElementById("phone").disabled=false;
			// 	document.getElementById("phonen").disabled=false;
			// 	document.getElementById("pho").disabled=false;
			// }

			// if (rv.phone == "-")
			// {
			// 	document.getElementById('phone').value="-";
			// 	document.getElementById('phonen').value="-";
			// 	document.getElementById("pho").disabled=true;
			// 	document.getElementById("phone").disabled=true;
			// 	document.getElementById("phonen").disabled=true;
			// 	phonenx = "";
			// }
			
			// simerr = rv.simerr;
			// if (simerr == "0")
			// {
			// 	document.getElementById("simwarn").style.display="none";
			// }
			// else
			// {
			// 	document.getElementById("simwarn").style.display="block";
			// 	document.getElementById("simsg").style.color = "red";
			// 	if (simerr == "1")
			// 	{
			// 		document.getElementById("simsg").innerHTML = "<%:SIM卡已锁定，个人资料中未输入SIM Pin！！%>";
			// 	}
			// 	else
			// 	{
			// 		if (simerr == "2")
			// 		{
			// 			document.getElementById("simsg").innerHTML = "<%:解锁SIM卡的Pin不正确%>";
			// 		}
			// 		else
			// 		{
			// 			if (simerr == "3")
			// 			{
			// 				document.getElementById("simsg").innerHTML = "<%:无效SIM卡%>";
			// 			} else
			// 			{
			// 				document.getElementById("simsg").innerHTML = "<%:SIM卡未锁定.错误的SIM卡%>";
			// 			}
			// 		}
			// 	}
			// }


			// reslt=rv.result

			// portx=rv.port
			// if (portx == "-" )
			// {
			// 	document.getElementById('inc1').style.display="none";
			// 	document.getElementById('dec1').style.display="none";
			// }
			// else
			// {
			// 	document.getElementById('inc1').style.display="block";
			// 	document.getElementById('dec1').style.display="block";
			// }

			// host = rv.host;
			// if(host == "1")
			// {
			// 	document.getElementById("pho").disabled=true;
			// }
		}
	);

	function clear_data()
	{
		document.getElementById('port').innerHTML="<%:Changing Port%>";
		document.getElementById('csq').innerHTML="-";
		document.getElementById('per').innerHTML="-";
		document.getElementById('rssi').innerHTML="-";
		document.getElementById('modem').innerHTML="-";
		document.getElementById('cops').innerHTML="-";
		document.getElementById('mode').innerHTML="-";
		document.getElementById('lac').innerHTML="-";
		document.getElementById('cid').innerHTML="-";
		document.getElementById('lacn').innerHTML="-";
		document.getElementById('cidn').innerHTML="-";
		document.getElementById('mcc').innerHTML="-";
		document.getElementById('mnc').innerHTML="-";
		document.getElementById('rnc').innerHTML="-";
		document.getElementById('rncn').innerHTML="-";
		document.getElementById('down').innerHTML="-";
		document.getElementById('up').innerHTML="-";
		document.getElementById('ecio').innerHTML="-";
		document.getElementById('rscp').innerHTML="-";
		document.getElementById('ecio1').innerHTML="-";
		document.getElementById('rscp1').innerHTML="-";
		document.getElementById('netmode').innerHTML="-";
		document.getElementById('conntype').innerHTML=" ";
		document.getElementById('chan').innerHTML=" ";
		document.getElementById('conmon').innerHTML="-";
		document.getElementById('phone').value="-";
		
		
		document.getElementById('imei').innerHTML="-";
		document.getElementById('imsi').innerHTML="-";
		document.getElementById('iccid').innerHTML="-";
		document.getElementById('lband').innerHTML="-";
		document.getElementById('pci').innerHTML="-";
		<% if havegps == 1 then %>
		document.getElementById('lat').innerHTML="-";
		document.getElementById('long').innerHTML="-";
		<% end %>

		// document.getElementById('idvp').innerHTML="-";
		// document.getElementById('phonen').value="-";
	}






//]]></script>


<div class="cbi-map" id="cbi-modem">
<h2><a id="content" name="content"><%:信号状态/模块信息%></a></h2>
<div class="cbi-map-descr">请注意该插件所有功能并无适配所有5G模块，不用妄想冷门模块插上就能用(有能力者自行适配)
</div>

<fieldset class="cbi-section" id="simwarn" style="display:none;">
	<legend><%:SIM警告%></legend>
	<table width="550"  border="0">
		<tr>
			<td width="10%"></td>
    		<td width="60%"><div align="left" id="simsg" style="font-size:1.875em"><strong></strong></div></td>
			<td width="30%"></td>
		</tr>
	</table>
</fieldset>


<fieldset class="cbi-section" id="cbi-mod">
	<legend><%:综合信息%></legend>
	<table width="100%" cellspacing="10">
		<tr><td width="20%"><%:模块 :%></td><td id="modem">-</td><td></td></tr>
		<tr><td width="20%"><%:制造商 :%></td><td id="conntype"></td><td></td></tr>
		<tr><td width="20%"><%:温度 : %></td><td id="tempur"></td><td></td></tr>
		<tr><td width="20%"><%:更新时间 : %></td><td id="date"></td><td></td></tr>
		<!-- <tr><td width="20%"><%:ID : %></td><td id="idvp"></td><td></td></tr>
		<tr><td width="20%"><%:端口 : %></td><td id="port"></td><td></td></tr>
		<tr><td width="20%"><%:协议 : %></td><td id="proto"></td><td></td></tr> -->
	</table>
</fieldset>

<% if nosms == 0 then %>
<% end %>

<fieldset class="cbi-section" id="cbi-msinfo">
	<legend><%:通信模块/SIM卡信息%></legend>
	<table width="100%" cellspacing="10">
		<tr><td width="20%"><%:运营商 : %></td><td id="cops"></td><td></td></tr>
		<tr><td width="20%"><%:IMEI :%></td><td id="imei"></td><td></td></tr>
		<tr><td width="20%"><%:IMSI : %></td><td id="imsi"></td><td></td></tr>
		<tr><td width="20%"><%:ICCID : %></td><td id="iccid"></td><td></td></tr>
		<tr><td width="20%"><%:SIM卡号码 : %></td><td id="phone"></td><td></td></tr>
	</table>
</fieldset>


<fieldset class="cbi-section" id="cbi-sig">
	<legend><%:信号状态%></legend>
	<table width="100%" cellspacing="10">
		<tr><td width="20%"><%:蜂窝网络类型 :%></td><td id="mode"></td><td></td></tr>
		<tr><td width="20%"><%:CSQ : %></td><td id="csq"></td><td></td></tr>
		<tr><td width="20%"><%:信号强度 : %></td><td id="per"></td><td></td></tr>
		<tr><td width="20%"><%:信号接收强度 RSSI : %></td><td id="rssi"></td><td></td></tr>
		<tr><td width="20%"><%:参考信号接收质量 RSRQ : %></td><td><ul><span id="ecio" class="r"></span><span id="ecio1" class="r"></span></ul></td><td></td></tr>
		<tr><td width="20%"><%:参考信号接收功率 RSRP : %></td><td><ul><span id="rscp" class="r"></span><span id="rscp1" class="r"></span></ul></td><td></td></tr>
		<tr><td width="20%"><%:信噪比 SINR : %></td><td id="sinr"></td><td></td></tr>
		<tr><td width="20%"><%:连接状态监控 : %></td><td id="conmon"></td><td></td></tr>

	</table>
</fieldset>

<fieldset class="cbi-section" id="cbi-sig">
	<legend><%:基站信息%></legend>
	<table width="100%" cellspacing="10">
		<tr><td width="20%"><%:MCC / MNC  :%></td><td id="mcc"></td><td id="mnc"></td></tr>
		<tr><td width="20%"><%:eNB ID : %></td><td><ul><span id="rnc" class="r"></span><span id="rncn" class="r"></span></ul></td><td></td></tr>
		<tr><td width="20%"><%:TAC : %></td><td><ul><span id="lac" class="r"></span><span id="lacn" class="r"></span></ul></td><td></td></tr>
		<tr><td width="20%"><%:Cell ID : %></td><td><ul><span id="cid" class="r"></span><span id="cidn" class="r"></span></ul></td><td></td></tr>
		<tr><td width="20%"><%:频段 Band : %></td><td id="lband"></td><td></td></tr>
		<tr><td width="20%"><%:频点 Channel : %></td><td id="chan"></td><td></td></tr>
		<tr><td width="20%"><%:物理小区标识 PCI : %></td><td id="pci"></td><td></td></tr>
		<tr><td width="20%"><%:最大Qos级别 Maximum Qos : %></td><td><ul><span id="down" class="r"></span><span id="up" class="r"></span></ul></td><td></td></tr>

	</table>
</fieldset>


<% if havegps == 1 then %>
<fieldset class="cbi-section" id="cbi-gps">
	<legend><%:GPS 定位%></legend>
	<table width="550"  border="0">
  	<tr>
    		<td width="30%"><div align="right"><%:纬度 :%></div></td>
    		<td><ul id="lat"></ul></td>
    		<td width="1%">&nbsp;</td>
  	</tr>
  	<tr>
    		<td><div align="right"><%:经度 :%></div></td>
    		<td><ul id="long"></ul></td>
    		<td>&nbsp;</td>
  	</tr>
	</table>
</fieldset>
<% end %>


</div>
<%+footer%>

