Эх сурвалжийг харах

[Improve][Modularization][Module_OcppBackend / Module_OcppBackend20 / Webpage]

2021.04.16 / Folus Wen

Actions:
1. Webpage present powet and totalize power consumption display format fix to fourth digit after the decimal point.
2. OCPP16 sent out buffer extend to 20480 bytes for transfer certification message.
3. OCPP16 implement certification exchange logic for security function.

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 жил өмнө
parent
commit
7b2d6ddef6

+ 47 - 22
EVSE/Modularization/ocpp20/MessageHandler.c

@@ -6008,6 +6008,14 @@ void CheckSystemValue(void)
 			sendReserveNowConfirmation((char *)ShmOCPP20Data->ReserveNow[gun_index].guid, gun_index);
 
 		}
+
+		//==========================================
+		// csu trigger LogStatusNotificationReq
+		//==========================================
+		if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq == ON))
+		{
+			sendLogStatusNotificationRequest((char *)ShmOCPP20Data->LogStatusNotification.status);
+		}
 	}
 }
 
@@ -12361,7 +12369,8 @@ void* GetLogProcess(void* data)
 	if(strcmp(remoteLocation,"")==0)
 	{
 		DEBUG_INFO("remoteLocation is <Empty>!\n");
-		sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
+		sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
+		ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
 		goto end;
 	}
 
@@ -12384,7 +12393,8 @@ void* GetLogProcess(void* data)
 	else
 	{
 		DEBUG_INFO("fnamePlusPath not exist!\n");
-		sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
+		sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
+		ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
 		goto end;
 	}
 
@@ -12406,7 +12416,8 @@ void* GetLogProcess(void* data)
 	if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0))
 	{
 		DEBUG_INFO("protocol is not ftp/http ! \n");
-		sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
+		sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
+		ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
 		goto end;
 	}
 
@@ -12417,21 +12428,24 @@ void* GetLogProcess(void* data)
 
 		do
 		{
-			sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
+			sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
+			ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
 			sleep(3);
 
 			isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, remoteLocation);
 			if(!isSuccess)
 			{
 				DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
-				sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
+				sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
+				ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
 				sleep(retryIntervalInt);
 
 			}
 			else
 			{
 				DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
-				sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
+				sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
+				ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
 			}
 			retriesInt--;
 		}while((isSuccess == 0)&&(retriesInt >= 0));
@@ -12468,20 +12482,23 @@ void* GetLogProcess(void* data)
 
 		do
 		{
-			sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
+			sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
+			ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
 			sleep(3);
 
 		    isSuccess = ftpUploadFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
 		    if(!isSuccess)
 			{
 				DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
-				sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
+				sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
+				ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
 				sleep(retryIntervalInt);
 			}
 			else
 			{
 				DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
-				sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
+				sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
+				ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
 			}
 		    retriesInt--;
 		}while((!isSuccess)&&(retriesInt >= 0));
@@ -15019,19 +15036,19 @@ int handleTriggerMessageRequest(char *uuid, char *payload)
 	//==========================
 	if( strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) == 0)
 	{
-		if((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) &&
-		   (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) &&
-		   (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) &&
-		   (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing) )
+		if((strlen((char*)ShmOCPP20Data->FirmwareStatusNotification.status) == 0) ||
+		   ((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing)))
 		{
 			FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
 		}
 
-		sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusNotificationStatus]);
+		ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
 	}
 	else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) == 0 )
 	{
-		sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[LogStatusNotificationStatus]);
+		if(strlen((char*)ShmOCPP20Data->LogStatusNotification.status) == 0)
+			sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Idle]);
+		ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
 	}
 	else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) == 0 )
 	{
@@ -15336,18 +15353,21 @@ void *UpdateFirmwareProcess(void *data)
 
 		do
 		{
-			sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
+			sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
+			ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
 			sleep(3);
 
 			isSuccess = httpDownLoadFile(host, ftppath, filenametemp, locationstr);
 			if(!isSuccess)
 			{
-				sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
+				sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
+				ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
 				sleep(retryIntervalInt);
 			}
 			else
 			{
-				sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
+				sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
+				ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
 			}
 		}while((isSuccess == 0)&&(retriesInt > 0 && retriesInt --));
 	}
@@ -15411,7 +15431,8 @@ void *UpdateFirmwareProcess(void *data)
 
 		do
 		{
-			sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
+			sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
+			ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
 			sleep(3);
 
 			isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, locationstr);
@@ -15419,18 +15440,22 @@ void *UpdateFirmwareProcess(void *data)
 			{
 				//BulldogUtil.sleepMs(interval*1000);
 				DEBUG_INFO("Update firmware request and download file fail.\n");
-				sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
+				sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
+				ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
 				sleep(retryIntervalInt);
 			}
 			else
 			{
-				sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
+				sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
+				ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
+
 			}
 		}while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
 	}
     else
     {
-    	sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
+		sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
+		ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
     }
 
 	ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = ON;

+ 18 - 3
EVSE/Modularization/ocpp20/Module_OcppBackend20.c

@@ -59,14 +59,29 @@ int SendData(struct lws *wsi)
     // Only disable isWebsocketSendable operation initiated by charger
     if((strstr((char*)SendBuffer, "\"Authorize\"") != NULL)
     || (strstr((char*)SendBuffer, "\"BootNotification\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"ClearedChargingLimit\"") != NULL)
 	|| (strstr((char*)SendBuffer, "\"DataTransfer\"") != NULL)
-	|| (strstr((char*)SendBuffer, "\"DiagnosticsStatusNotification\"") != NULL)
 	|| (strstr((char*)SendBuffer, "\"FirmwareStatusNotification\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"Get15118EVCertificate\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"GetCertificateStatus\"") != NULL)
 	|| (strstr((char*)SendBuffer, "\"Heartbeat\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"LogStatusNotification\"") != NULL)
 	|| (strstr((char*)SendBuffer, "\"MeterValues\"") != NULL)
-	|| (strstr((char*)SendBuffer, "\"StartTransaction\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"NotifyChargingLimit\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"NotifyCustomerInformation\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"NotifyDisplayMessages\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"NotifyEVChargingNeeds\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"NotifyEVChargingSchedule\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"NotifyEvent\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"NotifyMonitoringReport\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"NotifyReport\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"PublishFirmwareStatusNotification\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"ReportChargingProfiles\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"ReservationStatusUpdate\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"SecurityEventNotification\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"SignCertificate\"") != NULL)
 	|| (strstr((char*)SendBuffer, "\"StatusNotification\"") != NULL)
-	|| (strstr((char*)SendBuffer, "\"StopTransaction\"") != NULL))
+	|| (strstr((char*)SendBuffer, "\"TransactionEven\"") != NULL))
     {
     	isWebsocketSendable = 0;
     }

