Browse Source

[Improve][Modularization][Module_OcppBackend / Module_OcppBackend]

2021.05.19 / Folus Wen

Actions:
1. Message sent out interlock improve.

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 năm trước cách đây
mục cha
commit
3ff8186e7a

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

@@ -5739,7 +5739,6 @@ void CheckSystemValue(void)
 
 			sendStatusNotificationRequest(gun_index);
 			clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
-			isWebsocketSendable = OFF;
 		}
 
 		if(isWebsocketSendable && (server_sign == TRUE) && (cpinitateMsg.bits[gun_index].TransactionEventReq == ON))
@@ -17290,7 +17289,7 @@ void InitialSystemValue(void)
 	sleep(1);
 }
 
-void LWS_Send(char * str)
+void LWS_Send(char *str)
 {
 	//=====================================================
 	// Check InternetConn 0: disconnected, 1: connected
@@ -17301,6 +17300,36 @@ void LWS_Send(char * str)
 		return;
 	}
 
+    // Only disable isWebsocketSendable operation initiated by charger
+    if((strstr((char*)str, "\"Authorize\"") != NULL)
+    || (strstr((char*)str, "\"BootNotification\"") != NULL)
+	|| (strstr((char*)str, "\"ClearedChargingLimit\"") != NULL)
+	|| (strstr((char*)str, "\"DataTransfer\"") != NULL)
+	|| (strstr((char*)str, "\"FirmwareStatusNotification\"") != NULL)
+	|| (strstr((char*)str, "\"Get15118EVCertificate\"") != NULL)
+	|| (strstr((char*)str, "\"GetCertificateStatus\"") != NULL)
+	|| (strstr((char*)str, "\"Heartbeat\"") != NULL)
+	|| (strstr((char*)str, "\"LogStatusNotification\"") != NULL)
+	|| (strstr((char*)str, "\"MeterValues\"") != NULL)
+	|| (strstr((char*)str, "\"NotifyChargingLimit\"") != NULL)
+	|| (strstr((char*)str, "\"NotifyCustomerInformation\"") != NULL)
+	|| (strstr((char*)str, "\"NotifyDisplayMessages\"") != NULL)
+	|| (strstr((char*)str, "\"NotifyEVChargingNeeds\"") != NULL)
+	|| (strstr((char*)str, "\"NotifyEVChargingSchedule\"") != NULL)
+	|| (strstr((char*)str, "\"NotifyEvent\"") != NULL)
+	|| (strstr((char*)str, "\"NotifyMonitoringReport\"") != NULL)
+	|| (strstr((char*)str, "\"NotifyReport\"") != NULL)
+	|| (strstr((char*)str, "\"PublishFirmwareStatusNotification\"") != NULL)
+	|| (strstr((char*)str, "\"ReportChargingProfiles\"") != NULL)
+	|| (strstr((char*)str, "\"ReservationStatusUpdate\"") != NULL)
+	|| (strstr((char*)str, "\"SecurityEventNotification\"") != NULL)
+	|| (strstr((char*)str, "\"SignCertificate\"") != NULL)
+	|| (strstr((char*)str, "\"StatusNotification\"") != NULL)
+	|| (strstr((char*)str, "\"TransactionEven\"") != NULL))
+    {
+    	isWebsocketSendable = OFF;
+    }
+
 	pthread_mutex_lock(&lock_send);
 	memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
 	sprintf((char *)SendBuffer, "%s", str);
@@ -17312,7 +17341,7 @@ void LWS_Send(char * str)
 	//sleep(1);
 }
 
-void LWS_SendNow(char * str)
+void LWS_SendNow(char *str)
 {
 	//=====================================================
 	// Check InternetConn 0: disconnected, 1: connected
@@ -17323,6 +17352,36 @@ void LWS_SendNow(char * str)
 		return;
 	}
 
+    // Only disable isWebsocketSendable operation initiated by charger
+    if((strstr((char*)str, "\"Authorize\"") != NULL)
+    || (strstr((char*)str, "\"BootNotification\"") != NULL)
+	|| (strstr((char*)str, "\"ClearedChargingLimit\"") != NULL)
+	|| (strstr((char*)str, "\"DataTransfer\"") != NULL)
+	|| (strstr((char*)str, "\"FirmwareStatusNotification\"") != NULL)
+	|| (strstr((char*)str, "\"Get15118EVCertificate\"") != NULL)
+	|| (strstr((char*)str, "\"GetCertificateStatus\"") != NULL)
+	|| (strstr((char*)str, "\"Heartbeat\"") != NULL)
+	|| (strstr((char*)str, "\"LogStatusNotification\"") != NULL)
+	|| (strstr((char*)str, "\"MeterValues\"") != NULL)
+	|| (strstr((char*)str, "\"NotifyChargingLimit\"") != NULL)
+	|| (strstr((char*)str, "\"NotifyCustomerInformation\"") != NULL)
+	|| (strstr((char*)str, "\"NotifyDisplayMessages\"") != NULL)
+	|| (strstr((char*)str, "\"NotifyEVChargingNeeds\"") != NULL)
+	|| (strstr((char*)str, "\"NotifyEVChargingSchedule\"") != NULL)
+	|| (strstr((char*)str, "\"NotifyEvent\"") != NULL)
+	|| (strstr((char*)str, "\"NotifyMonitoringReport\"") != NULL)
+	|| (strstr((char*)str, "\"NotifyReport\"") != NULL)
+	|| (strstr((char*)str, "\"PublishFirmwareStatusNotification\"") != NULL)
+	|| (strstr((char*)str, "\"ReportChargingProfiles\"") != NULL)
+	|| (strstr((char*)str, "\"ReservationStatusUpdate\"") != NULL)
+	|| (strstr((char*)str, "\"SecurityEventNotification\"") != NULL)
+	|| (strstr((char*)str, "\"SignCertificate\"") != NULL)
+	|| (strstr((char*)str, "\"StatusNotification\"") != NULL)
+	|| (strstr((char*)str, "\"TransactionEven\"") != NULL))
+    {
+    	isWebsocketSendable = OFF;
+    }
+
 	pthread_mutex_lock(&lock_send);
 	memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
 	sprintf((char *)SendBuffer, "%s", str);

+ 0 - 30
EVSE/Modularization/ocpp20/Module_OcppBackend20.c

@@ -56,36 +56,6 @@ int SendData(struct lws *wsi)
     int len;
     unsigned char out[LWS_SEND_BUFFER_PRE_PADDING + (1024*20) + LWS_SEND_BUFFER_POST_PADDING] = {0};
 
-    // 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, "\"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, "\"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, "\"TransactionEven\"") != NULL))
-    {
-    	isWebsocketSendable = 0;
-    }
-
     len = strlen((char *)SendBuffer);
 
     if(len == 0)

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

@@ -3137,7 +3137,7 @@ void CheckSystemValue(void)
 			(
 				(statusModeChage[gun_index] == TRUE) ||
 				//((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > (server_cycle_Status + (GunStatusInterval*gun_index))) ||
-				((cpinitateMsg.bits[gun_index].StatusNotificationReq == 1) && ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 10))
+				((cpinitateMsg.bits[gun_index].StatusNotificationReq == 1) && ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 5))
 			)
 		  )
 		{
@@ -3147,7 +3147,6 @@ void CheckSystemValue(void)
 			sendStatusNotificationRequest(gun_index);
 			clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
 			statusModeChage[gun_index] = FALSE;
-			isWebsocketSendable = 0;
 		}
 
 		//==============================================
@@ -17897,7 +17896,7 @@ void InitialSystemValue(void)
 	sleep(1);
 }
 
-void LWS_Send(char * str)
+void LWS_Send(char *str)
 {
 	//=====================================================
 	// Check InternetConn 0: disconnected, 1: connected
@@ -17908,6 +17907,25 @@ void LWS_Send(char * str)
 		return;
 	}
 
