Explorar el Código

[Add][Modularization][Module_OcppBackend / /Module_OcppBackend20]

2021.09.28 / Folus Wen

Actions:
1. Module_OcppBackend add system uptime to configuration key.
2. Module_OcppBackend20 add system uptime to variable.

Files:
1. As follow commit history

Image version: D0.00.XX.XXXX.XX
Image checksum: XXXXXXXX

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen hace 3 años
padre
commit
96481fc60d

+ 33 - 3
EVSE/Modularization/ocpp20/MessageHandler.c

@@ -1729,6 +1729,14 @@ int DB_cbVariableIsCreate(void *para, int columnCount, char **columnValue, char
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].value, "3");
 		DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases]);
 
+		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].component.name, "ChargingStation");
+		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variable.name, "SystemUptimeSec");
+		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
+		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
+		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
+		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableAttribute[0].value, "0");
+		DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec]);
+
 		/* Connector Required item */
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
@@ -2665,6 +2673,9 @@ int DB_cbVariableIsCreate(void *para, int columnCount, char **columnValue, char
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
 
+		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].component.name, "ChargingStation");
+		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variable.name, "SystemUptimeSec");
+
 		/* Connector Required item */
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
@@ -14285,12 +14296,31 @@ int handleGetVariablesRequest(char *uuid, char *payload)
 					for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
 					{
 						if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) == 0) &&
-						   (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance) == 0) &&
+						   (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.instance) == 0) &&
 						   (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) == 0) &&
-						   (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance) == 0))
+						   (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.instance) == 0))
 						{
 							strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_Accepted]);
-							strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
+
+							if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, "ChargingStation") == 0) &&
+							   (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, "SystemUptimeSec") == 0))
+							{
+								struct sysinfo s_info;
+								int error = sysinfo(&s_info);
+								if(error != 0)
+								{
+									DEBUG_WARN("System uptime get error: %d\n", error);
+								}
+								else
+								{
+									sprintf((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, "%ld", s_info.uptime);
+									sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, "%ld", s_info.uptime);
+								}
+							}
+							else
+							{
+								strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
+							}
 
 							break;
 						}

+ 3 - 1
EVSE/Modularization/ocpp20/Module_OcppBackend20.h

@@ -17,16 +17,18 @@
 #include 	<sys/ipc.h>
 #include 	<sys/shm.h>
 #include 	<sys/mman.h>
+#include 	<sys/sysinfo.h>
 #include 	<linux/wireless.h>
 #include 	<linux/sockios.h>
 #include 	<linux/socket.h>
+#include 	<linux/unistd.h>
+#include 	<linux/kernel.h>
 #include 	<arpa/inet.h>
 #include 	<netinet/in.h>
 #include 	<unistd.h>
 #include 	<stdarg.h>
 #include    <stdio.h>
 #include    <stdlib.h>
-#include    <unistd.h>
 #include    <fcntl.h>
 #include    <termios.h>
 #include 	<errno.h>

+ 181 - 136
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -13939,7 +13939,7 @@ int initialConfigurationTable(void)
 	char sstr[256]={0};
 	int c = 0;
 	char *loc;
-	int	confVersion = 8;
+	int	confVersion = 9;
 
 	DEBUG_INFO("initialConfigurationTable...version: %d\n", confVersion);
 	//start_t = clock();
@@ -14306,6 +14306,13 @@ int initialConfigurationTable(void)
 
 		fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","TimeOffsetNextTransition", "false", ShmOCPP16Data->ConfigurationTable.CoreProfile[TimeOffsetNextTransition].ItemData);
 
+		// SystemUptimeSec
+		ShmOCPP16Data->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemAccessibility = 1;
+		strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemName, "SystemUptimeSec");
+		strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemData, "0" );
+
+		fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","SystemUptimeSec", "true", ShmOCPP16Data->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemData);
+
 		// Configuration Version
 		ShmOCPP16Data->ConfigurationTable.CoreProfile[ConfigurationVersion].ItemAccessibility = 0;
 		strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConfigurationVersion].ItemName, "ConfigurationVersion");
@@ -14728,6 +14735,12 @@ int initialConfigurationTable(void)
 					sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TimeOffsetNextTransition].ItemData, "%s", valuestr);
 				}
 
+				if(strcmp(keystr, "SystemUptimeSec") == 0)
+				{
+					ShmOCPP16Data->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
+					sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemData, "%s", valuestr);
+				}
+
 				if(strcmp(keystr, "ConfigurationVersion") == 0)
 				{
 					ShmOCPP16Data->ConfigurationTable.CoreProfile[ConfigurationVersion].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
@@ -15214,6 +15227,16 @@ void StoreConfigurationTable(void)
 
 	fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","TimeOffsetNextTransition", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TimeOffsetNextTransition].ItemData);
 
+	// SystemUptimeSec
+	/*
+	ShmOCPP16Data->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemAccessibility = 1;
+	strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemName, "SystemUptimeSec");
+	strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemData, "0" );
+	*/
+
+	fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","SystemUptimeSec", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemData);
+
+
 	// ConfigurationVersion
 	/*
 	ShmOCPP16Data->ConfigurationTable.CoreProfile[ConfigurationVersion].ItemAccessibility = 1;
@@ -16101,6 +16124,36 @@ void getKeyValue(char *keyReq)
 			  isKnowKey = TRUE;
 		  }
 
+	      if(isEmpty ||  strcmp(keyReq, "SystemUptimeSec") == 0 )
+		  {
+	    	  struct sysinfo s_info;
+	    	  int error = sysinfo(&s_info);
+
+			  strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_SystemUptimeSec].Item, "SystemUptimeSec");
+			  strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SystemUptimeSec].Key, "SystemUptimeSec");
+
+			  if(ShmOCPP16Data->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemAccessibility == 1)
+			  {
+				  strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SystemUptimeSec].ReadOnly, "0"/*"FALSE"*/);
+			  }
+			  else
+			  {
+				  strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SystemUptimeSec].ReadOnly, "1"/*"TRUE"*/);
+			  }
+
+	    	  if(error != 0)
+			  {
+				  DEBUG_WARN("System uptime get error: %d\n", error);
+			  }
+	    	  else
+	    	  {
+	    		  sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemData, "%ld", s_info.uptime);
+	    		  sprintf((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SystemUptimeSec].Value, "%ld", s_info.uptime);
+	    	  }
+
+			  isKnowKey = TRUE;
+		  }
+
 	      if(isEmpty ||  strcmp(keyReq, "ConfigurationVersion") == 0 )
 		  {
 			  strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_ConfigurationVersion].Item, "ConfigurationVersion");
@@ -16743,7 +16796,6 @@ int setKeyValue(char *key, char *value)
       	{
       	    isSuccess = ConfigurationStatus_Rejected;
       	}
-
     }
 
     if(strcmp(key, "ResetRetries") == 0)
@@ -16766,91 +16818,89 @@ int setKeyValue(char *key, char *value)
     	{
     	    isSuccess = ConfigurationStatus_Rejected;
     	}
+    }
 
-   }
-
-   if(strcmp(key, "ConnectorPhaseRotation") == 0)
-   {
-	   if(ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemAccessibility == 1)
-	   {
-		   strcpy(str, (const char*)value);
-		   for(int i = 0; str[i]; i++)
-		   {
-			   str[i] = tolower(str[i]);
-		   }
+    if(strcmp(key, "ConnectorPhaseRotation") == 0)
+    {
+    	if(ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemAccessibility == 1)
+    	{
+    		strcpy(str, (const char*)value);
+    		for(int i = 0; str[i]; i++)
+    		{
+    			str[i] = tolower(str[i]);
+    		}
 
-		   if(strcmp(str, "notapplicable")== 0)
-		   {
+    		if(strcmp(str, "notapplicable")== 0)
+    		{
 			   sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemData, "%s", "NotApplicable" );
 			   isSuccess = ConfigurationStatus_Accepted;
-		   }
-		   else  if(strcmp(str, "unknown")== 0)
-		   {
+    		}
+    		else  if(strcmp(str, "unknown")== 0)
+    		{
 			   sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemData, "%s", "Unknown" );
 			   isSuccess = ConfigurationStatus_Accepted;
-		   }
-		   else  if(strcmp(str, "rst")== 0)
-		   {
+    		}
+    		else  if(strcmp(str, "rst")== 0)
+    		{
 			   sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemData, "%s", "RST" );
 			   isSuccess = ConfigurationStatus_Accepted;
-		   }
-		   else  if(strcmp(str, "rts")== 0)
-		   {
+    		}
+    		else  if(strcmp(str, "rts")== 0)
+    		{
 			   sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemData, "%s", "RTS" );
 			   isSuccess = ConfigurationStatus_Accepted;
-		   }
-		   else  if(strcmp(str, "srt")== 0)
-		   {
+    		}
+    		else  if(strcmp(str, "srt")== 0)
+    		{
 			   sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemData, "%s", "SRT" );
 			   isSuccess = ConfigurationStatus_Accepted;
-		   }
-		   else  if(strcmp(str, "str")== 0)
-		   {
+    		}
+    		else  if(strcmp(str, "str")== 0)
+    		{
 			   sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemData, "%s", "STR" );
 			   isSuccess = ConfigurationStatus_Accepted;
-		   }
-		   else  if(strcmp(str, "trs")== 0)
-		   {
+    		}
+    		else  if(strcmp(str, "trs")== 0)
+    		{
 			   sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemData, "%s", "TRS" );
 			   isSuccess = ConfigurationStatus_Accepted;
-		   }
-		   else  if(strcmp(str, "tsr")== 0)
-		   {
+    		}
+    		else  if(strcmp(str, "tsr")== 0)
+    		{
 			   sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemData, "%s", "TSR" );
 			   isSuccess = ConfigurationStatus_Accepted;
-		   }
-		   else
-		   {
+    		}
+    		else
+    		{
 			   isSuccess = ConfigurationStatus_Rejected;
-		   }
-	   }
-	   else
-	   {
+    		}
+    	}
+    	else
+    	{
 	       isSuccess = ConfigurationStatus_Rejected;
-	   }
-
-   }
+    	}
+    }
 
-   if(strcmp(key, "ConnectorPhaseRotationMaxLength") == 0)
-   {
-	  if(ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotationMaxLength].ItemAccessibility == 1)
-	  {
-		  check_ascii = value[0];
-		  if( (check_ascii < 48) || (check_ascii > 57) )
-		  {
-		      isSuccess = ConfigurationStatus_Rejected;
-		  }
-		  else
-		  {
-		      sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotationMaxLength].ItemData, "%d", atoi(value) );
-		      isSuccess = ConfigurationStatus_Accepted;
-		  }
-	  }
-	  else
-	  {
-	  	  isSuccess = ConfigurationStatus_Rejected;
-	  }
-   }
+    if(strcmp(key, "ConnectorPhaseRotationMaxLength") == 0)
+    {
+    	if(ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotationMaxLength].ItemAccessibility == 1)
+    	{
+    		check_ascii = value[0];
+    		if( (check_ascii < 48) || (check_ascii > 57) )
+    		{
+    			isSuccess = ConfigurationStatus_Rejected;
+    		}
+    		else
+    		{
+    			sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotationMaxLength].ItemData, "%d", atoi(value) );
+    			isSuccess = ConfigurationStatus_Accepted;
+    		}
+    	}
+    	else
+    	{
+    		isSuccess = ConfigurationStatus_Rejected;
+    	}
+    }
 
    if(strcmp(key, "StopTransactionOnEVSideDisconnect") == 0)
    {
@@ -16872,60 +16922,59 @@ int setKeyValue(char *key, char *value)
 
    }
 
-    if(strcmp(key, "StopTransactionOnInvalidId") == 0)
-    {
-    	if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemAccessibility == 1)
-    	{
-    		strcpy(str, (const char*)value);
-    		for(int i = 0; str[i]; i++)
-    		{
-    			str[i] = tolower(str[i]);
-    		}
-    		//Charger.StopTransactionOnInvalidId = (value.toLowerCase().equals("true")?true:false);
-    		sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemData, "%s", (strcmp(str, "true")==0) ?"TRUE":"FALSE" );
-    		isSuccess = ConfigurationStatus_Accepted;
-    	}
-        else
-        {
-    		isSuccess = ConfigurationStatus_Rejected;
-        }
-    }
+   if(strcmp(key, "StopTransactionOnInvalidId") == 0)
+   {
+	   if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemAccessibility == 1)
+	   {
+		   strcpy(str, (const char*)value);
+		   for(int i = 0; str[i]; i++)
+		   {
+			   str[i] = tolower(str[i]);
+		   }
+		   //Charger.StopTransactionOnInvalidId = (value.toLowerCase().equals("true")?true:false);
+		   sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemData, "%s", (strcmp(str, "true")==0) ?"TRUE":"FALSE" );
+		   isSuccess = ConfigurationStatus_Accepted;
+	   }
+	   else
+	   {
+		   isSuccess = ConfigurationStatus_Rejected;
+	   }
+   }
 
+   if(strcmp(key, "StopTxnAlignedData") == 0)
+   {
+	   if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedData].ItemAccessibility == 1)
+	   {
+		   sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedData].ItemData, "%s", value );
+		   isSuccess = ConfigurationStatus_Accepted;
+	   }
+	   else
+	   {
+		   isSuccess = ConfigurationStatus_Rejected;
+	   }
+   }
 