+ 224 - 98
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -3430,6 +3430,14 @@ void CheckSystemValue(void)
 			sendFirmwareStatusNotificationRequest((char *)ShmOCPP16Data->FirmwareStatusNotification.Status);
 		}
 
+		//==========================================
+		// csu trigger DiagnosticsStatusNotificationReq
+		//==========================================
+		if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP16Data->SpMsg.bits.DiagnosticsStatusNotificationReq == 1))
+		{
+			sendDiagnosticsStatusNotificationRequest((char *)ShmOCPP16Data->DiagnosticsStatusNotification.Status);
+		}
+
 		//==========================================
 		// csu trigger CancelReservationConf
 		//==========================================
@@ -3463,6 +3471,11 @@ void CheckSystemValue(void)
 			sendReserveNowTransactionConfirmation((char *)ShmOCPP16Data->ReserveNow[gun_index].guid, (char *)ShmOCPP16Data->ReserveNow[gun_index].ResponseStatus);
 			ShmOCPP16Data->CsMsg.bits[gun_index].ReserveNowConf = 0;
 		}
+
+		if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP16Data->SpMsg.bits.SignCertificateReq == 1) && (access("/Storage/OCPP/cert.csr",F_OK) != -1))
+		{
+			sendSignCertificateRequest();
+		}
 	}
 }
 
@@ -3651,7 +3664,7 @@ int sendDiagnosticsStatusNotificationRequest(char *status)
 
 	//[ 2, "9f7bced1-b8b1-40ec-b3bb-2e15630e3cdc", "DiagnosticsStatusNotification", { "status": "Idle" } ]
 
-	DEBUG_INFO("sendDiagnosticsStatusNotificationRequest \n");
+	DEBUG_INFO("sendDiagnosticsStatusNotificationRequest...\n");
 	sprintf((char *)ShmOCPP16Data->DiagnosticsStatusNotification.Status,"%s",(const char *)status);
 	random_uuid(guid);
 
@@ -6240,7 +6253,7 @@ int sendLogStatusNotificationRequest(char *status)
 	random_uuid(guid);
 	sprintf(message,"[%d,\"%s\",\"LogStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(LogStatusNotification, JSON_C_TO_STRING_PLAIN));
 	json_object_put(LogStatusNotification);
-	LWS_SendNow(message);
+	LWS_Send(message);
 
 	sprintf(tempdata, "LogStatusNotification,%d", 0);
 
@@ -6255,7 +6268,7 @@ int sendLogStatusNotificationRequest(char *status)
 	return result;
 }
 
-int sendSecurityEventNotificationRequest(int gun_index)
+int sendSecurityEventNotificationRequest()
 {
 	mtrace();
 	int result = PASS;
@@ -6286,7 +6299,7 @@ int sendSecurityEventNotificationRequest(int gun_index)
 	return result;
 }
 
-int sendSignCertificateRequest(int gun_index)
+int sendSignCertificateRequest()
 {
 	mtrace();
 	int result = PASS;
@@ -6296,6 +6309,20 @@ int sendSignCertificateRequest(int gun_index)
 	json_object *SignCertificate = json_object_new_object();
 	DEBUG_INFO("sendSignCertificateRequest...\n");
 
+	// Read csr file content
+	memset(ShmOCPP16Data->SignCertificate.csr, 0x00, ARRAY_SIZE(ShmOCPP16Data->SignCertificate.csr));
+	FILE *fp=fopen("/Storage/OCPP/cert.csr","r");
+	char *line = NULL;
+	size_t len = 0;
+	while(getline(&line, &len, fp) != -1)
+	{
+		if((strstr(line, "BEGIN CERTIFICATE REQUEST") == NULL) && (strstr(line, "END CERTIFICATE REQUEST") == NULL))
+		{
+			memcpy(&ShmOCPP16Data->SignCertificate.csr[strlen((char*)ShmOCPP16Data->SignCertificate.csr)], line, (strlen(line)-1));
+		}
+	}
+	fclose(fp);
+
 	json_object_object_add(SignCertificate, "csr", json_object_new_string((char*)ShmOCPP16Data->SignCertificate.csr));
 
 	random_uuid(guid);
@@ -6333,7 +6360,7 @@ int sendSignedFirmwareStatusNotificationRequest(char *status)
 	random_uuid(guid);
 	sprintf(message,"[%d,\"%s\",\"FirmwareStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(FirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
 	json_object_put(FirmwareStatusNotification);
-	LWS_SendNow(message);
+	LWS_Send(message);
 
 	sprintf(tempdata, "FirmwareStatusNotification,%d", 0);
 
@@ -8898,7 +8925,8 @@ void* GetDiagnosticsProcess(void* data)
 	if(strcmp(locationstr,"")==0)
 	{
 		DEBUG_INFO("location is <Empty>!\n");
-		sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatus_UploadFailed]);
+		sprintf((char*)ShmOCPP16Data->DiagnosticsStatusNotification.Status, "%s", DiagnosticsStatusStr[DiagnosticsStatus_UploadFailed]);
+		ShmOCPP16Data->SpMsg.bits.DiagnosticsStatusNotificationReq = 1;
 		goto end;
 	}
 
@@ -8921,7 +8949,8 @@ void* GetDiagnosticsProcess(void* data)
 	else
 	{
 		DEBUG_INFO("fnamePlusPath not exist!\n");
-		sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatus_UploadFailed]);
+		sprintf((char*)ShmOCPP16Data->DiagnosticsStatusNotification.Status, "%s", DiagnosticsStatusStr[DiagnosticsStatus_UploadFailed]);
+		ShmOCPP16Data->SpMsg.bits.DiagnosticsStatusNotificationReq = 1;
 		goto end;
 	}
 
@@ -8943,7 +8972,8 @@ void* GetDiagnosticsProcess(void* data)
 	if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0))
 	{
 		DEBUG_INFO("protocol is not ftp/http ! \n");
-		sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatus_UploadFailed]);
+		sprintf((char*)ShmOCPP16Data->DiagnosticsStatusNotification.Status, "%s", DiagnosticsStatusStr[DiagnosticsStatus_UploadFailed]);
+		ShmOCPP16Data->SpMsg.bits.DiagnosticsStatusNotificationReq = 1;
 		goto end;
 	}
 
