Просмотр исходного кода

2020-02-27 / Kathy Yeh
1. modify SendLocalList Request: parentIdTag is Optional field

Kathy_Yeh 5 лет назад
Родитель
Сommit
c392189671
1 измененных файлов с 45 добавлено и 18 удалено
  1. 45 18
      EVSE/Modularization/ocppfiles/MessageHandler.c

+ 45 - 18
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -2,9 +2,9 @@
 #include 	<sys/types.h>
 #include 	<sys/ipc.h>
 #include 	<sys/shm.h>
-#include    <sys/stat.h>
+#include    	<sys/stat.h>
 #include 	<sys/time.h>   // gettimeofday sleep usleep
-#include    <fcntl.h>
+#include    	<fcntl.h>
 #include	<stddef.h>
 #include 	<stdio.h>
 #include	<string.h>
@@ -21,9 +21,7 @@
 #include	"hashmap.h"
 #include	"ShareMemory.h"
 #include	"TransactionQueue.h"
-#include    "SystemLogMessage.h"
 #include	"define.h"
-#include 	"ShareMemory.h"
 #include	"SystemLogMessage.h"
 //#include 	"config.h"
 #include 	<sys/socket.h>
@@ -38,7 +36,7 @@
 //#define _GNU_SOURCE
 #include 	<time.h>
 #include  	"MessageHandler.h"
-#include    <assert.h>
+#include    	<assert.h>
 #include 	<pthread.h>
 #include 	<mcheck.h>
 
@@ -8159,16 +8157,20 @@ int handleSendLocalListRequest(char *uuid, char *payload)
 		}
 		sstr[c] = '\0';
 
+		//DEBUG_INFO("sstr=%s\n", sstr);
+
 		//parsing strings to words
 		i = 0;
 		pch = strtok(sstr,delim1);
 		while (pch != NULL)
 		{
 			strcpy(CardList[i], pch);
+			DEBUG_INFO("CardList[i]=%s\n", CardList[i]);
 			pch = strtok (NULL, delim1);
 			i = i + 1;
 		}
 
+		//DEBUG_INFO("listVersionInt=%s\n", sstr);
 		//local Authorizations List Numbers
 		//n_localAuthorizations = i;
 		ShmOCPP16Data->SendLocalList.ListVersion = listVersionInt;
@@ -8190,32 +8192,54 @@ int handleSendLocalListRequest(char *uuid, char *payload)
 			}
 			sstr[j] = '\0';
 			strcpy(idTagstr, sstr);
+			//DEBUG_INFO("idTagstr=%s\n", idTagstr);
 
 			//Search "expiryDate"
 			memset(sstr ,0, sizeof(sstr) );
 			loc = strstr(CardList[c], "expiryDate");
 			j = 0;
-			while (loc[3+strlen("expiryDate")+j] != '\"')
+			if(loc != NULL)
 			{
-				sstr[j] = loc[3+strlen("expiryDate")+j];
-				//printf("i=%d sstr=%c\n",c, sstr[j]);
-				j++;
+				while (loc[3+strlen("expiryDate")+j] != '\"')
+				{
+					sstr[j] = loc[3+strlen("expiryDate")+j];
+					//printf("i=%d sstr=%c\n",c, sstr[j]);
+					j++;
+				}
+				sstr[j] = '\0';
+				strcpy(expiryDate, sstr);
+
 			}
-			sstr[j] = '\0';
-			strcpy(expiryDate, sstr);
+			else
+			{
+				strcpy(expiryDate, "");
+			}
+
+			//DEBUG_INFO("expiryDate=%s\n", expiryDate);
+
 
 			//Search "parentIdTag"
 			memset(sstr ,0, sizeof(sstr) );
 			loc = strstr(CardList[c], "parentIdTag");
 			j = 0;
-			while (loc[3+strlen("parentIdTag")+j] != '\"')
+			if(loc != NULL)
 			{
-				sstr[j] = loc[3+strlen("parentIdTag")+j];
-				//printf("i=%d sstr=%c\n",c, sstr[j]);
-				j++;
+				while (loc[3+strlen("parentIdTag")+j] != '\"')
+				{
+					sstr[j] = loc[3+strlen("parentIdTag")+j];
+					//printf("i=%d sstr=%c\n",c, sstr[j]);
+					j++;
+				}
+				sstr[j] = '\0';
+				strcpy(parentIdTag, sstr);
 			}
-			sstr[j] = '\0';
-			strcpy(parentIdTag, sstr);
+			else
+			{
+				strcpy(parentIdTag, "");
+			}
+
+			//DEBUG_INFO("parentIdTag=%s\n", parentIdTag);
+
 
 			//Search "status"
 			memset(sstr ,0, sizeof(sstr) );
@@ -8230,9 +8254,12 @@ int handleSendLocalListRequest(char *uuid, char *payload)
 			sstr[j] = '\0';
 			strcpy(idTagstatus, sstr);
 
+			//DEBUG_INFO("idTagstatus=%s\n", idTagstatus);
+
+
 			OCPP_getIdTag(idTagstr);
 			//OCPP_getIdTag("test"); For Test
-			DEBUG_INFO("idTagAuthorization=%s\n",idTagAuthorization);
+			//DEBUG_INFO("idTagAuthorization=%s\n",idTagAuthorization);
 
 			if(strcmp(updateTypestr, UpdateTypeStr[Full]) == 0)
 			{