Browse Source

Merge branch 'master' into DW30

FolusWen 5 years ago
parent
commit
753a527171

+ 13 - 7
EVSE/Modularization/logPackTools.c

@@ -226,17 +226,23 @@ int main(int argc, char *argv[]) {
 	return 0;
 	}
 	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);
-		int year,month,i,ty,tm,cnt;
-		char ym[7] ;
+		int year,month,day,hour,min,sec,i,ty,tm,cnt;
 		char pwd[70];
 		char cmd[100];
 		time_t tt = time(0); //獲取當前時間
 		struct tm *pst = localtime(&tt); //把time_t類型轉換為struct tm類型
 		year = pst->tm_year + 1900;
 		month = pst->tm_mon + 1;
+		day = pst->tm_mday;
+		hour = pst->tm_hour;
+		min = pst->tm_min;
+		sec = pst->tm_sec;
 		if((argc == 3) && isdigit(*argv[2])){
 			cnt=atoi(argv[2]);
 		}
@@ -252,16 +258,16 @@ int main(int argc, char *argv[]) {
 				tm=month-i;
 				ty=year;
 			}
-			sprintf(ym,"%04d-%02d",ty,tm);
 			sprintf(pwd,"%04d%02d%s",year,month,SerialNo);
-			sprintf(cmd,"zip --password %s \t /mnt/%04d-%02d.zip \t /Storage/ChargeLog/*%04d*%02d*\n",pwd,year,month,ty,tm);
+			sprintf(cmd,"zip --password %s \t /mnt/%s-%s-%04d%02d%02d%02d%02d%02d.zip \t /Storage/ChargeLog/*%04d*%02d*\n",pwd,ModelName,SerialNo,year,month,day,hour,min,sec,ty,tm);
 			system(cmd);
-			sprintf(cmd,"zip --password %s \t /mnt/%04d-%02d.zip \t /Storage/EventLog/*%04d*%02d*\n",pwd,year,month,ty,tm);
+			sprintf(cmd,"zip --password %s \t /mnt/%s-%s-%04d%02d%02d%02d%02d%02d.zip \t /Storage/EventLog/*%04d*%02d*\n",pwd,ModelName,SerialNo,year,month,day,hour,min,sec,ty,tm);
 			system(cmd);
-			sprintf(cmd,"zip --password %s \t /mnt/%04d-%02d.zip \t /Storage/SystemLog/*%04d*%02d*\n",pwd,year,month,ty,tm);
+			sprintf(cmd,"zip --password %s \t /mnt/%s-%s-%04d%02d%02d%02d%02d%02d.zip \t /Storage/SystemLog/*%04d*%02d*\n",pwd,ModelName,SerialNo,year,month,day,hour,min,sec,ty,tm);
+			system(cmd);
+			sprintf(cmd,"zip --password %s \t /mnt/%s-%s-%04d%02d%02d%02d%02d%02d.zip \t /Storage/OCPP/*%04d*%02d*\n",pwd,ModelName,SerialNo,year,month,day,hour,min,sec,ty,tm);
 			system(cmd);
 			printf("Log packing is done!\n");
-	//		zip --password "'.date('Ym').$SerialNumber.'" -r /var/www/log.zip /Storage/
 		}
 	}
 }

File diff suppressed because it is too large
+ 299 - 269
EVSE/Modularization/ocppfiles/MessageHandler.c


+ 48 - 13
EVSE/Modularization/ocppfiles/Module_OcppBackend.c

@@ -37,8 +37,6 @@
 #include	"sqlite3.h"
 
 
-
-
 #if 0
 #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
