Przeglądaj źródła

2020-09-14 / ct_chen

Actions:
1. define.h add TelcomEnabled
2. Webservice [download log] add date time on file name; [set network] add 3G/4G enable/disable; [set system] add rule for LCM;

Files:
1. EVSE/Projects/define.h
2. EVSE/Modularization/WebService.c
   EVSE/rootfs/var/www/log_download.php
   EVSE/rootfs/var/www/set_network.php
   EVSE/rootfs/var/www/set_network_action.php
   EVSE/rootfs/var/www/set_system.php
ct_chen 4 lat temu
rodzic
commit
6768d993c2

+ 9 - 1
EVSE/Modularization/WebService.c

@@ -662,6 +662,7 @@ int main(int argc, char *argv[]) {
 			char *TelcomChapPapId=NULL;
 			char *TelcomChapPapPwd=NULL;
 			char *TelcomIpAddress=NULL;
+			char TelcomEnabled=NULL;
 			if( json_object_object_get_ex(jobj, "Eth0DhcpClient", &val_obj) ) {
 				Eth0DhcpClient = json_object_get_int(val_obj);
 			}
@@ -710,6 +711,9 @@ int main(int argc, char *argv[]) {
 			if( json_object_object_get_ex(jobj, "TelcomIpAddress", &val_obj) ) {
 				TelcomIpAddress = (char*)json_object_get_string(val_obj);
 			}
+			if( json_object_object_get_ex(jobj, "TelcomEnabled", &val_obj) ) {
+				TelcomEnabled = json_object_get_int(val_obj);
+			}
 
 			ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient=Eth0DhcpClient;
 			strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,Eth0IpAddress);
@@ -728,6 +732,7 @@ int main(int argc, char *argv[]) {
 			strcpy((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId,TelcomChapPapId);
 			strcpy((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd,TelcomChapPapPwd);
 			strcpy((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomIpAddress,TelcomIpAddress);
+			ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled=TelcomEnabled;
 		}
 		if (strcmp(argv[1], "4") == 0) {
 			struct json_object *jobj = json_tokener_parse(argv[2]);
@@ -793,7 +798,7 @@ int main(int argc, char *argv[]) {
 		if (strcmp(argv[1], "aaa") == 0) {
 			//struct SysConfigData 	SysConfig;
 		//system
-		strcpy((char *)&ShmSysConfigAndInfo->SysConfig.ModelName, "DSLU601J1UT1P0D");
+		strcpy((char *)&ShmSysConfigAndInfo->SysConfig.ModelName, "AW0E770001W1P0D");
 		strcpy((char *)&ShmSysConfigAndInfo->SysConfig.SerialNumber, "SerialNumber");
 		strcpy((char *)&ShmSysConfigAndInfo->SysConfig.SystemId, "1234567890");
 		strcpy((char *)&ShmSysConfigAndInfo->SysConfig.SystemDateTime, "2019-12-31 23:59:59");
@@ -1187,6 +1192,7 @@ int main(int argc, char *argv[]) {
 		struct json_object *TelcomModemMode;
 		struct json_object *TelcomIpAddress;
 		struct json_object *TelcomNetworkConn;
+		struct json_object *TelcomEnabled;
 		//backend
 		struct json_object *BackendConnTimeout;
 		struct json_object *OfflinePolicy;
@@ -1624,6 +1630,7 @@ int main(int argc, char *argv[]) {
 		TelcomModemMode = json_object_new_int(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode);
 		TelcomIpAddress = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomIpAddress);
 		TelcomNetworkConn = json_object_new_int(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn);
+		TelcomEnabled = json_object_new_int(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled);
 		//backend
 		BackendConnTimeout = json_object_new_int(ShmSysConfigAndInfo->SysConfig.BackendConnTimeout);
 		OfflinePolicy = json_object_new_int(ShmSysConfigAndInfo->SysConfig.OfflinePolicy);
@@ -1848,6 +1855,7 @@ int main(int argc, char *argv[]) {
 		json_object_object_add(jobj3,"TelcomModemMode",TelcomModemMode);
 		json_object_object_add(jobj3,"TelcomIpAddress",TelcomIpAddress);
 		json_object_object_add(jobj3,"TelcomNetworkConn",TelcomNetworkConn);
+		json_object_object_add(jobj3,"TelcomEnabled",TelcomEnabled);
 		printf("%s\n", json_object_to_json_string(jobj3));
 		json_object_put(jobj3);
 

+ 1 - 0
EVSE/Projects/define.h

@@ -315,6 +315,7 @@ struct TeleConfigData
 	unsigned char		TelcomModemMode;			//0: No services, 1: CDMA, 2: GSM/GPRS, 3: WCDMA, 4: GSM/WCDMA, 5: TD_SCDMA mode, 6: Unknow
 	unsigned char		TelcomIpAddress[16];		//default: Null
 	unsigned char		TelcomNetworkConn;			//0: disconnected, 1: connected
+	unsigned char		TelcomEnabled;				//0: disable, 1: enable
 };
 
 struct BtConfigData

+ 3 - 2
EVSE/rootfs/var/www/log_download.php

@@ -69,7 +69,8 @@ img {
 		// 發送 Ajax 查詢請求並處理
 		var request = new XMLHttpRequest();
 		request.open("POST", "log_download_action.php");
-
+		var d=new Date();
+		var now=d.getFullYear() + ("00" + (d.getMonth() + 1)).slice(-2) + ("00" + d.getDate()).slice(-2) + ("00" + d.getHours()).slice(-2) + ("00" + d.getMinutes()).slice(-2) + ("00" + d.getSeconds()).slice(-2);
 		// POST 參數須使用 send() 發送
 		var data = "name=";
 
@@ -89,7 +90,7 @@ img {
 					var link = document.createElement("a");
 //					link.download = "/mnt/log.zip";
 					link.href = "/mnt/log.zip";
-					link.download="log.zip";
+					link.download="log"+now+".zip";
 					var ev = new MouseEvent("click", {"bubbles":true, "cancelable":true});
 					link.dispatchEvent(ev);
 				} else {

+ 10 - 2
EVSE/rootfs/var/www/set_network.php

@@ -187,7 +187,7 @@ img {
 											<select class="form-control" id="WifiMode" name="WifiMode" onchange="WifiMode_changed();">
 												<option value="0" <?php echo $obj->{'WifiMode'}=="0"?"selected":""?>>disable</option>
 												<option value="1" <?php echo $obj->{'WifiMode'}=="1"?"selected":""?>>station</option>
-												<option value="2" <?php echo $obj->{'WifiMode'}=="2"?"selected":""?>>Acess Point</option>
+												<option value="2" <?php echo $obj->{'WifiMode'}=="2"?"selected":""?>>Access Point</option>
 <?php /*												<option value="3" <?php echo $obj->{'WifiMode'}=="3"?"selected":""?>>Ad-Hoc</option>*/?>
 											</select>
 										</div>
@@ -246,6 +246,13 @@ img {
 								<article class="envor-sorting-item css" style="display:<?php echo $showTelcom;?>">
 									<header><?php echo $lang->showWord("3G/4G_module"); ?><i class="fa fa-plus"></i></header>
 									<section>
+										<div class="form-group">
+											<label>Mode</label>
+											<select class="form-control" id="TelcomEnabled" name="TelcomEnabled">
+												<option value="0" <?php echo $obj->{'TelcomEnabled'}=="0"?"selected":""?>>Disable</option>
+												<option value="1" <?php echo $obj->{'TelcomEnabled'}=="1"?"selected":""?>>Enable</option>
+											</select>
+										</div>
 										<div class="form-group">
 											<label>APN</label>
 											<input type="text" name="TelcomApn" id="TelcomApn" class="form-control" value="<?php echo $obj->{'TelcomApn'};?>">
@@ -377,7 +384,8 @@ img {
 						"&TelcomApn=" + document.getElementById("TelcomApn").value+
 						"&TelcomChapPapId=" + document.getElementById("TelcomChapPapId").value+
 						"&TelcomChapPapPwd=" + document.getElementById("TelcomChapPapPwd").value+
-						"&TelcomIpAddress=" + document.getElementById("TelcomIpAddress").value;
+						"&TelcomIpAddress=" + document.getElementById("TelcomIpAddress").value+
+						"&TelcomEnabled=" + document.getElementById("TelcomEnabled").value;
 
 			// POST 請求必須設置表頭在 open() 下面,send() 上面
 			request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

+ 2 - 0
EVSE/rootfs/var/www/set_network_action.php

@@ -27,6 +27,7 @@
 		checkValue("WifiMode");
 		checkValue("WifiDhcpServer");
 		checkValue("WifiDhcpClient");
+		checkValue("TelcomEnabled");
 		WifiMode_changed();
 //		$json = json_decode(file_get_contents("charging.txt"), true);
 //		$json = string[];
@@ -51,6 +52,7 @@
 		$json['TelcomChapPapId']		= $_POST['TelcomChapPapId'];
 		$json['TelcomChapPapPwd']		= $_POST['TelcomChapPapPwd'];
 		$json['TelcomIpAddress']		= $_POST['TelcomIpAddress'];
+		$json['TelcomEnabled']			= $_POST['TelcomEnabled'];
 
 //		ob_start();
 		

+ 33 - 6
EVSE/rootfs/var/www/set_system.php

@@ -137,7 +137,7 @@ img {
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
 											<label>Authentication</label>
-											<select class="form-control" id="AuthorisationMode" name="AuthorisationMode">
+											<select class="form-control" id="AuthorisationMode" name="AuthorisationMode" onchange="AuthorisationMode_changed()">
 												<option value="0" <?php echo $obj->{'AuthorisationMode'}=="0"?"selected":""?>>enable</option>
 												<option value="1" <?php echo $obj->{'AuthorisationMode'}=="1"?"selected":""?>>disable</option>
 											</select>
@@ -186,15 +186,15 @@ img {
 											<input type="text" readonly class="form-control" placeholder="<?php echo $obj->{'AcRatingCurrent'};?> amp">
 											<input type="hidden" name="AcRatingCurrent" id="AcRatingCurrent" value="<?php echo $obj->{'AcRatingCurrent'};?>">
 										</div>
-										<div class="form-group" style="display:<?php echo $am001;?>">
+										<div class="form-group" style="display:<?php echo $am001;?>" id="startMode">
 											<label id="isAPPLabel">
-											<input type="checkbox" id="isAPP" name="isAPP" <?php echo $obj->{'isAPP'}==1?"checked":"";?>>
+											<input type="checkbox" id="isAPP" name="isAPP" <?php echo $obj->{'isAPP'}==1?"checked":"";?> onclick="isAPP_clicked()">
 											APP</label>
 											<label id="isQRCodeLabel">
 											<input type="checkbox" id="isQRCode" name="isQRCode" <?php echo $obj->{'isQRCode'}==1?"checked":"";?> onclick="isQRCode_clicked()">
 											QR Code</label>
 											<label id="isRFIDLabel">
-											<input type="checkbox" id="isRFID" name="isRFID" <?php echo $obj->{'isRFID'}==1?"checked":"";?>>
+											<input type="checkbox" id="isRFID" name="isRFID" <?php echo $obj->{'isRFID'}==1?"checked":"";?> onclick="isRFID_clicked()">
 											RFID</label>
 										</div>
 										<div class="form-group" id="QRCodeMadeModeDiv">
@@ -331,6 +331,7 @@ img {
 			document.getElementById("AcModelNameDiv").style.display="none";
 		}
 		isQRCode_clicked();
+		AuthorisationMode_changed();
 		QRCodeMadeMode_changed();
 	});
 
@@ -399,10 +400,18 @@ img {
 
 	function AuthorisationMode_changed(){
 		if(document.getElementById("AuthorisationMode").value == "0"){
-			document.getElementById("AuthorisationModeText").style.display="block";
+			if(document.getElementById("ModelName").value.substr(0,1) == "D"){
+				document.getElementById("startMode").style.display="block";
+			}
+			if(document.getElementById("ModelName").value.substr(0,1) == "D" && document.getElementById("AuthorisationMode").value == "0" && !document.getElementById("isAPP").checked && !document.getElementById("isRFID").checked && !document.getElementById("isQRCode").checked){
+				alert("Please choose one of 'APP、QR code、RFID'");
+				document.getElementById("isAPP").checked=true;
+				document.getElementById("isQRCode").checked=true;
+				document.getElementById("isRFID").checked=true;
+			}
 		}
 		else{
-			document.getElementById("AuthorisationModeText").style.display="none";
+			document.getElementById("startMode").style.display="none";
 		}
 	}
 
@@ -414,6 +423,24 @@ img {
 		else{
 			document.getElementById("QRCodeMadeModeDiv").style.display="none";
 			document.getElementById("QRCodeContentDiv").style.display="none";
+			if(document.getElementById("ModelName").value.substr(0,1) == "D" && document.getElementById("AuthorisationMode").value == "0" && !document.getElementById("isAPP").checked && !document.getElementById("isRFID").checked){
+				alert("Please choose one of 'APP、QR code、RFID'");
+				document.getElementById("isQRCode").checked=true;
+			}
+		}
+	}
+
+	function isAPP_clicked(){
+		if(document.getElementById("ModelName").value.substr(0,1) == "D" && document.getElementById("AuthorisationMode").value == "0" && !document.getElementById("isQRCode").checked && !document.getElementById("isAPP").checked && !document.getElementById("isRFID").checked){
+			alert("Please choose one of 'APP、QR code、RFID'");
+			document.getElementById("isAPP").checked=true;
+		}
+	}
+
+	function isRFID_clicked(){
+		if(document.getElementById("ModelName").value.substr(0,1) == "D" && document.getElementById("AuthorisationMode").value == "0" && !document.getElementById("isQRCode").checked && !document.getElementById("isAPP").checked && !document.getElementById("isRFID").checked){
+			alert("Please choose one of 'APP、QR code、RFID'");
+			document.getElementById("isRFID").checked=true;
 		}
 	}