Selaa lähdekoodia

2020-02-27 / Kathy Yeh
1. modify HeartBeat not sent issue
2. modify CpIccid size to 22

Kathy_Yeh 5 vuotta sitten
vanhempi
commit
1ca84376a8

+ 12 - 16
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -44,7 +44,6 @@
 
 
 
-
 #define PASS				1
 #define FAIL				-1
 
@@ -1171,8 +1170,11 @@ void CheckSystemValue(void)
 	//===============================
 	// send Heartbeat
 	//===============================
+	//printf("server_sign=%d\n",server_sign);
+	//printf("HeartBeatWaitTime=%d\n",HeartBeatWaitTime);
 	if((server_sign == TRUE) && (difftime(time((time_t*)NULL), clientTime.Heartbeat) >= HeartBeatWaitTime)/*((time((time_t*)NULL)-clientTime.Heartbeat)>= ShmOCPP16Data->BootNotification.ResponseHeartbeatInterval)*/)
 	{
+		printf("Heartbeat !!!\n");
 		//parameter for test
 		sendHeartbeatRequest(0);
 	    //==============================================
@@ -1994,14 +1996,6 @@ int sendStartTransactionRequest(int gun_index)
 	sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
 	strcat(buf,usec_buf);
 #endif
-	//printf("Start Charging Time :%s",buf);
-
-    // set value
-	//if(ShmOCPP16Data->OcppConnStatus == 1 )
-	//{
-		//memset(&ShmOCPP16Data->StartTransaction[gun_index], 0, sizeof(ShmOCPP16Data->StartTransaction[gun_index])); // Clear StartTransaction Value
-
-	//}
 
 	ShmOCPP16Data->StartTransaction[gun_index].ConnectorId = gun_index +1 ; // gun start from 1~
 	strcpy((char *)ShmOCPP16Data->StartTransaction[gun_index].Timestamp, buf);
@@ -6304,8 +6298,8 @@ int handleGetDiagnosticsRequest(char *uuid, char *payload)
 	mtrace();
 	int result = FAIL;
 	//void *ret; //
-	char fnamePlusPath[50]="";
-	char fname[16]="";
+	char fnamePlusPath[100]="";
+	char fname[40]="";
 	pthread_t t; // pthread 變數
 	time_t rawtime;
 	struct tm * timeinfo;
@@ -6322,7 +6316,7 @@ int handleGetDiagnosticsRequest(char *uuid, char *payload)
 	if((access(fnamePlusPath,F_OK))!=-1)
 	{
 		DEBUG_INFO("fnamePlusPath exist.\n");
-		strftime (fname,sizeof(fname),"%4Y-%2m.zip",timeinfo);
+		strftime (fname,sizeof(fname),"%4Y-%2m-%d-%H-%M-%S.zip",timeinfo);
 	}
 	else
 	{
@@ -6349,8 +6343,8 @@ void* GetDiagnosticsProcess(void* data)
 	int retriesIsNULL,retryIntervalIsNULL, startTimeIsNULL, stopTimeIsNULL;
 	char protocol[10]={0}, user[50]={0},password[50]={0},host[50]={0}, path[50]={0}, ftppath[60]={0},host1[50]={0},path1[50]={0};
 	int port=0;
-	char fnamePlusPath[50]="";//="00000_2019-06-09_160902_CSULog.zip";
-	char fname[16]="";
+	char fnamePlusPath[100]="";//="00000_2019-06-09_160902_CSULog.zip";
+	char fname[40]="";
 	char sstr[260]={ 0 };//sstr[200]={ 0 };
 	int c = 0;
 	char *loc;
@@ -6366,7 +6360,7 @@ void* GetDiagnosticsProcess(void* data)
 
 	retriesIsNULL = retryIntervalIsNULL = startTimeIsNULL = stopTimeIsNULL = FALSE;
 
-	DEBUG_INFO("sendDiagnosticsStatusNotificationRequest 1\n");
+	DEBUG_INFO("GetDiagnosticsProcess\n");
 	sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatus_Uploading]);
 
 	//****************location*******************/
@@ -6488,7 +6482,7 @@ void* GetDiagnosticsProcess(void* data)
 	//printf("%ld\n", rawtime);
 	timeinfo = localtime (&rawtime);
 	strftime (fnamePlusPath,sizeof(fnamePlusPath),"../mnt/%4Y-%2m.zip",timeinfo);
-	strftime (fname,sizeof(fname),"%4Y-%2m.zip",timeinfo);
+	strftime (fname,sizeof(fname),"%4Y-%2m-%d-%H-%M-%S.zip",timeinfo);
 	DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
 	if((access(fnamePlusPath,F_OK))!=-1)
 	{
@@ -10105,6 +10099,7 @@ void handleBootNotificationResponse(char *payload, int gun_index)
 
 	BootNotificationInterval = ShmOCPP16Data->BootNotification.ResponseHeartbeatInterval = intervalInt;
 	HeartBeatWaitTime = BootNotificationInterval;
+	clientTime.Heartbeat=time((time_t*)NULL);
 
 
 //#ifdef SystemLogMessage
@@ -13691,6 +13686,7 @@ int ftpFile(char *location, char *user, char *password, int port, char *path, ch
 
 	memset(ftpbuf, 0, sizeof(ftpbuf));
 
+	/* format : ftpput -u phihong -p y42j%2f4cj84 112.91.88.35 -P 21 /2020-02.zip ../mnt/2020-02.zip*/
 	/* format : ftpput -u  username -p passwd IP  target  source*/
 	sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,port/*21*/,path,filename,fnamePlusPath);
 	DEBUG_INFO("ftpbuf=%s\n",ftpbuf);

+ 7 - 1
EVSE/Modularization/ocppfiles/Module_OcppBackend.c

@@ -38,6 +38,7 @@
 
 
 
+
 #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)
@@ -385,6 +386,7 @@ 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
@@ -424,6 +426,9 @@ static int OCPP16Callback(struct lws *wsi, enum lws_callback_reasons reason, voi
 			#ifdef SystemLogMessage
 			DEBUG_INFO("LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER\n");
 			#endif
+
+			DEBUG_OCPPMESSAGE_INFO("LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER Receive %s\n", (char *)in);
+
 			break;
 		case LWS_CALLBACK_CLIENT_ESTABLISHED://3
 			#ifdef SystemLogMessage
@@ -431,6 +436,7 @@ 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
@@ -552,7 +558,7 @@ int ConnectWsServer()
 	struct lws_client_connect_info ConnInfo;
 	int use_ssl=0;
 
-	//lws_set_log_level(LLL_PARSER | LLL_HEADER, NULL);
+	//lws_set_log_level(LLL_PARSER | LLL_HEADER | LLL_ERR | LLL_WARN | LLL_NOTICE | LLL_INFO | LLL_DEBUG | LLL_EXT | LLL_CLIENT | LLL_LATENCY  , NULL);
 
 	if(context!=NULL)
 		lws_context_destroy(context);

+ 1 - 1
EVSE/Projects/define.h

@@ -3116,7 +3116,7 @@ struct StructBootNotification
 	unsigned char CpSN[25];					//chargePointSerialNumber
 	unsigned char CbSN[25];					//chargeBoxSerialNumber
 	unsigned char CpFwVersion[50];			//firmwareVersion
-	unsigned char CpIccid[20];				//iccid
+	unsigned char CpIccid[22];				//iccid
 	unsigned char CpImsi[20];				//imsi
 	unsigned char CpMeterType[25];			//meterType
 	unsigned char CpMeterSerialNumber[25];	//meterSerialNumber