Browse Source

2020-02-24 / Kathy Yeh
1. modify Configuration KEY ConnectionTimeOut Value as 180
2. modify Configuration KEY NumberOfVonnectors Value by Model
3. modify Configuration KEY ConnectorPhaseRotation Value as NotApplicable
4. modify UpdateFirmware / GetDiagnostics child thread execute pthread_detach(pthread_self();
5. modify Get Function for OcppServerURL / OcppPath

Kathy_Yeh 5 years ago
parent
commit
ba83bc5ef7

+ 32 - 13
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -43,6 +43,7 @@
 #include 	<mcheck.h>
 
 
+
 #define PASS				1
 #define FAIL				-1
 
@@ -115,8 +116,10 @@ static char idTagAuthorization[32]={0};
 //===============================
 // OCPP Path
 //===============================
-char OcppPath[160]={};
-char OcppProtocol[10]={0},OcppHost[50]={0}, OcppTempPath[50]={0};
+extern char OcppPath[160];
+extern char OcppProtocol[10];
+extern char OcppHost[50];
+extern char OcppTempPath[50];
 int OcppPort=0;
 
 //===============================
@@ -6467,7 +6470,7 @@ int handleGetDiagnosticsRequest(char *uuid, char *payload)
 
 	sendGetDiagnosticsConfirmation(uuid,fname/*(char*) ret*/);
 	pthread_create(&t, NULL, GetDiagnosticsProcess, payload);
-    pthread_join(t, NULL/*&ret*/);
+   // pthread_join(t, NULL/*&ret*/);
 
 	return result;
 }
@@ -6475,6 +6478,7 @@ int handleGetDiagnosticsRequest(char *uuid, char *payload)
 
 void* GetDiagnosticsProcess(void* data)
 {
+	pthread_detach(pthread_self());
 	mtrace();
 	int retriesInt=0, retryIntervalInt=0;
 	char locationstr[100]={0}, startTimestr[30]={0}, stopTimestr[30]={0} ;
@@ -6702,7 +6706,7 @@ void* GetDiagnosticsProcess(void* data)
 
 
 		do{
-			isSuccess = httpUploadFile(host, ftppath, filenametemp, locationstr);
+			isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, locationstr);
 			sleep(retryIntervalInt);
 		}while((isSuccess == 0)&&(retriesInt > 0 && retriesInt --));
 
@@ -9587,7 +9591,7 @@ int handleUpdateFirmwareRequest(char *uuid, char *payload)
 	sendUpdateFirmwareConfirmation(uuid);
 	pthread_create(&t, NULL, UpdateFirmwareProcess, payload);
 	////pthread_join(t, NULL); //
-	pthread_detach(t);
+	//pthread_detach(t);
 
 	//sendUpdateFirmwareConfirmation(uuid);
 	ShmOCPP16Data->MsMsg.bits.UpdateFirmwareConf =1;
@@ -9597,6 +9601,7 @@ int handleUpdateFirmwareRequest(char *uuid, char *payload)
 
 void *UpdateFirmwareProcess(void *data)
 {
+	pthread_detach(pthread_self());
 	mtrace();
 	int retriesInt =0, retryIntervalInt=0;
 	char protocol[10], user[50],password[50],host[50], path[50], ftppath[60],host1[50],path1[20];
@@ -10640,7 +10645,7 @@ int initialConfigurationTable(void)
 	//ConnectionTimeOut
 	ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemAccessibility = 1;
 	strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemName, "ConnectionTimeOut");
-	strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData, "60" );
+	strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData, "180" );
 
 	//GetConfigurationMaxKeys
 	ShmOCPP16Data->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemAccessibility =0;
@@ -10707,7 +10712,15 @@ int initialConfigurationTable(void)
 	// NumberOfConnectors
 	ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemAccessibility = 0;
 	strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemName, "NumberOfConnectors");
-	strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemData, "3" );
+	if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
+	{
+		sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemData, "%d", (CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY));
+	}
+	else
+	{
+		sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemData, "%d", AC_QUANTITY);
+	}
+
 
 	// ResetRetries
 	ShmOCPP16Data->ConfigurationTable.CoreProfile[ResetRetries].ItemAccessibility = 1;
@@ -12490,6 +12503,7 @@ int httpUploadFile(char *location, char *path, char *filename,char *url)
 
 	DEBUG_INFO("filename=%s\n",filename);
 	DEBUG_INFO("url=%s\n",url);
+
 	sprintf(FilePath,"%s","../mnt/upload_file.txt");
 
 	if((access(FilePath,F_OK))!=-1)
@@ -12991,9 +13005,9 @@ void OCPP_deleteIdTag(char *idTag)
 
  }
 
