Bläddra i källkod

2020-03-10 / ct_chen

Actions:
1. Webservice fix bug

Files:
1. as list
ct_chen 5 år sedan
förälder
incheckning
a159079bbf

+ 12 - 6
EVSE/Modularization/WebService.c

@@ -478,7 +478,7 @@ int main(int argc, char *argv[]) {
 			int WifiMode=0;
 			char *WifiSsid=NULL;
 			char *WifiPassword=NULL;
-			// int WifiDhcpServer=0;
+			int WifiDhcpServer=0;
 			int WifiDhcpClient=0;
 			char *WifiIpAddress=NULL;
 			char *WifiSubmaskAddress=NULL;
@@ -523,9 +523,9 @@ int main(int argc, char *argv[]) {
 			if( json_object_object_get_ex(jobj, "WifiPassword", &val_obj) ) {
 				WifiPassword = (char*)json_object_get_string(val_obj);
 			}
-			// if( json_object_object_get_ex(jobj, "WifiDhcpServer", &val_obj) ) {
-				// WifiDhcpServer = json_object_get_int(val_obj);
-			// }
+			if( json_object_object_get_ex(jobj, "WifiDhcpServer", &val_obj) ) {
+				WifiDhcpServer = json_object_get_int(val_obj);
+			}
 			if( json_object_object_get_ex(jobj, "WifiDhcpClient", &val_obj) ) {
 				WifiDhcpClient = json_object_get_int(val_obj);
 			}
@@ -563,7 +563,7 @@ int main(int argc, char *argv[]) {
 			ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode=WifiMode;
 			strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid,WifiSsid);
 			strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword,WifiPassword);
-			// ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpServer=WifiDhcpServer;
+			ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpServer=WifiDhcpServer;
 			ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpClient=WifiDhcpClient;
 			strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiIpAddress,WifiIpAddress);
 			strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSubmaskAddress,WifiSubmaskAddress);
@@ -768,13 +768,19 @@ int main(int argc, char *argv[]) {
 		#endif
 		}
 		if (strcmp(argv[1], "log") == 0) {
+			unsigned char			ModelName[64];;
+			unsigned char			SerialNo[64];;
+			memcpy(ModelName,ShmSysConfigAndInfo->SysConfig.ModelName,ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.ModelName));
+			printf("%s", ModelName);
+			memcpy(SerialNo,ShmSysConfigAndInfo->SysConfig.SerialNumber,ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.SerialNumber));
+			printf("%s", SerialNo);
 			time_t tt = time(0); //獲取當前時間
 			int year,month;
 			char cmd[100];
 			struct tm *pst = localtime(&tt); //把time_t類型轉換為struct tm類型
 			year = pst->tm_year + 1900;
 			month = pst->tm_mon + 1;
-			sprintf(cmd,"cp /mnt/*%04d-%02d.zip /var/www/log.zip",year,month);
+			sprintf(cmd,"cp /mnt/*%s*%s*.zip /var/www/log.zip",ModelName,SerialNo);
 			if(system("exec /root/logPackTools 'log'")==0){
 				system(cmd);
 			}

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

