Sfoglia il codice sorgente

2020-01-15 / ct_chen

Actions:
1. Webservice 增加chargePointVendor欄位

Files:
1. 如列表
ct_chen 5 anni fa
parent
commit
93b84da0b2

+ 15 - 6
EVSE/Modularization/WebService.c

@@ -273,11 +273,11 @@ int StoreUsrConfigData(struct SysConfigData *UsrData)
 				if (fd>0)
 				{
 					wrd=write(fd, BufTmp, MtdBlockSize);
-    					close(fd);
-				   	if(wrd<MtdBlockSize)
+					close(fd);
+					if(wrd<MtdBlockSize)
 					{
 						DEBUG_ERROR("write /dev/mtdblock11(backup) NG\r\n");
-				   		result = FAIL;
+						result = FAIL;
 					}
 				}
 				else
@@ -288,8 +288,8 @@ int StoreUsrConfigData(struct SysConfigData *UsrData)
 			}
 			else
 			{
-		    		DEBUG_ERROR("write /dev/mtdblock10 NG\r\n");
-		    		result = FAIL;
+				DEBUG_ERROR("write /dev/mtdblock10 NG\r\n");
+				result = FAIL;
 			}
 		}
 		else
@@ -301,7 +301,7 @@ int StoreUsrConfigData(struct SysConfigData *UsrData)
 	else
 	{
 		DEBUG_ERROR("alloc BlockSize NG\r\n");
-    	result = FAIL;
+		result = FAIL;
 	}
 
 	if(BufTmp!=NULL)
@@ -582,6 +582,7 @@ int main(int argc, char *argv[]) {
 			int OfflineMaxChargeDuration=0;
 			char *OcppServerURL=NULL;
 			char *ChargeBoxId=NULL;
+			char *chargePointVendor=NULL;
 
 			if( json_object_object_get_ex(jobj, "BackendConnTimeout", &val_obj) ) {
 				BackendConnTimeout = json_object_get_int(val_obj);
@@ -601,6 +602,9 @@ int main(int argc, char *argv[]) {
 			if( json_object_object_get_ex(jobj, "ChargeBoxId", &val_obj) ) {
 				ChargeBoxId = (char*)json_object_get_string(val_obj);
 			}
+			if( json_object_object_get_ex(jobj, "chargePointVendor", &val_obj) ) {
+				chargePointVendor = (char*)json_object_get_string(val_obj);
+			}
 
 			ShmSysConfigAndInfo->SysConfig.BackendConnTimeout = BackendConnTimeout;
 			ShmSysConfigAndInfo->SysConfig.OfflinePolicy = OfflinePolicy;
@@ -608,6 +612,7 @@ int main(int argc, char *argv[]) {
 			ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration = OfflineMaxChargeDuration;
 			strcpy((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,OcppServerURL);
 			strcpy((char *)&ShmSysConfigAndInfo->SysConfig.ChargeBoxId,ChargeBoxId);
+			strcpy((char *)&ShmSysConfigAndInfo->SysConfig.chargePointVendor,chargePointVendor);
 		}
 		struct SysConfigData 	SysConfig;
 		memcpy(&SysConfig, &ShmSysConfigAndInfo->SysConfig, sizeof(struct SysConfigData));
@@ -749,6 +754,7 @@ int main(int argc, char *argv[]) {
 		ShmSysConfigAndInfo->SysInfo.OcppConnStatus=0;
 		strcpy((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,"");
 		strcpy((char *)&ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"");
+		strcpy((char *)&ShmSysConfigAndInfo->SysConfig.chargePointVendor,"Phihong");
 
 		ShmSysConfigAndInfo->SysInfo.FirmwareUpdate=0;
 		struct SysConfigData 	SysConfig;
@@ -945,6 +951,7 @@ int main(int argc, char *argv[]) {
 		struct json_object *OcppConnStatus;
 		struct json_object *OcppServerURL;
 		struct json_object *ChargeBoxId;
+		struct json_object *chargePointVendor;
 
 //		array_obj = json_object_new_array();
 		jobj1=json_object_new_object();
@@ -1348,6 +1355,7 @@ 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);
+		chargePointVendor = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.chargePointVendor);
 
 		//system
 		json_object_object_add(jobj1,"ModelName",ModelName);
@@ -1535,6 +1543,7 @@ int main(int argc, char *argv[]) {
 		json_object_object_add(jobj4,"OcppConnStatus",OcppConnStatus);
 		json_object_object_add(jobj4,"OcppServerURL",OcppServerURL);
 		json_object_object_add(jobj4,"ChargeBoxId",ChargeBoxId);
+		json_object_object_add(jobj4,"chargePointVendor",chargePointVendor);
 		printf("%s\n", json_object_to_json_string(jobj4));
 		json_object_put(jobj4);
 	}

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

@@ -94,6 +94,10 @@ img {
 											<label>ChargeBoxId</label>
 											<input type="text" name="ChargeBoxId" id="ChargeBoxId" class="form-control" value="<?php echo $obj->{'ChargeBoxId'};?>">
 										</div>
+										<div class="form-group" style="display:<?php echo $am101;?>">
+											<label>chargePointVendor</label>
+											<input type="text" name="chargePointVendor" id="chargePointVendor" class="form-control" value="<?php echo $obj->{'chargePointVendor'};?>">
+										</div>
 									</section>
 								</article>
 								<article class="envor-sorting-item css">
@@ -128,7 +132,8 @@ img {
 						"&OfflineMaxChargeDuration=" + document.getElementById("OfflineMaxChargeDuration").value+
 //						"&OcppConnStatus=" + document.getElementById("OcppConnStatus").value+
 						"&OcppServerURL=" + document.getElementById("OcppServerURL").value+
-						"&ChargeBoxId=" + document.getElementById("ChargeBoxId").value;
+						"&ChargeBoxId=" + document.getElementById("ChargeBoxId").value+
+						"&chargePointVendor=" + document.getElementById("chargePointVendor").value;
 			
 			// POST 請求必須設置表頭在 open() 下面,send() 上面
 			request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

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

@@ -31,6 +31,7 @@
 //		$json['OcppConnStatus']				= $_POST['OcppConnStatus'];
 		$json['OcppServerURL']				= $_POST['OcppServerURL'];
 		$json['ChargeBoxId']				= $_POST['ChargeBoxId'];
+		$json['chargePointVendor']				= $_POST['chargePointVendor'];
 //		ob_start();
 		
 		shell_exec('sync;sync;sync');