Ver Fonte

2020-03-23 / Kathy Yeh
1. modify SendLocalList error
2. enlarge per_session_data_size / rx_buffer_size to 65536
3. check Configuration Key ChargingScheduleMaxPeriods . ChargingScheduleAllowedChargingRateUnit for smart charging profile

Kathy_Yeh há 5 anos atrás
pai
commit
16ce0ff7be

Diff do ficheiro suprimidas por serem muito extensas
+ 8 - 3
EVSE/Modularization/ocppfiles/JsonParser.c


+ 33 - 13
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -8161,7 +8161,7 @@ int handleSendLocalListRequest(char *uuid, char *payload)
 			}
 			sstr[j] = '\0';
 			strcpy(idTagstr, sstr);
-			//DEBUG_INFO("idTagstr=%s\n", idTagstr);
+			DEBUG_INFO("idTagstr=%s\n", idTagstr);
 
 			//Search "expiryDate"
 			memset(sstr ,0, sizeof(sstr) );
@@ -8184,7 +8184,7 @@ int handleSendLocalListRequest(char *uuid, char *payload)
 				strcpy(expiryDate, "");
 			}
 
-			//DEBUG_INFO("expiryDate=%s\n", expiryDate);
+			DEBUG_INFO("expiryDate=%s\n", expiryDate);
 
 
 			//Search "parentIdTag"
@@ -8207,7 +8207,7 @@ int handleSendLocalListRequest(char *uuid, char *payload)
 				strcpy(parentIdTag, "");
 			}
 
-			//DEBUG_INFO("parentIdTag=%s\n", parentIdTag);
+			DEBUG_INFO("parentIdTag=%s\n", parentIdTag);
 
 
 			//Search "status"
@@ -8223,12 +8223,13 @@ int handleSendLocalListRequest(char *uuid, char *payload)
 			sstr[j] = '\0';
 			strcpy(idTagstatus, sstr);
 
-			//DEBUG_INFO("idTagstatus=%s\n", idTagstatus);
+			DEBUG_INFO("idTagstatus=%s\n", idTagstatus);
 
 
 			OCPP_getIdTag(idTagstr);
 			//OCPP_getIdTag("test"); For Test
 			//DEBUG_INFO("idTagAuthorization=%s\n",idTagAuthorization);
+			//DEBUG_INFO("updateTypestr=%s\n",updateTypestr);
 
 			if(strcmp(updateTypestr, UpdateTypeStr[Full]) == 0)
 			{
@@ -8236,22 +8237,26 @@ int handleSendLocalListRequest(char *uuid, char *payload)
 				DEBUG_INFO("Local list full update.\n");
 				// update list
 				OCPP_addLocalList_1(listVersionInt, idTagstr, parentIdTag, expiryDate, idTagstatus);
-				OCPP_get_TableAuthlocalAllData();
+				//DEBUG_INFO("Local list full update. 1\n");
+				//OCPP_get_TableAuthlocalAllData();
+				//DEBUG_INFO("Local list full update. 2\n");
 			}
 			else if(strcmp(updateTypestr, UpdateTypeStr[Differential]) == 0)
 			{
 				if((strcmp(idTagstr, idTagAuthorization) == 0) && (parentIdTag[0] != '\0'))
 				{
-					OCPP_addLocalList_1(listVersionInt, idTagstr, parentIdTag, expiryDate, idTagstatus);
+					OCPP_addLocalList_1(listVersionInt, idTagstr, parentIdTag, expiryDate, idTagstatus);  // update
 
 				}
 				else if((strcmp(idTagstr, idTagAuthorization) == 0) && (parentIdTag[0] == '\0'))
 				{
 					OCPP_deleteIdTag(idTagstr);
+					OCPP_addLocalList_1(listVersionInt, idTagstr, parentIdTag, expiryDate, idTagstatus);  // update
+					//OCPP_deleteIdTag(idTagstr);
 				}
 				else if((strcmp(idTagstr, idTagAuthorization) != 0) && (parentIdTag[0] != '\0'))
 				{
-					OCPP_addLocalList_1(listVersionInt, idTagstr, parentIdTag, expiryDate, idTagstatus);
+					OCPP_addLocalList_1(listVersionInt, idTagstr, parentIdTag, expiryDate, idTagstatus);  // add
 
 				}
 
@@ -8688,6 +8693,13 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 		sstr[c] = '\0';
 		strcpy(chargingRateUnitStr,sstr);
 
+		if((strcmp(chargingRateUnitStr,"A")!=0)&& strcmp((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleAllowedChargingRateUnit].ItemData, "Current")==0)
+		{
+			sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Rejected] );
+			goto end;
+		}
+
+
 		if(connectorIdInt == 0) //  an overall limit for the Charge Point.
 		{
 			strcpy((char *)ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.ChargingSchedule.ChargingRateUnit,chargingRateUnitStr);
@@ -8716,6 +8728,13 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 
 	}
 
+	if( chargingSchedulePeriodCount > atoi((const char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleMaxPeriods].ItemData))
+	{
+		sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Rejected] );
+		goto end;
+
+	}
+
 
 	//DEBUG_INFO("chargingSchedulePeriodCount=%d\n",chargingSchedulePeriodCount);
 	//DEBUG_INFO("handleSetChargingProfileRequest -13 -1\n");
@@ -14031,7 +14050,7 @@ void OCPP_getListVerion()
     }
 }
 
