浏览代码

[Improve][Modularization][Module_OcppBackend20]

2021.09.06 / Folus Wen

Actions:
1. Fix SetDisplayMessages function pointer name to SetDisplayMessage.
2. handleClearCache() logic implement.
3. handleSetDisplayMessageRequest() connectorId check logic fix.

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 3 年之前
父节点
当前提交
3f95bfb14e

+ 2 - 2
EVSE/Modularization/ocpp20/JsonParser.c

@@ -41,7 +41,7 @@ static char *requestNames[] = { "CancelReservation",
 								"Reset",
 								"SendLocalList",
 								"SetChargingProfile",
-								"SetDisplayMessages",
+								"SetDisplayMessage",
 								"SetMonitoringBase",
 								"SetMonitoringLevel",
 								"SetNetworkProfile",
@@ -135,7 +135,7 @@ static FunCallPtr funcalls[] = {handleCancelReservationRequest,
 								handleResetRequest,
 								handleSendLocalListRequest,
 								handleSetChargingProfileRequest,
-								handleSetDisplayMessagesRequest,
+								handleSetDisplayMessageRequest,
 								handleSetMonitoringBaseRequest,
 								handleSetMonitoringLevelRequest,
 								handleSetNetworkProfileRequest,

+ 10 - 13
EVSE/Modularization/ocpp20/MessageHandler.c

@@ -1300,7 +1300,7 @@ void DB_deleteIdTag(char idTag[])
 int DB_cleanLocalList()
 {
 	int result = PASS;
-	char * sqlcleanLocalList = "delete from ocpp20_auth_cache";
+	char * sqlcleanLocalList = "delete from ocpp20_auth_local";
 	char *errMsg = 0;
 
 	if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
@@ -1315,7 +1315,7 @@ int DB_cleanLocalList()
 int DB_cleanLocalCache()
 {
 	int result = PASS;
-	char * sqlcleanLocalList = "delete from ocpp20_auth_local";
+	char * sqlcleanLocalList = "delete from ocpp20_auth_cache";
 	char *errMsg = 0;
 
 	if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
@@ -12010,11 +12010,7 @@ int handleClearCacheRequest(char *uuid, char *payload)
     	system(rmFileCmd);
     }
 
-    /*
-     * TODO:
-     * 1. Clear cache from sqlite db
-     */
-    if(1)
+    if(DB_cleanLocalCache() != PASS)
     {
     	DEBUG_INFO("open AuthorizationCache file failed\n");
     	sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Rejected] );
@@ -15727,13 +15723,14 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 	return result;
 }
 
-int handleSetDisplayMessagesRequest(char *uuid, char *payload)
+int handleSetDisplayMessageRequest(char *uuid, char *payload)
 {
 	mtrace();
 	int result = FAIL;
 	json_object *SetDisplayMessage;
 
 	DEBUG_INFO("handleSetDisplayMessageRequest...\n");
+
 	SetDisplayMessage = json_tokener_parse(payload);
 	if(!is_error(SetDisplayMessage))
 	{
@@ -15763,13 +15760,13 @@ int handleSetDisplayMessagesRequest(char *uuid, char *payload)
 			if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message") != NULL)
 			{
 				if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format") != NULL)
-					sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.message.format, "%s",json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId"), "format")));
+					sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.message.format, "%s",json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format")));
 
 				if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language") != NULL)
-					sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.message.language, "%s",json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId"), "language")));
+					sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.message.language, "%s",json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language")));
 
 				if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content") != NULL)
-					sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.message.content, "%s",json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId"), "content")));
+					sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.message.content, "%s",json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content")));
 			}
 
 			if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display") != NULL)
@@ -15792,10 +15789,8 @@ int handleSetDisplayMessagesRequest(char *uuid, char *payload)
 		}
 	}
 	json_object_put(SetDisplayMessage);
-
 	strcpy((char*)ShmOCPP20Data->SetDisplayMessage.Response_status, DisplayMessageStatusEnumTypeStr[DisplayMessageStatusEnumType_Accepted]);
 	sendSetDisplayMessagesConfirmation(uuid);
-
 	// Announce CSU there is display request come from server
 	ShmOCPP20Data->MsMsg.bits.SetDisplayMessageReq = ON;
 
@@ -16331,6 +16326,8 @@ int handleTriggerMessageRequest(char *uuid, char *payload)
 			else
 				connectorIdIsNULL = TRUE;
 		}
+		else
+			connectorIdIsNULL = TRUE;
 	}
 	json_object_put(TriggerMessage);
 

+ 1 - 1
EVSE/Modularization/ocpp20/MessageHandler.h

@@ -937,7 +937,7 @@ int handleReserveNowRequest(char *uuid, char *payload);
 int handleResetRequest(char *uuid, char *payload);
 int handleSendLocalListRequest(char *uuid, char *payload);
 int handleSetChargingProfileRequest(char *uuid, char *payload);
-int handleSetDisplayMessagesRequest(char *uuid, char *payload);
+int handleSetDisplayMessageRequest(char *uuid, char *payload);
 int handleSetMonitoringBaseRequest(char *uuid, char *payload);
 int handleSetMonitoringLevelRequest(char *uuid, char *payload);
 int handleSetNetworkProfileRequest(char *uuid, char *payload);