@@ -8954,21 +8984,24 @@ void* GetDiagnosticsProcess(void* data)
 
 		do
 		{
-			sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatus_Uploading]);
+			sprintf((char*)ShmOCPP16Data->DiagnosticsStatusNotification.Status, "%s", DiagnosticsStatusStr[DiagnosticsStatus_Uploading]);
+			ShmOCPP16Data->SpMsg.bits.DiagnosticsStatusNotificationReq = 1;
 			sleep(3);
 
 			isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, locationstr);
 			if(!isSuccess)
 			{
 				DEBUG_INFO("Diagnostics fail.\n");
-				sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatus_UploadFailed]);
+				sprintf((char*)ShmOCPP16Data->DiagnosticsStatusNotification.Status, "%s", DiagnosticsStatusStr[DiagnosticsStatus_UploadFailed]);
+				ShmOCPP16Data->SpMsg.bits.DiagnosticsStatusNotificationReq = 1;
 				sleep(retryIntervalInt);
 
 			}
 			else
 			{
 				DEBUG_INFO("sendDiagnosticsStatusNotificationRequest Uploaded\n");
-				sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatus_Uploaded]);
+				sprintf((char*)ShmOCPP16Data->DiagnosticsStatusNotification.Status, "%s", DiagnosticsStatusStr[DiagnosticsStatus_Uploaded]);
+				ShmOCPP16Data->SpMsg.bits.DiagnosticsStatusNotificationReq = 1;
 			}
 			retriesInt--;
 		}while((isSuccess == 0)&&(retriesInt >= 0));
@@ -9005,20 +9038,23 @@ void* GetDiagnosticsProcess(void* data)
 
 		do
 		{
-			sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatus_Uploading]);
+			sprintf((char*)ShmOCPP16Data->DiagnosticsStatusNotification.Status, "%s", DiagnosticsStatusStr[DiagnosticsStatus_Uploading]);
+			ShmOCPP16Data->SpMsg.bits.DiagnosticsStatusNotificationReq = 1;
 			sleep(3);
 
 		    isSuccess = ftpFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
 		    if(!isSuccess)
 			{
 				DEBUG_INFO("Diagnostics fail.\n");
-				sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatus_UploadFailed]);
+				sprintf((char*)ShmOCPP16Data->DiagnosticsStatusNotification.Status, "%s", DiagnosticsStatusStr[DiagnosticsStatus_UploadFailed]);
+				ShmOCPP16Data->SpMsg.bits.DiagnosticsStatusNotificationReq = 1;
 				sleep(retryIntervalInt);
 			}
 			else
 			{
 				DEBUG_INFO("sendDiagnosticsStatusNotificationRequest Uploaded\n");
-				sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatus_Uploaded]);
+				sprintf((char*)ShmOCPP16Data->DiagnosticsStatusNotification.Status, "%s", DiagnosticsStatusStr[DiagnosticsStatus_Uploaded]);
+				ShmOCPP16Data->SpMsg.bits.DiagnosticsStatusNotificationReq = 1;
 			}
 		    retriesInt--;
 		}while((!isSuccess)&&(retriesInt >= 0));
@@ -11470,19 +11506,20 @@ int handleTriggerMessageRequest(char *uuid, char *payload)
 	//==========================
 	if( strcmp(requestedMessagestr, MessageTriggerStr[FirmwareStatusNotification]) == 0)
 	{
-		if((FirmwareStatusNotificationStatus != FIRMWARE_STATUS_DOWNLOADING) &&
-		   (FirmwareStatusNotificationStatus != FIRMWARE_STATUS_DOWNLOADED) &&
-		   (FirmwareStatusNotificationStatus != FIRMWARE_STATUS_IDLE) &&
-		   (FirmwareStatusNotificationStatus != FIRMWARE_STATUS_INSTALLING) )
+		if((strlen((char*)ShmOCPP16Data->FirmwareStatusNotification.Status) == 0) ||
+		   ((FirmwareStatusNotificationStatus != FIRMWARE_STATUS_DOWNLOADING) && (FirmwareStatusNotificationStatus != FIRMWARE_STATUS_DOWNLOADED) && (FirmwareStatusNotificationStatus != FIRMWARE_STATUS_IDLE) && (FirmwareStatusNotificationStatus != FIRMWARE_STATUS_INSTALLING)))
 		{
 			FirmwareStatusNotificationStatus = FIRMWARE_STATUS_IDLE;
+			sprintf((char*)ShmOCPP16Data->FirmwareStatusNotification.Status, "%s", FirmwareStatusStr[FirmwareStatus_Idle]);
 		}
 
-		sendFirmwareStatusNotificationRequest(FirmwareStatusStr[FirmwareStatusNotificationStatus]);
+		ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = 1;
 	}
 	else if(strcmp(requestedMessagestr, MessageTriggerStr[DiagnosticsStatusNotification]) == 0 )
 	{
-		sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatusNotificationStatus]);
+		if(strlen((char*)ShmOCPP16Data->DiagnosticsStatusNotification.Status) == 0)
+			sprintf((char*)ShmOCPP16Data->DiagnosticsStatusNotification.Status, "%s", DiagnosticsStatusStr[DiagnosticsStatus_Idle]);
+		ShmOCPP16Data->SpMsg.bits.DiagnosticsStatusNotificationReq = 1;
 	}
 	else if(strcmp(requestedMessagestr, MessageTriggerStr[BootNotification]) == 0 )
 	{
@@ -11775,18 +11812,21 @@ void *UpdateFirmwareProcess(void *data)
 
 		do
 		{
-			sendFirmwareStatusNotificationRequest(FirmwareStatusStr[FirmwareStatus_Downloading]);
+			sprintf((char*)ShmOCPP16Data->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Downloading]);
+			ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = 1;
 			sleep(3);
 
 			isSuccess = httpDownLoadFile(host, ftppath, filenametemp, locationstr);
 			if(!isSuccess)
 			{
-				sendFirmwareStatusNotificationRequest(FirmwareStatusStr[FirmwareStatus_DownloadFailed]);
+				sprintf((char*)ShmOCPP16Data->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_DownloadFailed]);
+				ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = 1;
 				sleep(retryIntervalInt);
 			}
 			else
 			{
-				sendFirmwareStatusNotificationRequest(FirmwareStatusStr[FirmwareStatus_Downloaded]);
+				sprintf((char*)ShmOCPP16Data->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Downloaded]);
+				ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = 1;
 			}
 		}while((isSuccess == 0)&&(retriesInt > 0 && retriesInt --));
 	}