-void OCPP_getIdTag(char *idTag)
+void OCPP_getIdTag(char idTag[])
 {
     int rc = 0;
    // const char* data = "Callback function called";
@@ -14072,6 +14091,7 @@ void OCPP_get_TableAuthlocalAllData(void)
     memset(sql, 0, 100);
     memset(zErrMsg, 0, 100);
 
+
     sprintf(sql,"select * from ocpp_auth_local ");
 
     /* Execute SQL statement */
@@ -14114,11 +14134,11 @@ int OCPP_addLocalList_1(int version, char *idTag, char *parentTage, char *expiry
 	 int isSuccess = FALSE;
 	 int ret = 0;
 	 //const char* data = "Callback function called";
-	 char sql[200];
-	 char zErrMsg[100];
+	 char sql[300];
+	 char zErrMsg[200];
 
-	 memset(sql, 0, 200);
-	 memset(zErrMsg, 0, 100);
+	 memset(sql, 0, 300);
+	 memset(zErrMsg, 0, 200);
 
 	 sprintf(sql,"insert or replace into ocpp_auth_local (idtag, parent_idtag, expir_date, status, version) " "VALUES ('%s', '%s', '%s', '%s', %d ); ""SELECT * from ocpp_auth_local", idTag, parentTage, expiryDate, status, version);
 
@@ -14137,7 +14157,7 @@ int OCPP_addLocalList_1(int version, char *idTag, char *parentTage, char *expiry
 	 return isSuccess;
 }
 
-void OCPP_deleteIdTag(char *idTag)
+void OCPP_deleteIdTag(char idTag[])
 {
 	//int ver = 0;
 	//int isSuccess = FALSE;

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

@@ -137,7 +137,9 @@ int GetWebSocketPingInterval(void);
  int OCPP_cleanLocalList();
  int OCPP_addLocalList(int version, char *idTag, char *parentTage, char *expiryDate, char *status);
  int OCPP_addLocalList_1(int version, char *idTag, char *parentTage, char *expiryDate, char *status);
- void OCPP_getIdTag(char *idTag);
- void OCPP_deleteIdTag(char *idTag);
+// void OCPP_getIdTag(char *idTag);
+ void OCPP_getIdTag(char idTag[]);
+// void OCPP_deleteIdTag(char *idTag);
+ void OCPP_deleteIdTag(char idTag[]);
 
 #endif

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

@@ -33,10 +33,12 @@
 #include    	"MessageHandler.h"
 #include	"sqlite3.h"
 
+
 #ifndef SPEC_LATEST_SUPPORTED
 #define SPEC_LATEST_SUPPORTED 13
 #endif
 
+
 #define Debug
 //#define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))
 #define PASS				1
@@ -594,10 +596,13 @@ static int OCPP16Callback(struct lws *wsi, enum lws_callback_reasons reason, voi
 				}
 			}
 
-			char tempin[1024*4]={0};
+			char tempin[65536]={0};
+
+			//char tempin[1024*4]={0};
 			int c = 0;
 			char *loc;
-			char sstr[600]={ 0 };
+			char sstr[65536]={ 0 };
+			//char sstr[600]={ 0 };
 
 		 	//**********Receive Message**********/
 		  	c = 0;
@@ -654,13 +659,13 @@ static struct lws_protocols protocols[] = {
 		"ocpp1.6",
 		OCPP16Callback,
 		65536,//10240,
-		10240,
+		65536,//10240,
 	},
 	{
 		"ocpp1.6",
 		OCPP16Callback,
 		65536,//10240,
-		10240,
+		65536,//10240,
 	},
 	{
 		NULL, NULL, 0		/* End of list */

+ 11 - 7
EVSE/Modularization/ocppfiles/SystemLogMessage.c

@@ -4,15 +4,17 @@
 #include 	<string.h>
 #include	<time.h>
 #include	<stdarg.h>
-//#include    "SystemLogMessage.h"
+
 
 #define Debug
 #define SystemLogMessage
 #ifdef SystemLogMessage
 int StoreLogMsg(const char *fmt, ...)
 {
-	char Buf[4096+256];
-	char buffer[4096];
+	char Buf[65536+256];
+	char buffer[65536];
+	//char Buf[4096+256];
+	//char buffer[4096];
 	time_t CurrentTime;
 	struct tm *tm;
 	va_list args;
@@ -27,7 +29,7 @@ int StoreLogMsg(const char *fmt, ...)
 			tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
 			buffer,
 			tm->tm_year+1900,tm->tm_mon+1);
-	//printf("buffer: %s\n",Buf );
+	printf("buffer: %s\n",Buf );
 	//execl("sh", "sh", "-c", Buf, NULL);//system((const char*)Buf);
 	system((const char*)Buf);
 	#ifdef Debug
@@ -38,8 +40,10 @@ int StoreLogMsg(const char *fmt, ...)
 
 int StoreOcppMsg(const char *fmt, ...)
 {
-	char Buf[4096+256];
-	char buffer[4096];
+	char Buf[65536+256];
+	char buffer[65536];
+	//char Buf[4096+256];
+	//char buffer[4096];
 	time_t CurrentTime;
 	struct tm *tm;
 	va_list args;
@@ -54,7 +58,7 @@ int StoreOcppMsg(const char *fmt, ...)
 			tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
 			buffer,
 			tm->tm_year+1900,tm->tm_mon+1);
-	//printf("buffer: %s\n",Buf );
+	printf("buffer: %s\n",Buf );
 	//execl("sh", "sh", "-c", Buf, NULL);//system((const char*)Buf);
 	system((const char*)Buf);
 	#ifdef Debug

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff