Преглед изворни кода

2021-07-12 / ct_chen

Actions:
1. Webservice "Backend" add new parameters
2. "Network" modify 3G/4G IP address disabled

Files:
1. EVSE/Modularization/WebService.c
   EVSE/rootfs/var/www/set_backend.php
   EVSE/rootfs/var/www/set_backend_action.php
2. EVSE/rootfs/var/www/set_network.php
ct_chen пре 3 година
родитељ
комит
c6f4f76354

+ 16 - 0
EVSE/Modularization/WebService.c

@@ -995,6 +995,8 @@ int main(int argc, char *argv[]) {
 			char *OcppServerURL=NULL;
 			char *ChargeBoxId=NULL;
 			char *chargePointVendor=NULL;
+			int OcppSecurityProfile=0;
+			char *OcppSecurityPassword=NULL;
 			int isEnableLocalPowerSharging=0;
 
 			if( json_object_object_get_ex(jobj, "BackendConnTimeout", &val_obj) ) {
@@ -1025,6 +1027,14 @@ int main(int argc, char *argv[]) {
 				chargePointVendor = (char*)json_object_get_string(val_obj);
 				strcpy((char *)&ShmSysConfigAndInfo->SysConfig.chargePointVendor,chargePointVendor);
 			}
+			if( json_object_object_get_ex(jobj, "OcppSecurityProfile", &val_obj) ) {
+				OcppSecurityProfile = json_object_get_int(val_obj);
+				ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile = OcppSecurityProfile;
+			}
+			if( json_object_object_get_ex(jobj, "OcppSecurityPassword", &val_obj) ) {
+				OcppSecurityPassword = (char*)json_object_get_string(val_obj);
+				strcpy((char *)&ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword,OcppSecurityPassword);
+			}
 			if( json_object_object_get_ex(jobj, "isEnableLocalPowerSharging", &val_obj) ) {
 				isEnableLocalPowerSharging = json_object_get_int(val_obj);
 				ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharging = isEnableLocalPowerSharging;
@@ -1561,6 +1571,8 @@ int main(int argc, char *argv[]) {
 		struct json_object *OcppServerURL;
 		struct json_object *ChargeBoxId;
 		struct json_object *chargePointVendor;
+		struct json_object *OcppSecurityProfile;
+		struct json_object *OcppSecurityPassword;
 		struct json_object *isEnableLocalPowerSharging;
 
 		jobj1=json_object_new_object();
@@ -2167,6 +2179,8 @@ int main(int argc, char *argv[]) {
 		OcppConnStatus = json_object_new_int(ShmSysConfigAndInfo->SysInfo.OcppConnStatus);
 		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);
 		if(strcmp(IsDO, "AX") == 0){
 			isEnableLocalPowerSharging = json_object_new_int(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharging);
@@ -2520,6 +2534,8 @@ int main(int argc, char *argv[]) {
 		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);
 		if(strcmp(IsDO, "AX") == 0){
 			json_object_object_add(jobj4,"isEnableLocalPowerSharging",isEnableLocalPowerSharging);
 		}

+ 26 - 1
EVSE/rootfs/var/www/set_backend.php

@@ -100,6 +100,19 @@ img {
 											<label>Charge Point Vendor</label>
 											<input type="text" name="chargePointVendor" id="chargePointVendor" class="form-control" value="<?php echo $obj->{'chargePointVendor'};?>">
 										</div>
+										<div class="form-group" style="display:<?php echo $am101;?>">
+											<label>Ocpp Security Profile</label>
+											<select class="form-control" id="OcppSecurityProfile" name="OcppSecurityProfile" onchange="OcppSecurityProfile_changed()">
+												<option value="0" <?php echo $obj->{'OcppSecurityProfile'}=="0"?"selected":""?>>None security</option>
+												<option value="1" <?php echo $obj->{'OcppSecurityProfile'}=="1"?"selected":""?>>Unsecured Transport with Basic Atuentication</option>
+												<option value="2" <?php echo $obj->{'OcppSecurityProfile'}=="2"?"selected":""?>>TLS with Basic Authentication</option>
+												<option value="3" <?php echo $obj->{'OcppSecurityProfile'}=="3"?"selected":""?>>TLS with Client Side Certificates</option>
+											</select>
+										</div>
+										<div id="OcppSecurityPasswordDiv" class="form-group" style="display:<?php echo $am101;?>">
+											<label>Ocpp Security Password</label>
+											<input type="text" name="OcppSecurityPassword" id="OcppSecurityPassword" class="form-control" value="<?php echo $obj->{'OcppSecurityPassword'};?>">
+										</div>
 <?php if(substr($ModelName,0,2)=="AX"){?>
 										<div class="form-group" style="display:block">
 											<label>Local Loading Balance</label>
@@ -132,6 +145,7 @@ img {
 		isEnableLocalPowerSharging_changed();
 	});
 <?php } ?>
+	OcppSecurityProfile_changed();
 	document.getElementById("save").onclick = function() {
 		if(formCheck())
 		{
@@ -149,7 +163,9 @@ img {
 //						"&OcppConnStatus=" + document.getElementById("OcppConnStatus").value+
 						"&OcppServerURL=" + document.getElementById("OcppServerURL").value+
 						"&ChargeBoxId=" + document.getElementById("ChargeBoxId").value+
-						"&chargePointVendor=" + document.getElementById("chargePointVendor").value;
+						"&chargePointVendor=" + document.getElementById("chargePointVendor").value+
+						"&OcppSecurityProfile=" + document.getElementById("OcppSecurityProfile").value+
+						"&OcppSecurityPassword=" + document.getElementById("OcppSecurityPassword").value;
 <?php if(substr($ModelName,0,2)=="AX"){?>
 				data += "&isEnableLocalPowerSharging=" + document.getElementById("isEnableLocalPowerSharging").value;
 <?php } ?>
@@ -203,6 +219,15 @@ img {
 		}
 		return true;
 	}
+	function OcppSecurityProfile_changed(){
+		if(document.getElementById("OcppSecurityProfile").value == "0" || document.getElementById("OcppSecurityProfile").value == "1"){
+			document.getElementById("OcppSecurityPasswordDiv").style.display="block";
+		}
+		else{
+			document.getElementById("OcppSecurityPasswordDiv").style.display="none";
+		}
+	}
+
 <?php if(substr($ModelName,0,2)=="AX"){?>
 	function isEnableLocalPowerSharging_changed(){
 		if(document.getElementById("isEnableLocalPowerSharging").selectedIndex==1){

+ 8 - 1
EVSE/rootfs/var/www/set_backend_action.php

@@ -43,7 +43,14 @@
 			$json['ChargeBoxId']				= $_POST['ChargeBoxId'];
 		}
 		if(isset($_POST['chargePointVendor'])){
-			$json['chargePointVendor']				= $_POST['chargePointVendor'];
+			$json['chargePointVendor']			= $_POST['chargePointVendor'];
+		}
+		if(isset($_POST['OcppSecurityProfile'])){
+			checkValue("OcppSecurityProfile");
+			$json['OcppSecurityProfile']		= (int)$_POST['OcppSecurityProfile'];
+		}
+		if(isset($_POST['OcppSecurityPassword'])){
+			$json['OcppSecurityPassword']		= $_POST['OcppSecurityPassword'];
 		}
 		if(isset($_POST['isEnableLocalPowerSharging'])){
 			checkValue("isEnableLocalPowerSharging");

+ 1 - 1
EVSE/rootfs/var/www/set_network.php

@@ -304,7 +304,7 @@ img {
 										</div>
 										<div class="form-group">
 											<label>IP Address</label>
-											<input type="text" name="TelcomIpAddress" id="TelcomIpAddress" class="form-control" value="<?php echo $obj->{'TelcomIpAddress'};?>">
+											<input type="text" name="TelcomIpAddress" id="TelcomIpAddress" class="form-control" value="<?php echo $obj->{'TelcomIpAddress'};?>" disabled>
 										</div>
 										<div class="form-group">
 											<label>Network Connection Status</label>