-    if(strcmp(key, "StopTxnAlignedData") == 0)
+    if(strcmp(key, "StopTxnAlignedDataMaxLength") == 0)
     {
-    	if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedData].ItemAccessibility == 1)
+    	if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedDataMaxLength].ItemAccessibility == 1)
     	{
-    	    sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedData].ItemData, "%s", value );
-    		isSuccess = ConfigurationStatus_Accepted;
+    		check_ascii = value[0];
+    		if( (check_ascii < 48) || (check_ascii > 57) )
+    		{
+    			isSuccess = ConfigurationStatus_Rejected;
+    		}
+    		else
+    		{
+    			sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedDataMaxLength].ItemData, "%d", atoi(value) );
+    			isSuccess = ConfigurationStatus_Accepted;
+    		}
     	}
     	else
     	{
-    	    isSuccess = ConfigurationStatus_Rejected;
+    		isSuccess = ConfigurationStatus_Rejected;
     	}
     }
 
-    if(strcmp(key, "StopTxnAlignedDataMaxLength") == 0)
-    {
-   	  if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedDataMaxLength].ItemAccessibility == 1)
-   	  {
-   		 check_ascii = value[0];
-   		 if( (check_ascii < 48) || (check_ascii > 57) )
-   		 {
-   			isSuccess = ConfigurationStatus_Rejected;
-   		 }
-   		 else
-   		 {
-   			sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedDataMaxLength].ItemData, "%d", atoi(value) );
-   			isSuccess = ConfigurationStatus_Accepted;
-   		 }
-   	  }
-   	  else
-   	  {
-   	  	  isSuccess = ConfigurationStatus_Rejected;
-   	  }
-    }
-
     if(strcmp(key, "StopTxnSampledData") == 0)
     {
     	if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledData].ItemAccessibility == 1)
@@ -16972,7 +17021,6 @@ int setKeyValue(char *key, char *value)
        	{
        	    isSuccess = ConfigurationStatus_Rejected;
        	}
-
     }
 
     if(strcmp(key, "SupportedFeatureProfilesMaxLength") == 0)
@@ -17041,7 +17089,6 @@ int setKeyValue(char *key, char *value)
     	{
     	    isSuccess = ConfigurationStatus_Rejected;
     	}
-
     }
 
     if(strcmp(key, "UnlockConnectorOnEVSideDisconnect") == 0)
@@ -17061,7 +17108,6 @@ int setKeyValue(char *key, char *value)
         {
         	isSuccess = ConfigurationStatus_Rejected;
         }
-
     }
 
     if(strcmp(key, "WebSocketPingInterval") == 0)
@@ -17099,10 +17145,9 @@ int setKeyValue(char *key, char *value)
 			isSuccess = ConfigurationStatus_Accepted;
 		}
 		else
-	   {
-		isSuccess = ConfigurationStatus_Rejected;
-	   }
-
+		{
+			isSuccess = ConfigurationStatus_Rejected;
+		}
     }
 
     if(strcmp(key, "AuthorizationKey") == 0)
@@ -17181,10 +17226,9 @@ int setKeyValue(char *key, char *value)
 			isSuccess = ConfigurationStatus_Accepted;
 		}
 		else
-	   {
-		isSuccess = ConfigurationStatus_Rejected;
-	   }
-
+		{
+			isSuccess = ConfigurationStatus_Rejected;
+		}
     }
 
     if(strcmp(key, "CustomIdleFeeAfterStop") == 0)
@@ -17200,10 +17244,9 @@ int setKeyValue(char *key, char *value)
 			isSuccess = ConfigurationStatus_Accepted;
 		}
 		else
-	   {
-		isSuccess = ConfigurationStatus_Rejected;
-	   }
-
+		{
+			isSuccess = ConfigurationStatus_Rejected;
+		}
     }
 
     if(strcmp(key, "TimeOffset") == 0)
@@ -17215,10 +17258,9 @@ int setKeyValue(char *key, char *value)
     		isSuccess = ConfigurationStatus_Accepted;
 		}
 		else
-	   {
-		isSuccess = ConfigurationStatus_Rejected;
-	   }
-
+		{
+			isSuccess = ConfigurationStatus_Rejected;
+		}
     }
 
     if(strcmp(key, "NextTimeOffsetTransitionDateTime") == 0)