-char *GetOcppServerURL()
+int GetOcppServerURL()
 {
-
+    int result = FALSE;
 	memset(OcppProtocol, 0, sizeof(OcppProtocol));
 	memset(OcppHost, 0, sizeof(OcppHost));
 	memset(OcppTempPath, 0, sizeof(OcppTempPath));
@@ -13004,6 +13018,7 @@ char *GetOcppServerURL()
 		sscanf((const char *)ShmSysConfigAndInfo->SysConfig.OcppServerURL,
 						"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
 						OcppProtocol, OcppHost, &OcppPort, OcppTempPath);
+		result = TRUE;
 	//	DEBUG_INFO("OcppProtocol =%s\n",OcppProtocol);
 	//	DEBUG_INFO("OcppHost =%s\n",OcppHost);
 	//	DEBUG_INFO("OcppPort =%d\n",OcppPort);
@@ -13016,6 +13031,7 @@ char *GetOcppServerURL()
 		sscanf((const char *)ShmOCPP16Data->OcppServerURL,
 								"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
 								OcppProtocol, OcppHost, &OcppPort, OcppTempPath);
+		result = TRUE;
 	//	DEBUG_INFO("OcppProtocol =%s\n",OcppProtocol);
 	//	DEBUG_INFO("OcppHost =%s\n",OcppHost);
 	//	DEBUG_INFO("OcppPort =%d\n",OcppPort);
@@ -13029,11 +13045,12 @@ char *GetOcppServerURL()
 	}
 
 End:
-	return OcppHost;
+	return result;
 }
 
-char *GetOcppPath()
+int GetOcppPath()
 {
+	int result = FALSE;
 	if((ShmSysConfigAndInfo->SysConfig.ChargeBoxId != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"") != 0) )
 	{
 		if(OcppTempPath == NULL)
@@ -13044,6 +13061,7 @@ char *GetOcppPath()
 		{
 			sprintf(OcppPath,"/%s%s",OcppTempPath,ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
 		}
+		result = TRUE;
 		goto End;
 	}
 	else if((ShmOCPP16Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP16Data->ChargeBoxId,"") != 0))
@@ -13056,16 +13074,17 @@ char *GetOcppPath()
 		{
 			sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP16Data->ChargeBoxId);
 		}
+		result = TRUE;
 		goto End;
 	}
 	else
 	{
-		strcpy(OcppHost,"");
+		strcpy(OcppPath,"");
 	}
 
 End:
 	DEBUG_INFO("OcppPath=%s\n",OcppPath);
-	return OcppPath;
+	return result;
 }
 
 int GetOcppPort()

+ 2 - 2
EVSE/Modularization/ocppfiles/MessageHandler.h

@@ -118,8 +118,8 @@ void handleError(char *id, char *errorCode, char *errorDescription,char *payload
  //void Send(struct json_object *message);
  void LWS_Send(char * str);
 extern int queue_operation(int type, char *frontUUID, char *frontData);
-char *GetOcppServerURL();
-char *GetOcppPath();
+int GetOcppServerURL();
+int GetOcppPath();
 int GetOcppPort();
 int GetTransactionId(int gunindex);
 void SetTransactionIdZero(int gunindex);

+ 6 - 11
EVSE/Modularization/ocppfiles/Module_OcppBackend.c

@@ -55,11 +55,7 @@ struct lws 								*wsi_client;
 struct lws_context 						*context;
 static int sendbuffer = 0;
 extern int server_sign;
-//extern int TransactionMessageAttemptsValue;
-//extern int TransactionMessageRetryIntervalValue;
-//extern int server_pending;
 
-//extern struct OCPP16Data 				*ShmOCPP16Data;
 extern void CheckSystemValue(void);
 //extern int TransactionMessageAttemptsGet(void);
 extern int FirstHeartBeatResponse(void);
@@ -70,16 +66,13 @@ extern int GetOcppConnStatus(void);
 extern void SetOcppConnStatus(uint8_t status);
 extern int GetHeartBeatWithNOResponse(void);
 extern void SetHeartBeatWithNOResponse(void);
-//extern int InternetDisconnect(void);
+
 
 pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
 pthread_mutex_t lock_sentData = PTHREAD_MUTEX_INITIALIZER;
 pthread_mutex_t receiveData = PTHREAD_MUTEX_INITIALIZER;
 
 
-//struct json_object 			*parsed_json;
-
-//extern struct node Node;
 //==========================================
 // Function prototype
 //==========================================
@@ -113,6 +106,8 @@ static int TransactionQueueInterval = 10;//3; // TransactionMessageAttempts
 static int TransactionQueueNum = 0;
 static int  OfflineTransaction = 0;
 int defaultWaitingTime = 10; //10 second
+char OcppPath[160]={0};
+char OcppProtocol[10]={0},OcppHost[50]={0}, OcppTempPath[50]={0};
 
 //===============================
 // OCPP SentQueue TransactionId
@@ -591,18 +586,18 @@ int ConnectWsServer()
 	// fill up below information
 	ConnInfo.context = context;
 
-	if((strcmp((const char *)GetOcppServerURL(),"")==0) || (GetOcppPort() == 0) || (strcmp((const char *)GetOcppPath(),"")==0) )
+	if((GetOcppServerURL()==0) || (GetOcppPort() == 0) || (GetOcppPath()==0) )
 	{
 		result = FAIL;
 		DEBUG_ERROR("OCPP URL is NULL or OCPP Port is zero or  OCPP Path is NULL\n");
 		return result;
 	}
 
-	ConnInfo.address=(const char *)GetOcppServerURL();
+	ConnInfo.address=(const char *)OcppHost;
 
 	ConnInfo.port = GetOcppPort();
 
-	ConnInfo.path=(const char *)GetOcppPath();
+	ConnInfo.path=(const char *)OcppPath;
 	ConnInfo.host=lws_canonical_hostname(context);
 	ConnInfo.origin="origin";
 	ConnInfo.protocol = protocols[1].name;