Explorar o código

[Improve][Modularization][Module_OcppBackend / Module_OcppBackend20]

2021.07.16 / Folus Wen

Actions:
1. After changed configuration key 'SecurityProfile' and 'AuthorizeKey' charger will auto reconnect to server.

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 %!s(int64=3) %!d(string=hai) anos
pai
achega
d73c41376f

+ 9 - 2
EVSE/Modularization/ocpp20/MessageHandler.c

@@ -833,6 +833,7 @@ static int HeartBeatCountPerHour = 0;
 
 sqlite3 *db;
 
+extern void  ChageWebSocketPingInterval(int WebSocketPingInterval);
 int TransactionMessageAttemptsGet(void);
 int TransactionMessageRetryIntervalGet(void);
 int GetOcppConnStatus(void);
@@ -2223,7 +2224,7 @@ int DB_cbVariableIsCreate(void *para, int columnCount, char **columnValue, char
 		ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.maxLimit = 48;
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
-		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].value, "Phihong Technology");
+		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].value, "%s", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
 		DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity]);
 
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
@@ -2231,7 +2232,7 @@ int DB_cbVariableIsCreate(void *para, int columnCount, char **columnValue, char
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
-		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].value, "Phihong");
+		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].value, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
 		DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName]);
 
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
@@ -15216,10 +15217,16 @@ int handleSetVariablesRequest(char *uuid, char *payload)
 							else
 								strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
 
+							if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "WebSocketPingInterval") != NULL))
+							{
+								ChageWebSocketPingInterval(atoi((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value));
+							}
+
 							if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "SecurityCtrlr") != NULL) &&
 							   ((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "SecurityProfile") != NULL) || (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "BasicAuthPassword") != NULL)))
 							{
 								StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
+								SetOcppConnStatus(FALSE);
 							}
 						}
 					}

+ 4 - 3
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -7813,13 +7813,16 @@ int handleChangeConfigurationRequest(char *uuid, char *payload)
 
     sendChangeConfigurationConfirmation(uuid, comfirmstr);
 	ShmOCPP16Data->MsMsg.bits.ChangeConfigurationConf = 1;
+
 	if((strcmp(keystr,"WebSocketPingInterval")==0)&&(strcmp(comfirmstr,"Accepted")==0))
 	{
 		ChageWebSocketPingInterval(atoi(valuestr));
 	}
 
-	if((strcmp(keystr,"SecurityProfile")==0)&&(strcmp(comfirmstr,"Accepted")==0))
+	if(((strcmp(keystr,"AuthorizationKey")==0) || ((strcmp(keystr,"SecurityProfile")==0))) &&
+	   (strcmp(keystr,"SecurityProfile")==0)&&(strcmp(comfirmstr,"Accepted")==0))
 	{
+		StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
 		SetOcppConnStatus(FALSE);
 	}
 
@@ -15830,7 +15833,6 @@ int setKeyValue(char *key, char *value)
     		strcpy(str, (const char*)value);
     		sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData, "%s", str);
     		strcpy((char*)ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword, (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData);
-    		StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
 
     		isSuccess = ConfigurationStatus_Accepted;
     	}
@@ -15859,7 +15861,6 @@ int setKeyValue(char *key, char *value)
     			{
     				sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemData, "%d", atoi(value) );
     				ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile = atoi(value);
-    				StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
 
     				isSuccess = ConfigurationStatus_Accepted;
     			}