@@ -17230,10 +17272,9 @@ int setKeyValue(char *key, char *value)
 			isSuccess = ConfigurationStatus_Accepted;
 		}
 		else
-	   {
-		isSuccess = ConfigurationStatus_Rejected;
-	   }
-
+		{
+			isSuccess = ConfigurationStatus_Rejected;
+		}
     }
 
     if(strcmp(key, "TimeOffsetNextTransition") == 0)
@@ -17245,10 +17286,14 @@ int setKeyValue(char *key, char *value)
 			isSuccess = ConfigurationStatus_Accepted;
 		}
 		else
-	   {
-		isSuccess = ConfigurationStatus_Rejected;
-	   }
+	    {
+			isSuccess = ConfigurationStatus_Rejected;
+	    }
+    }
 
+    if(strcmp(key, "SystemUptimeSec") == 0)
+    {
+		isSuccess = NotSupported;
     }
 #if 0
     //For OCPP Test Case

+ 1 - 0
EVSE/Modularization/ocppfiles/MessageHandler.h

@@ -395,6 +395,7 @@ enum GetConfigurationKey {
 	GetConfiguration_TimeOffset,
 	GetConfiguration_NextTimeOffsetTransitionDateTime,
 	GetConfiguration_TimeOffsetNextTransition,
+	GetConfiguration_SystemUptimeSec,
 	GetConfiguration_LocalAuthListEnabled,
 	GetConfiguration_LocalAuthListMaxLength,
 	GetConfiguration_SendLocalListMaxLength,

+ 3 - 1
EVSE/Modularization/ocppfiles/Module_OcppBackend.h

@@ -17,16 +17,18 @@
 #include 	<sys/ipc.h>
 #include 	<sys/shm.h>
 #include 	<sys/mman.h>
+#include 	<sys/sysinfo.h>
 #include 	<linux/wireless.h>
 #include 	<linux/sockios.h>
 #include 	<linux/socket.h>
+#include 	<linux/unistd.h>
+#include 	<linux/kernel.h>
 #include 	<arpa/inet.h>
 #include 	<netinet/in.h>
 #include 	<unistd.h>
 #include 	<stdarg.h>
 #include    <stdio.h>
 #include    <stdlib.h>
-#include    <unistd.h>
 #include    <fcntl.h>
 #include    <termios.h>
 #include 	<errno.h>

+ 58 - 1
EVSE/Modularization/ocppph/MessageHandler.c

@@ -13672,7 +13672,7 @@ int initialConfigurationTable(void)
 	char sstr[256]={0};
 	int c = 0;
 	char *loc;
-	int	confVersion = 8;
+	int	confVersion = 9;
 
 	DEBUG_INFO("initialConfigurationTable...version: %d\n", confVersion);
 	//start_t = clock();
@@ -14018,6 +14018,13 @@ int initialConfigurationTable(void)
 
 		fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","CustomIdleFeeAfterStop", "false", ShmOCPP16DataPH->ConfigurationTable.CoreProfile[CustomIdleFeeAfterStop].ItemData);
 
+		// SystemUptimeSec
+		ShmOCPP16DataPH->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemAccessibility = 1;
+		strcpy((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemName, "SystemUptimeSec");
+		strcpy((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemData, "0" );
+
+		fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","SystemUptimeSec", "true", ShmOCPP16DataPH->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemData);
+
 		// Configuration Version
 		ShmOCPP16DataPH->ConfigurationTable.CoreProfile[ConfigurationVersion].ItemAccessibility = 0;
 		strcpy((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[ConfigurationVersion].ItemName, "ConfigurationVersion");
@@ -14423,6 +14430,12 @@ int initialConfigurationTable(void)
 					sprintf((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[CustomIdleFeeAfterStop].ItemData, "%s", valuestr);
 				}
 
+				if(strcmp(keystr, "SystemUptimeSec") == 0)
+				{
+					ShmOCPP16DataPH->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
+					sprintf((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemData, "%d", atoi(valuestr));
+				}
+
 				if(strcmp(keystr, "ConfigurationVersion") == 0)
 				{
 					ShmOCPP16DataPH->ConfigurationTable.CoreProfile[ConfigurationVersion].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
@@ -14882,6 +14895,15 @@ void StoreConfigurationTable(void)
 
 	fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","CustomIdleFeeAfterStop", "false", (char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[CustomIdleFeeAfterStop].ItemData);
 
+	// SystemUptimeSec
+	/*
+	ShmOCPP16DataPH->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemAccessibility = 1;
+	strcpy((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemName, "SystemUptimeSec");
+	strcpy((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemData, "0" );
+	*/
+
+	fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","SystemUptimeSec", "true", (char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemData);
+
 	// ConfigurationVersion
 	/*
 	ShmOCPP16DataPH->ConfigurationTable.CoreProfile[ConfigurationVersion].ItemAccessibility = 1;
@@ -15715,6 +15737,36 @@ void getKeyValue(char *keyReq)
 			  isKnowKey = TRUE;
 		  }
 
+	      if(isEmpty ||  strcmp(keyReq, "SystemUptimeSec") == 0 )
+		  {
+	    	  struct sysinfo s_info;
+	    	  int error = sysinfo(&s_info);
+
+			  strcpy((char *)ShmOCPP16DataPH->GetConfiguration.Key[GetConfiguration_SystemUptimeSec].Item, "SystemUptimeSec");
+			  strcpy((char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SystemUptimeSec].Key, "SystemUptimeSec");
+
+			  if(ShmOCPP16DataPH->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemAccessibility == 1)
+			  {
+				  strcpy((char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SystemUptimeSec].ReadOnly, "0"/*"FALSE"*/);
+			  }
+			  else
+			  {
+				  strcpy((char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SystemUptimeSec].ReadOnly, "1"/*"TRUE"*/);
+			  }
+
+			  if(error != 0)
+			  {
+				  DEBUG_WARN("System uptime get error: %d\n", error);
+			  }
+			  else
+			  {
+				  sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SystemUptimeSec].ItemData, "%ld", s_info.uptime);
+				  sprintf((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SystemUptimeSec].Value, "%ld", s_info.uptime);
+			  }
+
+			  isKnowKey = TRUE;
+		  }
+
 	      if(isEmpty ||  strcmp(keyReq, "ConfigurationVersion") == 0 )
 		  {
 			  strcpy((char *)ShmOCPP16DataPH->GetConfiguration.Key[GetConfiguration_ConfigurationVersion].Item, "ConfigurationVersion");
@@ -16818,6 +16870,11 @@ int setKeyValue(char *key, char *value)
 	   }
 
     }
