소스 검색

2021-11-19 / ct_chen

Actions:
1. Webservice add MaintainServerURL and MaintainServerConnStatus

Files:
1. EVSE/Modularization/WebService.c
   EVSE/rootfs/var/www/set_backend.php
   EVSE/rootfs/var/www/set_backend_action.php
ct_chen 3 년 전
부모
커밋
21015381e8
3개의 변경된 파일49개의 추가작업 그리고 6개의 파일을 삭제
  1. 12 0
      EVSE/Modularization/WebService.c
  2. 20 0
      EVSE/rootfs/var/www/set_backend.php
  3. 17 6
      EVSE/rootfs/var/www/set_backend_action.php

+ 12 - 0
EVSE/Modularization/WebService.c

@@ -1004,6 +1004,7 @@ int main(int argc, char *argv[]) {
 			char *OcppSecurityPassword=NULL;
 			int isEnableLocalPowerSharging=0;
 			char *OcppReceiptrURL=NULL;
+			char *MaintainServerURL=NULL;
 			/*for TTIA*/
 			char isEnableTTIA=0;
 			char *server_addr=NULL;
@@ -1058,6 +1059,10 @@ int main(int argc, char *argv[]) {
 				OcppReceiptrURL = (char*)json_object_get_string(val_obj);
 				strcpy((char *)&ShmSysConfigAndInfo->SysConfig.OcppReceiptrURL,OcppReceiptrURL);
 			}
+			if( json_object_object_get_ex(jobj, "MaintainServerURL", &val_obj) ) {
+				MaintainServerURL = (char*)json_object_get_string(val_obj);
+				strcpy((char *)&ShmSysConfigAndInfo->SysConfig.MaintainServerURL,MaintainServerURL);
+			}
 			/*for TTIA*/
 			if( json_object_object_get_ex(jobj, "isEnableTTIA", &val_obj) ) {
 				isEnableTTIA = json_object_get_int(val_obj);
@@ -1241,6 +1246,7 @@ int main(int argc, char *argv[]) {
 			ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy=0;
 			ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration=0;
 			ShmSysConfigAndInfo->SysInfo.OcppConnStatus=0;
+			ShmSysConfigAndInfo->SysInfo.MaintainServerConnStatus=0;
 			strcpy((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,"");
 			strcpy((char *)&ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"");
 			strcpy((char *)&ShmSysConfigAndInfo->SysConfig.chargePointVendor,"Phihong");
@@ -1651,6 +1657,7 @@ int main(int argc, char *argv[]) {
 		struct json_object *OfflineMaxChargeEnergy;
 		struct json_object *OfflineMaxChargeDuration;
 		struct json_object *OcppConnStatus;
+		struct json_object *MaintainServerConnStatus;
 		struct json_object *OcppServerURL;
 		struct json_object *ChargeBoxId;
 		struct json_object *chargePointVendor;
@@ -1658,6 +1665,7 @@ int main(int argc, char *argv[]) {
 		struct json_object *OcppSecurityPassword;
 		struct json_object *isEnableLocalPowerSharging;
 		struct json_object *OcppReceiptrURL;
+		struct json_object *MaintainServerURL;
 		/*for TTIA*/
 		struct json_object *isEnableTTIA;
 		struct json_object *server_addr;
@@ -2326,11 +2334,13 @@ int main(int argc, char *argv[]) {
 		OfflineMaxChargeEnergy = json_object_new_int(ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy);
 		OfflineMaxChargeDuration = json_object_new_int(ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration);
 		OcppConnStatus = json_object_new_int(ShmSysConfigAndInfo->SysInfo.OcppConnStatus);
+		MaintainServerConnStatus = json_object_new_int(ShmSysConfigAndInfo->SysInfo.MaintainServerConnStatus);
 		OcppServerURL = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL);
 		ChargeBoxId = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
 		OcppSecurityProfile = json_object_new_int(ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile);
 		OcppSecurityPassword = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword);
 		chargePointVendor = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.chargePointVendor);
+		MaintainServerURL = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.MaintainServerURL);
 		if(strcmp(IsDO, "AX") == 0){
 			isEnableLocalPowerSharging = json_object_new_int(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharging);
 			OcppReceiptrURL = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.OcppReceiptrURL);
@@ -2745,11 +2755,13 @@ int main(int argc, char *argv[]) {
 		json_object_object_add(jobj4,"OfflineMaxChargeEnergy",OfflineMaxChargeEnergy);
 		json_object_object_add(jobj4,"OfflineMaxChargeDuration",OfflineMaxChargeDuration);
 		json_object_object_add(jobj4,"OcppConnStatus",OcppConnStatus);
+		json_object_object_add(jobj4,"MaintainServerConnStatus",MaintainServerConnStatus);
 		json_object_object_add(jobj4,"OcppServerURL",OcppServerURL);
 		json_object_object_add(jobj4,"ChargeBoxId",ChargeBoxId);
 		json_object_object_add(jobj4,"chargePointVendor",chargePointVendor);
 		json_object_object_add(jobj4,"OcppSecurityProfile",OcppSecurityProfile);
 		json_object_object_add(jobj4,"OcppSecurityPassword",OcppSecurityPassword);
+		json_object_object_add(jobj4,"MaintainServerURL",MaintainServerURL);
 		if(strcmp(IsDO, "AX") == 0){
 			json_object_object_add(jobj4,"isEnableLocalPowerSharging",isEnableLocalPowerSharging);
 			json_object_object_add(jobj4,"OcppReceiptrURL",OcppReceiptrURL);

+ 20 - 0
EVSE/rootfs/var/www/set_backend.php

@@ -262,6 +262,15 @@ CORE STYLES ABOVE - NO TOUCHY
 											</select>
 										</div>
 <?php } ?>
+										<div class="form-group" style="display:<?php echo $am101;?>">
+											<label>Maintain Server Connection Status</label>
+											<input type="text" readonly class="form-control" placeholder="<?php echo $MaintainServerConnStatus;?>">
+											<input type="hidden" name="MaintainServerConnStatus" id="MaintainServerConnStatus" value="<?php echo $obj->{'MaintainServerConnStatus'};?>">
+										</div>
+										<div class="form-group" style="display:<?php echo $am101;?>">
+											<label>Maintain Server URL</label>
+											<input type="text" name="MaintainServerURL" id="MaintainServerURL" class="form-control" value="<?php echo $obj->{'MaintainServerURL'};?>">
+										</div>
 									</section>
 								</article>
 <?php if(substr($ModelName,0,1)=="D" && substr($ModelName,3,1)=="C"){ ?>
@@ -352,6 +361,7 @@ CORE STYLES ABOVE - NO TOUCHY
 						"&OfflineMaxChargeDuration=" + document.getElementById("OfflineMaxChargeDuration").value+
 //						"&OcppConnStatus=" + document.getElementById("OcppConnStatus").value+
 						"&OcppServerURL=" + escape(document.getElementById("OcppServerURL").value)+
+						"&MaintainServerURL=" + escape(document.getElementById("MaintainServerURL").value)+
 						"&ChargeBoxId=" + escape(document.getElementById("ChargeBoxId").value)+
 						"&chargePointVendor=" + escape(document.getElementById("chargePointVendor").value)+
 						"&OcppSecurityProfile=" + document.getElementById("OcppSecurityProfile").value+
@@ -394,6 +404,7 @@ CORE STYLES ABOVE - NO TOUCHY
 	function formCheck()
 	{
 		var OcppServerURL = document.getElementById("OcppServerURL").value;
+		var MaintainServerURL = document.getElementById("MaintainServerURL").value;
 		var ChargeBoxId = document.getElementById("ChargeBoxId").value;
 		var chargePointVendor = document.getElementById("chargePointVendor").value;
 		var tests=/^(ws|wss):\/\/((([0-9]{1,3}\.){3}[0-9]{1,3})|(([a-zA-Z0-9]+(([\-]?[a-zA-Z0-9]+)*\.)+)*[a-zA-Z]{2,}))+/;
@@ -404,6 +415,13 @@ CORE STYLES ABOVE - NO TOUCHY
 				return false;
 			}
 		}
+		if(MaintainServerURL!=""){
+			if(MaintainServerURL.match(tests)==null){
+				alert("MaintainServerURL format error!");
+				document.getElementById("MaintainServerURL").focus();
+				return false;
+			}
+		}
 		if(ChargeBoxId!=""){
 			if(ChargeBoxId.length>25){
 				alert("Length of ChargeBoxId should be less than 25!");
@@ -483,11 +501,13 @@ CORE STYLES ABOVE - NO TOUCHY
 	function isEnableLocalPowerSharging_changed(){
 		if(document.getElementById("isEnableLocalPowerSharging").selectedIndex==1){
 			document.getElementById("OcppServerURL").setAttribute("readOnly","true");
+			document.getElementById("MaintainServerURL").setAttribute("readOnly","true");
 			document.getElementById("ChargeBoxId").setAttribute("readOnly","true");
 			document.getElementById("chargePointVendor").setAttribute("readOnly","true");
 		}
 		else{
 			document.getElementById("OcppServerURL").removeAttribute("readOnly");
+			document.getElementById("MaintainServerURL").removeAttribute("readOnly");
 			document.getElementById("ChargeBoxId").removeAttribute("readOnly");
 			document.getElementById("chargePointVendor").removeAttribute("readOnly");
 		}

+ 17 - 6
EVSE/rootfs/var/www/set_backend_action.php

@@ -21,6 +21,14 @@
 				return false;
 			}
 		}
+		if($_REQUEST['MaintainServerURL']!=""){
+			if(!preg_match($pattern, $_REQUEST['MaintainServerURL'])){
+				$jsone['result'] = "Fail";
+				$jsone['message'] = "MaintainServerURL format error, fill it with 'ws://' or 'wss://'";
+				echo json_encode($jsone);
+				return false;
+			}
+		}
 		checkValue("OfflinePolicy");
 		checkLength("ChargeBoxId",25);
 		checkLength("chargePointVendor",20);
@@ -39,6 +47,9 @@
 		if(isset($_REQUEST['OcppServerURL'])){
 			$json['OcppServerURL']				= str_replace("&amp;","&",str_replace("&quot;",'"',str_replace("&#039;","'",str_replace("&lt;","<",str_replace("&gt;",">",$_REQUEST['OcppServerURL'])))));
 		}
+		if(isset($_REQUEST['MaintainServerURL'])){
+			$json['MaintainServerURL']			= str_replace("&amp;","&",str_replace("&quot;",'"',str_replace("&#039;","'",str_replace("&lt;","<",str_replace("&gt;",">",$_REQUEST['MaintainServerURL'])))));
+		}
 		if(isset($_REQUEST['ChargeBoxId'])){
 			$json['ChargeBoxId']				= str_replace("&amp;","&",str_replace("&quot;",'"',str_replace("&#039;","'",str_replace("&lt;","<",str_replace("&gt;",">",$_REQUEST['ChargeBoxId'])))));
 		}
@@ -54,14 +65,14 @@
 		}
 		if(isset($_REQUEST['isEnableLocalPowerSharging'])){
 			checkValue("isEnableLocalPowerSharging");
-			$json['isEnableLocalPowerSharging']		= (int)$_REQUEST['isEnableLocalPowerSharging'];
+			$json['isEnableLocalPowerSharging']	= (int)$_REQUEST['isEnableLocalPowerSharging'];
 		}
 		if(isset($_REQUEST['OcppReceiptrURL'])){
-			$json['OcppReceiptrURL']		= str_replace("&amp;","&",str_replace("&quot;",'"',str_replace("&#039;","'",str_replace("&lt;","<",str_replace("&gt;",">",$_REQUEST['OcppReceiptrURL'])))));
+			$json['OcppReceiptrURL']			= str_replace("&amp;","&",str_replace("&quot;",'"',str_replace("&#039;","'",str_replace("&lt;","<",str_replace("&gt;",">",$_REQUEST['OcppReceiptrURL'])))));
 		}
 		if(isset($_REQUEST['isEnableTTIA'])){
 			checkValue("isEnableTTIA");
-			$json['isEnableTTIA']		= (int)$_REQUEST['isEnableTTIA'];
+			$json['isEnableTTIA']				= (int)$_REQUEST['isEnableTTIA'];
 		}
 		if(isset($_REQUEST['server_addr'])){
 			$json['server_addr']				= str_replace("&amp;","&",str_replace("&quot;",'"',str_replace("&#039;","'",str_replace("&lt;","<",str_replace("&gt;",">",$_REQUEST['server_addr'])))));
@@ -76,15 +87,15 @@
 		}
 		if(isset($_REQUEST['EquipmentProvider'])){
 			checkLength("EquipmentProvider",15);
-			$json['EquipmentProvider']				= str_replace("&amp;","&",str_replace("&quot;",'"',str_replace("&#039;","'",str_replace("&lt;","<",str_replace("&gt;",">",$_REQUEST['EquipmentProvider'])))));
+			$json['EquipmentProvider']			= str_replace("&amp;","&",str_replace("&quot;",'"',str_replace("&#039;","'",str_replace("&lt;","<",str_replace("&gt;",">",$_REQUEST['EquipmentProvider'])))));
 		}
 		if(isset($_REQUEST['TransportationCompanyNo'])){
 			isNumeric("TransportationCompanyNo",255);
-			$json['TransportationCompanyNo']				= (int)$_REQUEST['TransportationCompanyNo'];
+			$json['TransportationCompanyNo']	= (int)$_REQUEST['TransportationCompanyNo'];
 		}
 		if(isset($_REQUEST['TTIAChargeBoxId'])){
 			isNumeric("TTIAChargeBoxId",255);
-			$json['TTIAChargeBoxId']				= (int)$_REQUEST['TTIAChargeBoxId'];
+			$json['TTIAChargeBoxId']			= (int)$_REQUEST['TTIAChargeBoxId'];
 		}
 		if(isset($_REQUEST['evseStation'])){
 			checkLength("evseStation",15);