@@ -11850,7 +11890,8 @@ void *UpdateFirmwareProcess(void *data)
 
 		do
 		{
-			sendFirmwareStatusNotificationRequest(FirmwareStatusStr[FirmwareStatus_Downloading]);
+			sprintf((char*)ShmOCPP16Data->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Downloading]);
+			ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = 1;
 			sleep(3);
 
 			isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, locationstr);
@@ -11858,18 +11899,21 @@ void *UpdateFirmwareProcess(void *data)
 			{
 				//BulldogUtil.sleepMs(interval*1000);
 				DEBUG_INFO("Update firmware request and download file fail.\n");
-				sendFirmwareStatusNotificationRequest(FirmwareStatusStr[FirmwareStatus_DownloadFailed]);
+				sprintf((char*)ShmOCPP16Data->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_DownloadFailed]);
+				ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = 1;
 				sleep(retryIntervalInt);
 			}
 			else
 			{
-				sendFirmwareStatusNotificationRequest(FirmwareStatusStr[FirmwareStatus_Downloaded]);
+				sprintf((char*)ShmOCPP16Data->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Downloaded]);
+				ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = 1;
 			}
 		}while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
 	}
     else
     {
-    	sendFirmwareStatusNotificationRequest(FirmwareStatusStr[FirmwareStatus_DownloadFailed]);
+		sprintf((char*)ShmOCPP16Data->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_DownloadFailed]);
+		ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = 1;
     }
 
 	ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = 1;
@@ -11887,19 +11931,20 @@ int handleCertificateSignedRequest(char *uuid, char *payload)
 	CertificateSigned = json_tokener_parse(payload);
 	if(!is_error(CertificateSigned))
 	{
-		sprintf((char*)ShmOCPP16Data->CertificateSigned.certificateChain, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateChain")));
-
-		/*
-		 *	TODO: CertificateSigned process
-		 */
-		ShmOCPP16Data->MsMsg.bits.CertificateSignedReq = 1;
-		DEBUG_INFO("certificateChain: %s\n", ShmOCPP16Data->CertificateSigned.certificateChain);
-
-		sprintf((char*)ShmOCPP16Data->CertificateSigned.Response_status, "Rejected");
-		sendCertificateSignedConfirmation(uuid);
+		sprintf((char*)ShmOCPP16Data->CertificateSigned.certificateChain, "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(CertificateSigned, "certificateChain"), 0)));
 	}
 	json_object_put(CertificateSigned);
 
+	FILE *fp = fopen("/Storage/OCPP/cert.crt", "w");
+	fprintf(fp, "%s", ShmOCPP16Data->CertificateSigned.certificateChain);
+	fclose(fp);
+	system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
+
+	ShmOCPP16Data->MsMsg.bits.CertificateSignedReq = 1;
+
+	sprintf((char*)ShmOCPP16Data->CertificateSigned.Response_status, "Accepted");
+	sendCertificateSignedConfirmation(uuid);
+
 	return result;
 }
 
@@ -11917,21 +11962,21 @@ int handleDeleteCertificateRequest(char *uuid, char *payload)
 		sprintf((char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash")));
 		sprintf((char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash")));
 		sprintf((char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber")));
-
-		/*
-		 *	TODO: Delete certificateSigned process
-		 */
-		ShmOCPP16Data->MsMsg.bits.DeleteCertificateReq = 1;
-		DEBUG_INFO("hashAlgorithm: %s\n", ShmOCPP16Data->DeleteCertificate.certificateHashData.hashAlgorithm);
-		DEBUG_INFO("issuerNameHash: %s\n", ShmOCPP16Data->DeleteCertificate.certificateHashData.issuerNameHash);
-		DEBUG_INFO("issuerKeyHash: %s\n", ShmOCPP16Data->DeleteCertificate.certificateHashData.issuerKeyHash);
-		DEBUG_INFO("serialNumber: %s\n", ShmOCPP16Data->DeleteCertificate.certificateHashData.serialNumber);
-
-		sprintf((char*)ShmOCPP16Data->DeleteCertificate.Response_status, "NotFound");
-		sendDeleteCertificateConfirmation(uuid);
 	}
 	json_object_put(DeleteCertificate);
 
+	/*
+	 *	TODO: Delete certificateSigned process
+	 */
+	ShmOCPP16Data->MsMsg.bits.DeleteCertificateReq = 1;
+	DEBUG_INFO("hashAlgorithm: %s\n", ShmOCPP16Data->DeleteCertificate.certificateHashData.hashAlgorithm);
+	DEBUG_INFO("issuerNameHash: %s\n", ShmOCPP16Data->DeleteCertificate.certificateHashData.issuerNameHash);
+	DEBUG_INFO("issuerKeyHash: %s\n", ShmOCPP16Data->DeleteCertificate.certificateHashData.issuerKeyHash);
+	DEBUG_INFO("serialNumber: %s\n", ShmOCPP16Data->DeleteCertificate.certificateHashData.serialNumber);
+
+	sprintf((char*)ShmOCPP16Data->DeleteCertificate.Response_status, "NotFound");
+	sendDeleteCertificateConfirmation(uuid);
+
 	return result;
 }
 
@@ -11955,19 +12000,100 @@ int handleExtendedTriggerMessageRequest(char *uuid, char *payload)
 		{
 			ShmOCPP16Data->ExtendedTriggerMessage.connectorId = -1;
 		}
+	}
+	json_object_put(ExtendedTriggerMessage);
 
-		/*
-		 *	TODO: Trigger message process
-		 */
-		ShmOCPP16Data->MsMsg.bits.ExtendedTriggerMessageReq = 1;
 
-		DEBUG_INFO("requestedMessage: %s\n", ShmOCPP16Data->ExtendedTriggerMessage.requestedMessage);
-		DEBUG_INFO("connectorIdInt: %d\n", ShmOCPP16Data->ExtendedTriggerMessage.connectorId);
+	DEBUG_INFO("requestedMessage: %s\n", ShmOCPP16Data->ExtendedTriggerMessage.requestedMessage);
+	DEBUG_INFO("connectorIdInt: %d\n", ShmOCPP16Data->ExtendedTriggerMessage.connectorId);
 
-		sprintf((char*)ShmOCPP16Data->ExtendedTriggerMessage.Response_status, "NotImplemented");
-		sendExtendedTriggerMessageConfirmation(uuid);
+	if((ShmOCPP16Data->ExtendedTriggerMessage.connectorId == 0) || (ShmOCPP16Data->ExtendedTriggerMessage.connectorId > gunTotalNumber))
+	{
+		sprintf((char*)ShmOCPP16Data->ExtendedTriggerMessage.Response_status, TriggerMessageStatusStr[TriggerMessageStatus_Rejected]);
+	}
+	else
+	{
+		if((strcmp((char*)ShmOCPP16Data->ExtendedTriggerMessage.requestedMessage, MessageTriggerStr[BootNotification]) != 0 ) &&
+		   (strcmp((char*)ShmOCPP16Data->ExtendedTriggerMessage.requestedMessage, "LogStatusNotification") != 0) &&
+		   (strcmp((char*)ShmOCPP16Data->ExtendedTriggerMessage.requestedMessage, MessageTriggerStr[FirmwareStatusNotification]) != 0) &&
+		   (strcmp((char*)ShmOCPP16Data->ExtendedTriggerMessage.requestedMessage, MessageTriggerStr[Heartbeat]) != 0) &&
+		   (strcmp((char*)ShmOCPP16Data->ExtendedTriggerMessage.requestedMessage, MessageTriggerStr[MeterValues]) != 0) &&
+		   (strcmp((char*)ShmOCPP16Data->ExtendedTriggerMessage.requestedMessage, "SignChargePointCertificate") != 0 ) &&
+		   (strcmp((char*)ShmOCPP16Data->ExtendedTriggerMessage.requestedMessage, MessageTriggerStr[StatusNotification]) != 0 ))
+		{
+			sprintf((char*)ShmOCPP16Data->ExtendedTriggerMessage.Response_status, "%s",TriggerMessageStatusStr[TriggerMessageStatus_NotImplemented] );
+		}
+		else
+		{
+			sprintf((char*)ShmOCPP16Data->ExtendedTriggerMessage.Response_status, "%s",TriggerMessageStatusStr[TriggerMessageStatus_Accepted] );
+		}
+	}
+	sendExtendedTriggerMessageConfirmation(uuid);
+
+	//==========================
+	// Trigger message
+	//==========================
+	if(strcmp((char*)ShmOCPP16Data->ExtendedTriggerMessage.requestedMessage, MessageTriggerStr[BootNotification]) == 0 )
+	{
+		//sendBootNotificationRequest();
+		server_sign = FALSE;
+	}
+	else if( strcmp((char*)ShmOCPP16Data->ExtendedTriggerMessage.requestedMessage, "LogStatusNotification") == 0)
+	{
+		ShmOCPP16Data->SpMsg.bits.LogStatusNotificationReq = 1;
+	}
+	else if( strcmp((char*)ShmOCPP16Data->ExtendedTriggerMessage.requestedMessage, MessageTriggerStr[FirmwareStatusNotification]) == 0)
+	{
+		if((strlen((char*)ShmOCPP16Data->FirmwareStatusNotification.Status) == 0) ||
+		   ((FirmwareStatusNotificationStatus != FIRMWARE_STATUS_DOWNLOADING) && (FirmwareStatusNotificationStatus != FIRMWARE_STATUS_DOWNLOADED) && (FirmwareStatusNotificationStatus != FIRMWARE_STATUS_IDLE) && (FirmwareStatusNotificationStatus != FIRMWARE_STATUS_INSTALLING)))
+
+		{
+			FirmwareStatusNotificationStatus = FIRMWARE_STATUS_IDLE;
+			sprintf((char*)ShmOCPP16Data->FirmwareStatusNotification.Status, "%s", FirmwareStatusStr[FirmwareStatus_Idle]);
+		}
+
+		ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = 1;
+	}
+	else if(strcmp((char*)ShmOCPP16Data->ExtendedTriggerMessage.requestedMessage, MessageTriggerStr[Heartbeat]) == 0 )
+	{
+		clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP16Data->BootNotification.ResponseHeartbeatInterval);
+	}
+	else if (strcmp((char*)ShmOCPP16Data->ExtendedTriggerMessage.requestedMessage, MessageTriggerStr[MeterValues]) == 0 )
+	{
+		if((ShmOCPP16Data->ExtendedTriggerMessage.connectorId > 0) && (ShmOCPP16Data->ExtendedTriggerMessage.connectorId <= gunTotalNumber))
+		{
+			cpinitateMsg.bits[ShmOCPP16Data->ExtendedTriggerMessage.connectorId-1].TriggerMeterValue = 1;
+		}
+		else
+		{
+			for(int idx=0;idx< gunTotalNumber;idx++)
+			{
+				//sendMeterValuesRequest(idx, ReadingContext_Trigger);
+				cpinitateMsg.bits[idx].TriggerMeterValue = 1;
+			}
+		}
+	}
+	else if(strcmp((char*)ShmOCPP16Data->ExtendedTriggerMessage.requestedMessage, "SignChargePointCertificate") == 0 )
+	{
+		ShmOCPP16Data->SpMsg.bits.SignCertificateReq = 1;
+
+		if(access("/Storage/OCPP/cert.csr",F_OK) == -1)
+		{
+			system("openssl req -newkey rsa:2048 -out /Storage/OCPP/cert.csr -nodes -keyout /Storage/OCPP/cert.key -subj \"/C=TW/ST=Taiwan/L=Taoyuan/O=Phihong Technology/OU=IT/CN=phihong.com\" &");
+		}
+	}
+	else if(strcmp((char*)ShmOCPP16Data->ExtendedTriggerMessage.requestedMessage, MessageTriggerStr[StatusNotification]) == 0 )
+	{
+		if((ShmOCPP16Data->ExtendedTriggerMessage.connectorId > 0) && (ShmOCPP16Data->ExtendedTriggerMessage.connectorId <= gunTotalNumber))
+		{
+			cpinitateMsg.bits[ShmOCPP16Data->ExtendedTriggerMessage.connectorId -1].StatusNotificationReq = 1;
+		}
+		else
+		{
+			for(int idx=0;idx< gunTotalNumber;idx++)
+				cpinitateMsg.bits[idx].StatusNotificationReq = 1;
+		}
 	}
-	json_object_put(ExtendedTriggerMessage);
 
 	return result;
 }
@@ -11983,19 +12109,19 @@ int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
 	if(!is_error(GetInstalledCertificateIds))
 	{
 		sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.certificateType, "%s", json_object_get_string(json_object_object_get(GetInstalledCertificateIds, "certificateType")));
-
-		/*
-		 *	TODO: Return installed certificate process
-		 */
-		ShmOCPP16Data->MsMsg.bits.GetInstalledCertificateIdsReq = 1;
-		DEBUG_INFO("requestedMessage: %s\n", (char*)ShmOCPP16Data->GetInstalledCertificateIds.certificateType);
-
-		memset(ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData, 0x00, ARRAY_SIZE(ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData)*sizeof(struct CertificateHashDataType));
-		sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_status, "NotFound");
-		sendGetInstalledCertificateIdsConfirmation(uuid);
 	}
 	json_object_put(GetInstalledCertificateIds);
 