+
+    if(strcmp(key, "SystemUptimeSec") == 0)
+    {
+		isSuccess = NotSupported;
+    }
 #if 0
     //For OCPP Test Case
     if(strcmp(key, "LocalAuthorizationListEnabled") == 0)

+ 1 - 0
EVSE/Modularization/ocppph/MessageHandler.h

@@ -392,6 +392,7 @@ enum GetConfigurationKey {
 	GetConfiguration_DefaultPrice,
 	GetConfiguration_CustomDisplayCostAndPrice,
 	GetConfiguration_CustomIdleFeeAfterStop,
+	GetConfiguration_SystemUptimeSec,
 	GetConfiguration_LocalAuthListEnabled,
 	GetConfiguration_LocalAuthListMaxLength,
 	GetConfiguration_SendLocalListMaxLength,

+ 3 - 1
EVSE/Modularization/ocppph/Module_OcppBackend.h

@@ -17,16 +17,18 @@
 #include 	<sys/ipc.h>
 #include 	<sys/shm.h>
 #include 	<sys/mman.h>
+#include	<sys/sysinfo.h>
 #include 	<linux/wireless.h>
 #include 	<linux/sockios.h>
 #include 	<linux/socket.h>
+#include	<linux/unistd.h>
+#include	<linux/kernel.h>
 #include 	<arpa/inet.h>
 #include 	<netinet/in.h>
 #include 	<unistd.h>
 #include 	<stdarg.h>
 #include    <stdio.h>
 #include    <stdlib.h>
-#include    <unistd.h>
 #include    <fcntl.h>
 #include    <termios.h>
 #include 	<errno.h>

+ 2 - 0
EVSE/Projects/define.h

@@ -301,6 +301,7 @@ enum CoreProfile {
      TimeOffset,
      NextTimeOffsetTransitionDateTime,
      TimeOffsetNextTransition,
+	 SystemUptimeSec,
      ConfigurationVersion,
 	 _CoreProfile_CNT
 };
@@ -4715,6 +4716,7 @@ enum OCPP20CtrlrVariable
 	ChargingStation_Available,
 	ChargingStation_AvailabilityState,
 	ChargingStation_SupplyPhases,
+	ChargingStation_SystemUptimeSec,
 	Connector_Available,
 	Connector_ConnectorType,
 	Connector_SupplyPhases,