Browse Source

[Improve][Modularization][Module_OcppBackend]

2020.12.04 / Folus Wen

Actions:
1. define.h add OcppRunningVer variable and OCPP version enumeration.
2. Module_OcppBackend implement sychronize ocpp running version to share memory for auto switch task usage.
3. Module_OcppBackend storeTempStopTransaction() default reason set to PowerLoss.

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 4 years ago
parent
commit
59e0b43555

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

@@ -16210,9 +16210,7 @@ void storeTempStopTransaction(int gun_index)
 	json_object_object_add(StopTransaction, "meterStop", json_object_new_int(ShmOCPP16Data->StopTransaction[gun_index].MeterStop));
 	json_object_object_add(StopTransaction, "transactionId", json_object_new_int(ShmOCPP16Data->StopTransaction[gun_index].TransactionId));
 	json_object_object_add(StopTransaction, "timestamp", json_object_new_string((char*)ShmOCPP16Data->StopTransaction[gun_index].Timestamp));
-
-	if(strlen((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason) > 0)
-		json_object_object_add(StopTransaction, "reason", json_object_new_string((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason));
+	json_object_object_add(StopTransaction, "reason", json_object_new_string("PowerLoss"));
 
 	for(int idxTrans = 0;idxTrans<ARRAY_SIZE(ShmOCPP16Data->StopTransaction[gun_index].TransactionData);idxTrans++)
 	{
@@ -16389,6 +16387,22 @@ void GetOcppSecurityPassword(uint8_t *data)
 	sprintf((char*)data, "%s", ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData);
 }
 
+void SetOcppVersion(uint8_t *version)
+{
+	for (uint8_t idx=0; idx<strlen((char*)version); idx++) version[idx] = tolower(version[idx]);
+
+	DEBUG_INFO("ocpp version: %s\n", version);
+	if(strstr((char*)version, "ocpp1.6") != NULL)
+	{
+		ShmSysConfigAndInfo->SysConfig.OcppRunningVer = OCPP_RUNNING_VERSION_16;
+	}
+	else if(strstr((char*)version, "ocpp2.0") != NULL)
+	{
+		ShmSysConfigAndInfo->SysConfig.OcppRunningVer = OCPP_RUNNING_VERSION_20;
+		system("pkill OcppBackend");
+	}
+}
+
 void SetServerSign(int value)
 {
 	server_sign = value;

+ 9 - 2
EVSE/Modularization/ocppfiles/Module_OcppBackend.c

@@ -183,6 +183,7 @@ static int OCPP16Callback(struct lws *wsi, enum lws_callback_reasons reason, voi
 			lws_hdr_copy(wsi, buf, ARRAY_SIZE(buf) - 1, WSI_TOKEN_PROTOCOL);
 			DEBUG_OCPPMESSAGE_INFO("Sec-WebSocket-Protocol: %s\n", buf);
 			DEBUG_OCPPMESSAGE_INFO("----- Handshake: Server response END -----\n");
+			SetOcppVersion((uint8_t*)buf);
 
 			break;
 
@@ -390,7 +391,13 @@ static struct lws_protocols protocols[] =
 		65536,//65536,//10240,
 	},
 	{
-		"ocpp1.6",
+		"ocpp2.0",
+		OCPP16Callback,
+		65536,//65536,//10240,
+		65536,//65536,//10240,
+	},
+	{
+		"ocpp1.6,ocpp2.0",
 		OCPP16Callback,
 		65536,//65536,//10240,
 		65536,//65536,//10240,
@@ -477,7 +484,7 @@ void* ConnectWsServer(void* data)  //int ConnectWsServer()
 
 	ConnInfo.host= addr_port; // ConnInfo.address;//lws_canonical_hostname(context);
 	//ConnInfo.origin="origin";
-	ConnInfo.protocol = protocols[1].name;
+	ConnInfo.protocol = protocols[0].name;
 	ConnInfo.ietf_version_or_minus_one = -1;
 
 	if(use_ssl)

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

@@ -109,6 +109,7 @@ extern void SetHeartBeatWithNOResponse(void);
 extern uint8_t GetOcppSecurityProfile();
 extern void GetOcppChargerBoxId(uint8_t *data);
 extern void GetOcppSecurityPassword(uint8_t *data);
+extern void SetOcppVersion(uint8_t *version);
 
 extern int InitShareMemory();
 extern int ProcessShareMemory();

File diff suppressed because it is too large
+ 1148 - 116
EVSE/Projects/AW-CCS/Apps/main.c


+ 5 - 0
EVSE/Projects/define.h

@@ -283,6 +283,10 @@ enum CoreProfile {
 	 _CoreProfile_CNT
 };
 
+enum OCPP_RUNNING_VERSION {
+	OCPP_RUNNING_VERSION_16=0,
+	OCPP_RUNNING_VERSION_20
+};
 /**************************************************************************************/
 /****structure SysConfigData => shall store the data to NAND flash****************/
 /****structure SysInfoData => shall NOT store the data to NAND flash***************/
@@ -431,6 +435,7 @@ struct SysConfigData
 	unsigned int 			Checksum;					//4 bytes checksum
 	struct LED				LedInfo;					// LED configuration info
 	unsigned char			ShowInformation;
+	unsigned char			OcppRunningVer;				// 0: 1.6J		1:2.0
 };
 
 struct ChargingInfoData

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