+	/*
+	 *	TODO: Return installed certificate process
+	 */
+	ShmOCPP16Data->MsMsg.bits.GetInstalledCertificateIdsReq = 1;
+	DEBUG_INFO("requestedMessage: %s\n", (char*)ShmOCPP16Data->GetInstalledCertificateIds.certificateType);
+
+	memset(ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData, 0x00, ARRAY_SIZE(ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData)*sizeof(struct CertificateHashDataType));
+	sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_status, "NotFound");
+	sendGetInstalledCertificateIdsConfirmation(uuid);
+
 	return result;
 }
 
@@ -12033,23 +12159,23 @@ int handleGetLogRequest(char *uuid, char *payload)
 		{
 			sprintf((char*)ShmOCPP16Data->GetLog.log.latestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp")));
 		}
-
-		/*
-		 *	TODO: Upload log process
-		 */
-		ShmOCPP16Data->MsMsg.bits.GetLogReq = 1;
-		DEBUG_INFO("logType: %s\n", ShmOCPP16Data->GetLog.logType);
-		DEBUG_INFO("requestId: %d\n", ShmOCPP16Data->GetLog.requestId);
-		DEBUG_INFO("retries: %d\n", ShmOCPP16Data->GetLog.retries);
-		DEBUG_INFO("retryInterval: %d\n", ShmOCPP16Data->GetLog.retryInterval);
-		DEBUG_INFO("remoteLocation: %s\n", ShmOCPP16Data->GetLog.log.remoteLocation);
-		DEBUG_INFO("oldestTimestamp: %s\n", ShmOCPP16Data->GetLog.log.oldestTimestamp);
-		DEBUG_INFO("latestTimestamp: %s\n", ShmOCPP16Data->GetLog.log.latestTimestamp);
-		sprintf((char*)ShmOCPP16Data->GetLog.Response_status, "Rejected");
-		sendGetLogConfirmation(uuid);
 	}
 	json_object_put(GetLog);
 
+	/*
+	 *	TODO: Upload log process
+	 */
+	ShmOCPP16Data->MsMsg.bits.GetLogReq = 1;
+	DEBUG_INFO("logType: %s\n", ShmOCPP16Data->GetLog.logType);
+	DEBUG_INFO("requestId: %d\n", ShmOCPP16Data->GetLog.requestId);
+	DEBUG_INFO("retries: %d\n", ShmOCPP16Data->GetLog.retries);
+	DEBUG_INFO("retryInterval: %d\n", ShmOCPP16Data->GetLog.retryInterval);
+	DEBUG_INFO("remoteLocation: %s\n", ShmOCPP16Data->GetLog.log.remoteLocation);
+	DEBUG_INFO("oldestTimestamp: %s\n", ShmOCPP16Data->GetLog.log.oldestTimestamp);
+	DEBUG_INFO("latestTimestamp: %s\n", ShmOCPP16Data->GetLog.log.latestTimestamp);
+	sprintf((char*)ShmOCPP16Data->GetLog.Response_status, "Rejected");
+	sendGetLogConfirmation(uuid);
+
 	return result;
 }
 
@@ -12113,25 +12239,25 @@ int handleSignedUpdateFirmwareRequest(char *uuid, char *payload)
 
 		sprintf((char*)ShmOCPP16Data->SignedUpdateFirmware.firmware.signingCertificate, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SignedUpdateFirmware, "firmware"), "signingCertificate")));
 		sprintf((char*)ShmOCPP16Data->SignedUpdateFirmware.firmware.signature, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SignedUpdateFirmware, "firmware"), "signature")));
-
-		/*
-		 * 	TODO:	Upgrade firmware process
-		 */
-		ShmOCPP16Data->MsMsg.bits.SignedUpdateFirmwareReq = 1;
-		DEBUG_INFO("retries: %d\n", ShmOCPP16Data->SignedUpdateFirmware.retries);
-		DEBUG_INFO("retryInterval: %d\n", ShmOCPP16Data->SignedUpdateFirmware.retryInterval);
-		DEBUG_INFO("requestId: %d\n", ShmOCPP16Data->SignedUpdateFirmware.requestId);
-		DEBUG_INFO("location: %s\n", ShmOCPP16Data->SignedUpdateFirmware.firmware.location);
-		DEBUG_INFO("retrieveDateTime: %s\n", ShmOCPP16Data->SignedUpdateFirmware.firmware.retrieveDateTime);
-		DEBUG_INFO("installDateTime: %s\n", ShmOCPP16Data->SignedUpdateFirmware.firmware.installDateTime);
-		DEBUG_INFO("signingCertificate: %s\n", ShmOCPP16Data->SignedUpdateFirmware.firmware.signingCertificate);
-		DEBUG_INFO("signature: %s\n", ShmOCPP16Data->SignedUpdateFirmware.firmware.signature);
-
-		sprintf((char*)ShmOCPP16Data->SignedUpdateFirmware.Response_status, "Rejected");
-		sendInstallCertificateConfirmation(uuid);
 	}
 	json_object_put(SignedUpdateFirmware);
 