@@ -60,7 +60,7 @@ img {
 											<label>Offline Policy</label>
 											<select class="form-control" id="OfflinePolicy" name="OfflinePolicy">
 												<option value="0" <?php echo $obj->{'OfflinePolicy'}=="0"?"selected":""?>>local list</option>
-												<option value="1" <?php echo $obj->{'OfflinePolicy'}=="1"?"selected":""?>>Phihong RFID tag</option>
+<?php /*												<option value="1" <?php echo $obj->{'OfflinePolicy'}=="1"?"selected":""?>>Phihong RFID tag</option>*/?>
 												<option value="2" <?php echo $obj->{'OfflinePolicy'}=="2"?"selected":""?>>free charging</option>
 												<option value="3" <?php echo $obj->{'OfflinePolicy'}=="3"?"selected":""?>>no charging</option>
 											</select>

+ 31 - 4
EVSE/rootfs/var/www/set_charging.php

@@ -280,24 +280,28 @@ img {
 										<div class="form-group" style="display:<?php echo $am111;?>">
 											<label>Max Charging Energy</label>
 											<small class="form-text text-muted-red">kWh</small>
-											<input type="text" name="MaxChargingEnergy" id="MaxChargingEnergy" class="form-control" value="<?php echo $obj['MaxChargingEnergy'];?>" placeholder="<?php echo ($obj['MaxChargingEnergy']==0||$obj['MaxChargingEnergy']=="")?"'0' means unlimit":"";?>">
+											<input type="text" name="MaxChargingEnergy" id="MaxChargingEnergy" class="form-control" value="<?php echo $obj['MaxChargingEnergy'];?>" placeholder="<?php echo ($obj['MaxChargingEnergy']==0||$obj['MaxChargingEnergy']=="")?"'0' means unlimit":"";?>" title="'0' means unlimit" onchange="MaxValue_changed(document.getElementById('MaxChargingEnergy').id,document.getElementById('MaxChargingEnergyText').id);">
+											<small class="form-text text-muted-red"><label id="MaxChargingEnergyText" style="display:none;">'0' means unlimit</label></small>
 										</div>
 										<div class="form-group" style="display:<?php echo $am001;?>">
 											<label>Max Charging Power</label>
 											<small class="form-text text-muted-red">kW</small>
-											<input type="text" name="MaxChargingPower" id="MaxChargingPower" class="form-control" value="<?php echo $obj['MaxChargingPower'];?>" placeholder="<?php echo ($obj['MaxChargingEnergy']==0||$obj['MaxChargingEnergy']=="")?"'0' means unlimit":"";?>">
+											<input type="text" name="MaxChargingPower" id="MaxChargingPower" class="form-control" value="<?php echo $obj['MaxChargingPower'];?>" placeholder="<?php echo ($obj['MaxChargingPower']==0||$obj['MaxChargingPower']=="")?"'0' means unlimit":"";?>" title="'0' means unlimit" onchange="MaxValue_changed(document.getElementById('MaxChargingPower').id,document.getElementById('MaxChargingPowerText').id);">
 											<input type="hidden" name="RatingPower" id="RatingPower" value="<?php echo $RatingPower;?>">
+											<small class="form-text text-muted-red"><label id="MaxChargingPowerText" style="display:none;">'0' means unlimit</label></small>
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
 											<label>Max Charging Current</label>
 											<small class="form-text text-muted-red">amp</small>
-											<input type="text" name="MaxChargingCurrent" id="MaxChargingCurrent" class="form-control" value="<?php echo $obj['MaxChargingCurrent'];?>" placeholder="<?php echo ($obj['MaxChargingEnergy']==0||$obj['MaxChargingEnergy']=="")?"'0' means unlimit":"";?>">
+											<input type="text" name="MaxChargingCurrent" id="MaxChargingCurrent" class="form-control" value="<?php echo $obj['MaxChargingCurrent'];?>" placeholder="<?php echo ($obj['MaxChargingCurrent']==0||$obj['MaxChargingCurrent']=="")?"'0' means unlimit":"";?>" title="'0' means unlimit" onchange="MaxValue_changed(document.getElementById('MaxChargingCurrent').id,document.getElementById('MaxChargingCurrentText').id);">
 											<input type="hidden" name="RatingCurrent" id="RatingCurrent" value="<?php echo $RatingCurrent;?>">
+											<small class="form-text text-muted-red"><label id="MaxChargingCurrentText" style="display:none;">'0' means unlimit</label></small>
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
 											<label>Max Charging Duration</label>
 											<small class="form-text text-muted-red">minutes</small>
-											<input type="text" name="MaxChargingDuration" id="MaxChargingDuration" class="form-control" value="<?php echo $obj['MaxChargingDuration'];?>" placeholder="<?php echo ($obj['MaxChargingEnergy']==0||$obj['MaxChargingEnergy']=="")?"'0' means unlimit":"";?>">
+											<input type="text" name="MaxChargingDuration" id="MaxChargingDuration" class="form-control" value="<?php echo $obj['MaxChargingDuration'];?>" placeholder="<?php echo ($obj['MaxChargingDuration']==0||$obj['MaxChargingDuration']=="")?"'0' means unlimit":"";?>" title="'0' means unlimit" onchange="MaxValue_changed(document.getElementById('MaxChargingDuration').id,document.getElementById('MaxChargingDurationText').id);">
+											<small class="form-text text-muted-red"><label id="MaxChargingDurationText" style="display:none;">'0' means unlimit</label></small>
 										</div>
 										<div class="form-group" style="display:<?php echo $am001;?>">
 											<label>AC Phase Loss Policy</label>
@@ -627,6 +631,20 @@ img {
 ?>
 
 <script type="text/JavaScript">
+	$(document).ready(function(){
+		if(document.getElementById("MaxChargingEnergy").value=="0" || document.getElementById("MaxChargingEnergy").value==""){
+			document.getElementById("MaxChargingEnergyText").style.display="block";
+		}
+		if(document.getElementById("MaxChargingPower").value=="0" || document.getElementById("MaxChargingPower").value==""){
+			document.getElementById("MaxChargingPowerText").style.display="block";
+		}
+		if(document.getElementById("MaxChargingCurrent").value=="0" || document.getElementById("MaxChargingCurrent").value==""){
+			document.getElementById("MaxChargingCurrentText").style.display="block";
+		}
+		if(document.getElementById("MaxChargingDuration").value=="0" || document.getElementById("MaxChargingDuration").value==""){
+			document.getElementById("MaxChargingDurationText").style.display="block";
+		}
+	});
 
 	document.getElementById("save").onclick = function() {
 		if(formCheck())
@@ -838,6 +856,15 @@ img {
 		return true;
 	}
 
+	function MaxValue_changed(id,id2){
+		if(document.getElementById(id).value == "0" || document.getElementById(id).value == ""){
+			document.getElementById(id2).style.display="block";
+		}
+		else{
+			document.getElementById(id2).style.display="none";
+		}
+	}
+
 	function isNumberKey(evt)
 	{
 		var charCode = (evt.which) ? evt.which : event.keyCode

+ 39 - 6
EVSE/rootfs/var/www/set_network.php

@@ -181,11 +181,11 @@ img {
 									<section>
 										<div class="form-group" style="display:<?php echo $am101;?>">
 											<label>Mode</label>
-											<select class="form-control" id="WifiMode" name="WifiMode">
+											<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>
-<?php /*												<option value="2" <?php echo $obj->{'WifiMode'}=="2"?"selected":""?>>Acess Point</option>
-												<option value="3" <?php echo $obj->{'WifiMode'}=="3"?"selected":""?>>Ad-Hoc</option>*/?>
+												<option value="2" <?php echo $obj->{'WifiMode'}=="2"?"selected":""?>>Acess Point</option>
+<?php /*												<option value="3" <?php echo $obj->{'WifiMode'}=="3"?"selected":""?>>Ad-Hoc</option>*/?>
 											</select>
 										</div>
 										<div class="form-group" style="display:<?php echo $am101;?>">
@@ -201,13 +201,13 @@ img {
 											<input type="text" readonly class="form-control" placeholder="<?php echo $obj->{'WifiRssi'};?> dBm">
 											<input type="hidden" name="WifiRssi" id="WifiRssi" value="<?php echo $obj->{'WifiRssi'};?>">
 										</div>
-<?php /*										<div class="form-group" style="display:<?php echo $am101;?>">
+										<div class="form-group" style="display:<?php echo $am101;?>">
 											<label>Dhcp Server</label>
 											<select class="form-control" id="WifiDhcpServer" name="WifiDhcpServer">
 												<option value="0" <?php echo $obj->{'WifiDhcpServer'}=="0"?"selected":""?>>enable</option>
 												<option value="1" <?php echo $obj->{'WifiDhcpServer'}=="1"?"selected":""?>>disable</option>
 											</select>
-										</div>*/?>
+										</div>
 										<div class="form-group" style="display:<?php echo $am101;?>">
 											<label>Dhcp Client</label>
 											<select class="form-control" id="WifiDhcpClient" name="WifiDhcpClient">
@@ -338,6 +338,20 @@ img {
 ?>
 
 <script type="text/JavaScript">
+	$(document).ready(function(){
+		if(document.getElementById("WifiMode").value=="0"){
+			document.getElementById("WifiDhcpServer").disabled=true;
+			document.getElementById("WifiDhcpClient").disabled=true;
+		}
+		if(document.getElementById("WifiMode").value=="1"){
+			document.getElementById("WifiDhcpServer").disabled=true;
+			document.getElementById("WifiDhcpClient").disabled=false;
+		}
+		if(document.getElementById("WifiMode").value=="2"){
+			document.getElementById("WifiDhcpServer").disabled=false;
+			document.getElementById("WifiDhcpClient").disabled=true;
+		}
+	});
 
 	document.getElementById("save").onclick = function() {
 		if(formCheck())
@@ -361,7 +375,7 @@ img {
 						"&WifiMode=" + document.getElementById("WifiMode").value+
 						"&WifiSsid=" + document.getElementById("WifiSsid").value+
 						"&WifiPassword=" + document.getElementById("WifiPassword").value+
-						// "&WifiDhcpServer=" + document.getElementById("WifiDhcpServer").value+
+						"&WifiDhcpServer=" + document.getElementById("WifiDhcpServer").value+
 						"&WifiDhcpClient=" + document.getElementById("WifiDhcpClient").value+
 						"&WifiIpAddress=" + document.getElementById("WifiIpAddress").value+
 						"&WifiSubmaskAddress=" + document.getElementById("WifiSubmaskAddress").value+
@@ -428,6 +442,25 @@ img {
 		return true;
 	}
 
+	function WifiMode_changed(){
+		if(document.getElementById("WifiMode").value=="0"){
+			document.getElementById("WifiDhcpServer").disabled=true;
+			document.getElementById("WifiDhcpClient").disabled=true;
+		}
+		if(document.getElementById("WifiMode").value=="2"){
+			document.getElementById("WifiDhcpServer").disabled=false;
+			document.getElementById("WifiDhcpClient").disabled=true;
+		}
+		if(document.getElementById("WifiMode").value=="1"){
+			document.getElementById("WifiDhcpServer").disabled=true;
+			document.getElementById("WifiDhcpClient").disabled=false;
+		}
+		if(document.getElementById("WifiMode").value=="2"){
+			document.getElementById("WifiDhcpServer").disabled=false;
+			document.getElementById("WifiDhcpClient").disabled=true;
+		}
+	}
+
 	function isNumberKey(evt)
 	{
 		var charCode = (evt.which) ? evt.which : event.keyCode

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

@@ -25,7 +25,7 @@
 		checkValue("Eth0DhcpClient");
 		// checkValue("Eth1DhcpClient");
 		checkValue("WifiMode");
-		// checkValue("WifiDhcpServer");
+		checkValue("WifiDhcpServer");
 		checkValue("WifiDhcpClient");
 //		$json = json_decode(file_get_contents("charging.txt"), true);
 //		$json = string[];
@@ -41,7 +41,7 @@
 		$json['WifiMode']				= $_POST['WifiMode'];
 		$json['WifiSsid']				= $_POST['WifiSsid'];
 		$json['WifiPassword']			= $_POST['WifiPassword'];
-		// $json['WifiDhcpServer']			= $_POST['WifiDhcpServer'];
+		$json['WifiDhcpServer']			= $_POST['WifiDhcpServer'];
 		$json['WifiDhcpClient']			= $_POST['WifiDhcpClient'];
 		$json['WifiIpAddress']			= $_POST['WifiIpAddress'];
 		$json['WifiSubmaskAddress']		= $_POST['WifiSubmaskAddress'];