@@ -386,13 +384,38 @@ static int OCPP16Callback(struct lws *wsi, enum lws_callback_reasons reason, voi
 			#ifdef SystemLogMessage
 			DEBUG_INFO("LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH\n");
 			#endif
-			DEBUG_OCPPMESSAGE_INFO("LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH Receive %s\n", (char *)in);
-			break;
-		case LWS_CALLBACK_CLOSED_CLIENT_HTTP:
-			#ifdef SystemLogMessage
-			DEBUG_INFO("LWS_CALLBACK_CLOSED_CLIENT_HTTP\n");
-			#endif
+			char buf[64];
+
+			DEBUG_OCPPMESSAGE_INFO("------------------Handshake: Server response START----------------\n");
+
+			lws_hdr_copy(wsi, buf, sizeof(buf) - 1, WSI_TOKEN_HTTP);
+			DEBUG_OCPPMESSAGE_INFO("HTTP/1.1 %s\n", buf);
+
+			lws_hdr_copy(wsi, buf, sizeof(buf) - 1, WSI_TOKEN_UPGRADE);
+			DEBUG_OCPPMESSAGE_INFO("Upgrade: %s\n", buf);
+
+
+			lws_hdr_copy(wsi, buf, sizeof(buf) - 1, WSI_TOKEN_CONNECTION);
+			DEBUG_OCPPMESSAGE_INFO("Connection: %s\n", buf);
+
+			lws_hdr_copy(wsi, buf, sizeof(buf) - 1, WSI_TOKEN_ACCEPT);
+			DEBUG_OCPPMESSAGE_INFO("Sec-WebSocket-Accept: %s\n", buf);
+
+			lws_hdr_copy(wsi, buf, sizeof(buf) - 1, WSI_TOKEN_PROTOCOL);
+			DEBUG_OCPPMESSAGE_INFO("Sec-WebSocket-Protocol: %s\n", buf);
+
+			DEBUG_OCPPMESSAGE_INFO("------------------Handshake: Server response END----------------\n");
+
 			break;
+
+		case LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION:
+		#ifdef SystemLogMessage
+		DEBUG_INFO("LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER\n");
+		#endif
+
+
+		break;
+
 		case LWS_CALLBACK_WSI_DESTROY:
 			#ifdef SystemLogMessage
 			DEBUG_INFO("LWS_CALLBACK_WSI_DESTROY\n");
@@ -422,12 +445,25 @@ static int OCPP16Callback(struct lws *wsi, enum lws_callback_reasons reason, voi
 			break;
 		case LWS_CALLBACK_GET_THREAD_ID:
 			break;
+
 		case LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER:
-			#ifdef SystemLogMessage
-			DEBUG_INFO("LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER\n");
-			#endif
+		{
+		#ifdef SystemLogMessage
+		DEBUG_INFO("LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER\n");
+		#endif
+#if 0
+		unsigned char **p, *end;
+		struct lws *parent;
+		char buf[8192];
 
-			DEBUG_OCPPMESSAGE_INFO("LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER Receive %s\n", (char *)in);
+		parent = lws_get_parent(wsi);
+		if (!parent)
+			break;
+
+		p = (unsigned char **)in;
+		end = (*p) + len;
+#endif
+		}
 
 			break;
 		case LWS_CALLBACK_CLIENT_ESTABLISHED://3
@@ -436,7 +472,6 @@ static int OCPP16Callback(struct lws *wsi, enum lws_callback_reasons reason, voi
 			#endif
 			//connected
 			ConnectionEstablished=1;
-			DEBUG_OCPPMESSAGE_INFO("LWS_CALLBACK_CLIENT_ESTABLISHED Receive %s\n", (char *)in);
 			break;
 		case LWS_CALLBACK_CLIENT_CONNECTION_ERROR://1
 			#ifdef Debug

+ 10 - 0
EVSE/Projects/define.h

@@ -289,6 +289,13 @@ struct BtConfigData
 	unsigned char		isRequestStop;				//0: no action	1: request stop charging
 };
 
+struct BillingConfigData
+{
+	unsigned char		isBilling;					//0:not for business	1:for business
+	unsigned char		Currency;					//
+	unsigned short		Fee[24];					//fee for 24 hours
+};
+
 struct SysConfigData
 {
 	/**************System***************/
@@ -308,6 +315,8 @@ struct SysConfigData
 	unsigned short			ChademoPlugInTimes;			//0~65535
 	unsigned char 			PsuAcInputType;				//0: 220, 1: 277
 	unsigned short 			RatingCurrent;				//0: Depend on Model name,	1 ~ rating value amp
+	unsigned char			QRCodeMadeMode;				//0: default	1:customized
+	unsigned char			QRCodeContent[128];			//for QRCodeMadeMode=1
 	/**************Charging***************/
 	unsigned short	   		MaxChargingEnergy;			//0: no limit,	1 ~ 65535	kWh
 	unsigned short	   		MaxChargingPower;			//0: rating value, 1 ~ RATING_POWER	kW"
@@ -316,6 +325,7 @@ struct SysConfigData
 	unsigned char   		PhaseLossPolicy;			//0: charging,  1: stop charging
 	unsigned char   		LocalWhiteCard[10][32];		//Max. card quantity is 10
 	unsigned char 			UserId[32];					//the user use this ID to trigger charging event, it can be RFID card number, OCPP IdTag, etc.
+	struct BillingConfigData BillingData;
 	/**************Network***************/
 	unsigned char 			FtpServer[256];				//the ftp server for Phihong server to do data transimission
 	struct EthConfigData	Eth0Interface;

+ 17 - 0
EVSE/rootfs/var/www/ocpp_upload.php

@@ -0,0 +1,17 @@
+<?php
+$content=file("/mnt/upload_file.txt");
+$url = $content[0];
+$upload_file = $content[1];
+ 
+$ch = curl_init();
+ 
+curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+curl_setopt($ch, CURLOPT_URL, $url);
+ 
+### 設定要上傳檔案的路徑
+$upload_data = array(
+    'upload_file' => $upload_file,
+);
+ 
+curl_setopt($ch, CURLOPT_POSTFIELDS, $upload_data);
+?>

Some files were not shown because too many files changed in this diff