+	/*
+	 * 	TODO:	Upgrade firmware process
+	 */
+	ShmOCPP16Data->MsMsg.bits.SignedUpdateFirmwareReq = 1;
+	DEBUG_INFO("retries: %d\n", ShmOCPP16Data->SignedUpdateFirmware.retries);
+	DEBUG_INFO("retryInterval: %d\n", ShmOCPP16Data->SignedUpdateFirmware.retryInterval);
+	DEBUG_INFO("requestId: %d\n", ShmOCPP16Data->SignedUpdateFirmware.requestId);
+	DEBUG_INFO("location: %s\n", ShmOCPP16Data->SignedUpdateFirmware.firmware.location);
+	DEBUG_INFO("retrieveDateTime: %s\n", ShmOCPP16Data->SignedUpdateFirmware.firmware.retrieveDateTime);
+	DEBUG_INFO("installDateTime: %s\n", ShmOCPP16Data->SignedUpdateFirmware.firmware.installDateTime);
+	DEBUG_INFO("signingCertificate: %s\n", ShmOCPP16Data->SignedUpdateFirmware.firmware.signingCertificate);
+	DEBUG_INFO("signature: %s\n", ShmOCPP16Data->SignedUpdateFirmware.firmware.signature);
+
+	sprintf((char*)ShmOCPP16Data->SignedUpdateFirmware.Response_status, "Rejected");
+	sendInstallCertificateConfirmation(uuid);
+
 	return result;
 }
 

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

@@ -461,8 +461,8 @@ int sendStopTransactionRequest(int gun_index);
 int sendMeterValuesRequest(int gun_index, ReadingContext dataType);
 
 int sendLogStatusNotificationRequest(char *status);
-int sendSecurityEventNotificationRequest(int gun_index);
-int sendSignCertificateRequest(int gun_index);
+int sendSecurityEventNotificationRequest();
+int sendSignCertificateRequest();
 int sendSignedFirmwareStatusNotificationRequest(char *status);
 
 //==========================================

+ 7 - 3
EVSE/Modularization/ocppfiles/Module_OcppBackend.c

@@ -20,7 +20,7 @@ struct StartTime
 //==========================================
 void ReceivedMessage(void *in, size_t len);
 int SendBufLen=0;//(1024*4);//(1024*3);
-unsigned char SendBuffer[1024*4]={0};
+unsigned char SendBuffer[1024*20]={0};
 static int ConnectionEstablished=0;
 static int TransactionMessageResend = 1;  // the number of retry to submit a transaction-related message when the Central System fails to process it.
 static int TransactionQueueNum = 0;
@@ -108,7 +108,7 @@ int SendData(struct lws *wsi)
 {
     int n;
     int len;
-    unsigned char out[LWS_SEND_BUFFER_PRE_PADDING + 4096 + LWS_SEND_BUFFER_POST_PADDING] = {0};
+    unsigned char out[LWS_SEND_BUFFER_PRE_PADDING + ARRAY_SIZE(SendBuffer) + LWS_SEND_BUFFER_POST_PADDING] = {0};
 
     // Only disable isWebsocketSendable operation initiated by charger
     if((strstr((char*)SendBuffer, "\"Authorize\"") != NULL)
@@ -120,7 +120,11 @@ int SendData(struct lws *wsi)
 	|| (strstr((char*)SendBuffer, "\"MeterValues\"") != NULL)
 	|| (strstr((char*)SendBuffer, "\"StartTransaction\"") != NULL)
 	|| (strstr((char*)SendBuffer, "\"StatusNotification\"") != NULL)
-	|| (strstr((char*)SendBuffer, "\"StopTransaction\"") != NULL))
+	|| (strstr((char*)SendBuffer, "\"StopTransaction\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"LogStatusNotification\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"SecurityEventNotification\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"SignCertificate\"") != NULL)
+	|| (strstr((char*)SendBuffer, "\"SignedFirmwareStatusNotification\"") != NULL))
     {
     	isWebsocketSendable = 0;
     }

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

@@ -142,7 +142,7 @@ extern char * strtrim( char * s );
 
 extern struct lws 					*wsi_client;
 extern struct lws_context 			*context;
-extern unsigned char 				SendBuffer[4096];
+extern unsigned char 				SendBuffer[1024*20];
 extern int 							SendBufLen;
 extern char 						OcppPath[384];
 extern char 						OcppProtocol[10];

+ 21 - 21
EVSE/rootfs/var/www/set_charging.php