+	 // Only disable isWebsocketSendable operation initiated by charger
+	if((strstr((char*)str, "\"Authorize\"") != NULL)
+    || (strstr((char*)str, "\"BootNotification\"") != NULL)
+	|| (strstr((char*)str, "\"DataTransfer\"") != NULL)
+	|| (strstr((char*)str, "\"DiagnosticsStatusNotification\"") != NULL)
+	|| (strstr((char*)str, "\"FirmwareStatusNotification\"") != NULL)
+	|| (strstr((char*)str, "\"Heartbeat\"") != NULL)
+	|| (strstr((char*)str, "\"MeterValues\"") != NULL)
+	|| (strstr((char*)str, "\"StartTransaction\"") != NULL)
+	|| (strstr((char*)str, "\"StatusNotification\"") != NULL)
+	|| (strstr((char*)str, "\"StopTransaction\"") != NULL)
+	|| (strstr((char*)str, "\"LogStatusNotification\"") != NULL)
+	|| (strstr((char*)str, "\"SecurityEventNotification\"") != NULL)
+	|| (strstr((char*)str, "\"SignCertificate\"") != NULL)
+	|| (strstr((char*)str, "\"SignedFirmwareStatusNotification\"") != NULL))
+    {
+    	isWebsocketSendable = 0;
+    }
+
 	pthread_mutex_lock(&lock_send);
 	memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
 	sprintf((char *)SendBuffer, "%s", str);
@@ -17919,7 +17937,7 @@ void LWS_Send(char * str)
 	//sleep(1);
 }
 
-void LWS_SendNow(char * str)
+void LWS_SendNow(char *str)
 {
 	//=====================================================
 	// Check InternetConn 0: disconnected, 1: connected
@@ -17930,6 +17948,25 @@ void LWS_SendNow(char * str)
 		return;
 	}
 
+	 // Only disable isWebsocketSendable operation initiated by charger
+	if((strstr((char*)str, "\"Authorize\"") != NULL)
+    || (strstr((char*)str, "\"BootNotification\"") != NULL)
+	|| (strstr((char*)str, "\"DataTransfer\"") != NULL)
+	|| (strstr((char*)str, "\"DiagnosticsStatusNotification\"") != NULL)
+	|| (strstr((char*)str, "\"FirmwareStatusNotification\"") != NULL)
+	|| (strstr((char*)str, "\"Heartbeat\"") != NULL)
+	|| (strstr((char*)str, "\"MeterValues\"") != NULL)
+	|| (strstr((char*)str, "\"StartTransaction\"") != NULL)
+	|| (strstr((char*)str, "\"StatusNotification\"") != NULL)
+	|| (strstr((char*)str, "\"StopTransaction\"") != NULL)
+	|| (strstr((char*)str, "\"LogStatusNotification\"") != NULL)
+	|| (strstr((char*)str, "\"SecurityEventNotification\"") != NULL)
+	|| (strstr((char*)str, "\"SignCertificate\"") != NULL)
+	|| (strstr((char*)str, "\"SignedFirmwareStatusNotification\"") != NULL))
+	{
+		isWebsocketSendable = 0;
+	}
+
 	pthread_mutex_lock(&lock_send);
 	memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
 	sprintf((char *)SendBuffer, "%s", str);

+ 0 - 19
EVSE/Modularization/ocppfiles/Module_OcppBackend.c

@@ -110,25 +110,6 @@ int SendData(struct lws *wsi)
     int len;
     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)
-    || (strstr((char*)SendBuffer, "\"BootNotification\"") != NULL)
-	|| (strstr((char*)SendBuffer, "\"DataTransfer\"") != NULL)
-	|| (strstr((char*)SendBuffer, "\"DiagnosticsStatusNotification\"") != NULL)
-	|| (strstr((char*)SendBuffer, "\"FirmwareStatusNotification\"") != NULL)
-	|| (strstr((char*)SendBuffer, "\"Heartbeat\"") != NULL)
-	|| (strstr((char*)SendBuffer, "\"MeterValues\"") != NULL)
-	|| (strstr((char*)SendBuffer, "\"StartTransaction\"") != NULL)
-	|| (strstr((char*)SendBuffer, "\"StatusNotification\"") != 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;
-    }
-
     len = strlen((char *)SendBuffer);
 
     if(len == 0)