@@ -843,7 +843,7 @@ img {
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
 											<label>Present Charging Energy</label>
-											<input type="text" readonly class="form-control" placeholder="<?php echo round($obj['DDChargingInfo1']['PresentChargedEnergy'],2);?> kWh">
+											<input type="text" readonly class="form-control" placeholder="<?php echo number_format(round($obj['DDChargingInfo1']['PresentChargedEnergy'],4), 4, ".", " ");?> kWh">
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
 											<label>Present Charging Duration</label>
@@ -866,8 +866,8 @@ img {
 											<input type="text" readonly class="form-control" placeholder="<?php echo $obj['DDChargingInfo1']['EvBatterySoc'];?>">
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
-											<label>Power Consumption</label>
-											<input type="text" readonly class="form-control" placeholder="<?php echo round($obj['DDChargingInfo1']['PowerConsumption'],2);?> kWh">
+											<label>Totalize Power Consumption</label>
+											<input type="text" readonly class="form-control" placeholder="<?php echo number_format(round($obj['DDChargingInfo1']['PowerConsumption'],4), 4, ".", " ");?> kWh">
 										</div>
 									</section>
 								</article>
@@ -915,7 +915,7 @@ img {
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
 											<label>Present Charging Energy</label>
-											<input type="text" readonly class="form-control" placeholder="<?php echo round($obj['DDChargingInfo2']['PresentChargedEnergy'],2);?> kWh">
+											<input type="text" readonly class="form-control" placeholder="<?php echo number_format(round($obj['DDChargingInfo2']['PresentChargedEnergy'],4), 4, ".", " ");?> kWh">
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
 											<label>Present Charging Duration</label>
@@ -938,8 +938,8 @@ img {
 											<input type="text" readonly class="form-control" placeholder="<?php echo $obj['DDChargingInfo2']['EvBatterySoc'];?>">
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
-											<label>Power Consumption</label>
-											<input type="text" readonly class="form-control" placeholder="<?php echo round($obj['DDChargingInfo2']['PowerConsumption'],2);?> kWh">
+											<label>Totalize Power Consumption</label>
+											<input type="text" readonly class="form-control" placeholder="<?php echo number_format(round($obj['DDChargingInfo2']['PowerConsumption'],4), 4, ".", " ");?> kWh">
 										</div>
 									</section>
 								</article>
@@ -987,7 +987,7 @@ img {
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
 											<label>Present Charging Energy</label>
-											<input type="text" readonly class="form-control" placeholder="<?php echo round($obj['DDChargingInfo3']['PresentChargedEnergy'],2);?> kWh">
+											<input type="text" readonly class="form-control" placeholder="<?php echo number_format(round($obj['DDChargingInfo3']['PresentChargedEnergy'],4), 4, ".", " ");?> kWh">
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
 											<label>Present Charging Duration</label>
@@ -1010,8 +1010,8 @@ img {
 											<input type="text" readonly class="form-control" placeholder="<?php echo $obj['DDChargingInfo3']['EvBatterySoc'];?>">
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
-											<label>Power Consumption</label>
-											<input type="text" readonly class="form-control" placeholder="<?php echo round($obj['DDChargingInfo3']['PowerConsumption'],2);?> kWh">
+											<label>Totalize Power Consumption</label>
+											<input type="text" readonly class="form-control" placeholder="<?php echo number_format(round($obj['DDChargingInfo3']['PowerConsumption'],4), 4, ".", " ");?> kWh">
 										</div>
 									</section>
 								</article>
@@ -1059,7 +1059,7 @@ img {
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
 											<label>Present Charging Energy</label>
-											<input type="text" readonly class="form-control" placeholder="<?php echo round($obj['DDChargingInfo4']['PresentChargedEnergy'],2);?> kWh">
+											<input type="text" readonly class="form-control" placeholder="<?php echo number_format(round($obj['DDChargingInfo4']['PresentChargedEnergy'],4), 4, ".", " ");?> kWh">
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
 											<label>Present Charging Duration</label>
@@ -1082,8 +1082,8 @@ img {
 											<input type="text" readonly class="form-control" placeholder="<?php echo $obj['DDChargingInfo4']['EvBatterySoc'];?>">
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
-											<label>Power Consumption</label>
-											<input type="text" readonly class="form-control" placeholder="<?php echo round($obj['DDChargingInfo4']['PowerConsumption'],2);?> kWh">
+											<label>Totalize Power Consumption</label>
+											<input type="text" readonly class="form-control" placeholder="<?php echo number_format(round($obj['DDChargingInfo4']['PowerConsumption'],4), 4, ".", " ");?> kWh">
 										</div>
 									</section>
 								</article>
@@ -1141,7 +1141,7 @@ img {
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
 											<label>Present Charging Energy</label>
-											<input type="text" readonly class="form-control" placeholder="<?php echo round($obj['ChargingInfo1']['PresentChargedEnergy'],2);?> kWh">
+											<input type="text" readonly class="form-control" placeholder="<?php echo number_format(round($obj['ChargingInfo1']['PresentChargedEnergy'],4), 4, ".", " ");?> kWh">
 											<input type="hidden" name="PresentChargedEnergy1" id="PresentChargedEnergy1" value="<?php echo $obj['ChargingInfo1']['PresentChargedEnergy'];?>">
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
@@ -1170,8 +1170,8 @@ img {
 											<input type="hidden" name="EvBatterySoc1" id="EvBatterySoc1" value="<?php echo $obj['ChargingInfo1']['EvBatterySoc'];?>">
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
-											<label>Power Consumption</label>
-											<input type="text" readonly class="form-control" placeholder="<?php echo round($obj['ChargingInfo1']['PowerConsumption'],2);?> kWh">
+											<label>Totalize Power Consumption</label>
+											<input type="text" readonly class="form-control" placeholder="<?php echo number_format(round($obj['ChargingInfo1']['PowerConsumption'],4), 4, ".", " ");?> kWh">
 										</div>
 									</section>
 								</article>
@@ -1228,7 +1228,7 @@ img {
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
 											<label>Present Charging Energy</label>
-											<input type="text" readonly class="form-control" placeholder="<?php echo round($obj['ChargingInfo2']['PresentChargedEnergy'],2);?> kWh">
+											<input type="text" readonly class="form-control" placeholder="<?php echo number_format(round($obj['ChargingInfo2']['PresentChargedEnergy'],4), 4, ".", " ");?> kWh">
 											<input type="hidden" name="PresentChargedEnergy2" id="PresentChargedEnergy2" value="<?php echo $obj['ChargingInfo2']['PresentChargedEnergy'];?>">
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
@@ -1257,8 +1257,8 @@ img {
 											<input type="hidden" name="EvBatterySoc2" id="EvBatterySoc2" value="<?php echo $obj['ChargingInfo2']['EvBatterySoc'];?>">
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
-											<label>Power Consumption</label>
-											<input type="text" readonly class="form-control" placeholder="<?php echo round($obj['ChargingInfo2']['PowerConsumption'],2);?> kWh">
+											<label>Totalize Power Consumption</label>
+											<input type="text" readonly class="form-control" placeholder="<?php echo number_format(round($obj['ChargingInfo2']['PowerConsumption'],4), 4, ".", " ");?> kWh">
 										</div>
 									</section>
 								</article>
@@ -1315,7 +1315,7 @@ img {
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
 											<label>Present Charging Energy</label>
-											<input type="text" readonly class="form-control" placeholder="<?php echo round($obj['ChargingInfo3']['PresentChargedEnergy'],2);?> kWh">
+											<input type="text" readonly class="form-control" placeholder="<?php echo number_format(round($obj['ChargingInfo3']['PresentChargedEnergy'],4), 4, ".", " ");?> kWh">
 											<input type="hidden" name="PresentChargedEnergy3" id="PresentChargedEnergy3" value="<?php echo $obj['ChargingInfo3']['PresentChargedEnergy'];?>">
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
@@ -1344,8 +1344,8 @@ img {
 											<input type="hidden" name="EvBatterySoc3" id="EvBatterySoc3" value="<?php echo $obj['ChargingInfo3']['EvBatterySoc'];?>">
 										</div>
 										<div class="form-group" style="display:<?php echo $am111;?>">
-											<label>Power Consumption</label>
-											<input type="text" readonly class="form-control" placeholder="<?php echo round($obj['ChargingInfo3']['PowerConsumption'],2);?> kWh">
+											<label>Totalize Power Consumption</label>
+											<input type="text" readonly class="form-control" placeholder="<?php echo number_format(round($obj['ChargingInfo3']['PowerConsumption'],4), 4, ".", " ");?> kWh">
 										</div>
 									</section>
 								</article>