Browse Source

[Improve][Modularization][OcppBackend]

2020.10.18 / Folus Wen

Actions:
1. EVSE/Modularization/ocppfiles/JsonParser.c remove whitespace in payload message and release JSON object.
2. EVSE/Modularization/ocppfiles/MessageHandler.c update composite schedule when receive setChargingProfile & clearChargingProfile message.
3. EVSE/Modularization/ocppfiles/MessageHandler.c MeterValue remove transaction id if charger does not in charging mode.
4. EVSE/Modularization/ocppfiles/MessageHandler.c MeterValue payload generation method change to JSON-C library.
5. EVSE/Modularization/ocppfiles/MessageHandler.c remove whitespace when payload generate.
6. EVSE/Modularization/ocppfiles/MessageHandler.c release JSON object avoid memory leak issue.
7. EVSE/Modularization/ocppfiles/MessageHandler.c MaxChargingProfilesInstalled key default value change to 10.
8. EVSE/Modularization/ocppfiles/Module_OcppBackend.c couterQueueSent reset condition add when queue is empty.
9. EVSE/Modularization/ocppfiles/SystemLogMessage.h debug output into remove file folder.

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

+ 76 - 67
EVSE/Modularization/ocppfiles/JsonParser.c

@@ -84,7 +84,7 @@ static FunCallErrorPtr funcallerror[] = {	handleError	};
 
 void ReceivedMessage(void *in, size_t len)
 {
-	DEBUG_INFO("ReceivedMessage\n");
+	//DEBUG_INFO("ReceivedMessage\n");
 	char tempin[65536];
 	int MsgType = 0;
 	char UniqueId[37],Action[33],Payload[64824],ErrorCode[129],ErrorDescription[513];
@@ -107,82 +107,91 @@ void ReceivedMessage(void *in, size_t len)
 	strcpy(tempin, (const char *)in);
 	memset( (void *)in, 0, sizeof(char)*len );
 
-
-	MsgType = json_object_get_int(json_object_array_get_idx(json_tokener_parse(tempin), 0));
-	sprintf(UniqueId, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 1)));
-
-	if(strcmp((const char *)tempin,"[ ]") == 0)
-	{
-		DEBUG_WARN("Message is empty array.\n");
-	    return;
-	}
-
 	if(tempin[0] != '\0')
 	{
-		if((MsgType != 2) && (MsgType != 3) && (MsgType != 4) )
+		if(strcmp((const char *)tempin,"[ ]") == 0)
 		{
-			DEBUG_WARN("Message type not valid.\n");
+			DEBUG_WARN("Message is empty array.\n");
 			return;
 		}
 
-		if(UniqueId[0] == '\0')
+		json_object *obj = NULL;
+		obj = json_tokener_parse(tempin);
+		if(!is_error(obj))
 		{
-			DEBUG_WARN("Message unique id is null.\n");
-			return;
+			MsgType = json_object_get_int(json_object_array_get_idx(obj, 0));
+			sprintf(UniqueId, "%s", json_object_get_string(json_object_array_get_idx(obj, 1)));
+
+			if((MsgType != 2) && (MsgType != 3) && (MsgType != 4) )
+			{
+				DEBUG_WARN("Message type not valid.\n");
+				return;
+			}
+
+			if(UniqueId[0] == '\0')
+			{
+				DEBUG_WARN("Message unique id is null.\n");
+				return;
+			}
+
+			CheckTransactionPacket(UniqueId);
+
+			switch (MsgType)
+			{
+				case MESSAGE_TYPE_CALL:
+					sprintf(Action, "%s", json_object_get_string(json_object_array_get_idx(obj, 2)));
+					sprintf(Payload, "%s", json_object_to_json_string_ext(json_object_array_get_idx(obj, 3), JSON_C_TO_STRING_PLAIN));
+					CallHandler(UniqueId,Action,Payload);
+					break;
+
+				case MESSAGE_TYPE_CALLRESULT:
+					sprintf(Payload, "%s", json_object_to_json_string_ext(json_object_array_get_idx(obj, 2), JSON_C_TO_STRING_PLAIN));
+
+					if(hashmap_operation(HASH_OP_GET, UniqueId, key_value) == TRUE)
+					{
+						hashmap_operation(HASH_OP_REMOVE, UniqueId, key_value);
+						char * const testdup  = strdup(key_value);
+
+						substr = strtok(testdup, del);
+						while (substr != NULL)
+						{
+							arr[count] = substr;
+							count++;
+							substr = strtok(NULL, del);
+						}
+
+						i=0;
+						sprintf(Action, "%s", *(arr+i++));
+						gun_index = atoi(*(arr+i++));
+						CallResultHandler(Action, Payload, gun_index);
+						free(testdup);
+					}
+
+					break;
+
+			   case MESSAGE_TYPE_CALLERROR:
+				   sprintf(ErrorCode, "%s", json_object_get_string(json_object_array_get_idx(obj, 2)));
+				   sprintf(ErrorDescription, "%s", json_object_get_string(json_object_array_get_idx(obj, 3)));
+				   sprintf(Payload, "%s", json_object_to_json_string_ext(json_object_array_get_idx(obj, 4), JSON_C_TO_STRING_PLAIN));
+
+				   if(hashmap_operation(HASH_OP_GET, UniqueId, key_value) == TRUE)
+				   {
+					   hashmap_operation(HASH_OP_REMOVE, UniqueId, key_value);
+					   sprintf(Action, "%s", key_value);
+					   CallErrorHandler(UniqueId,ErrorCode, ErrorDescription, "");
+				   }
+
+				   break;
+
+				default:
+					break;
+			}
 		}
-
-		CheckTransactionPacket(UniqueId);
-
-		switch (MsgType)
+		else
 		{
-			case MESSAGE_TYPE_CALL:
-				sprintf(Action, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 2)));
-				sprintf(Payload, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 3)));
-			   	CallHandler(UniqueId,Action,Payload);
-			   	break;
-
-			case MESSAGE_TYPE_CALLRESULT:
-				sprintf(Payload, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 2)));
-
-			   	if(hashmap_operation(HASH_OP_GET, UniqueId, key_value) == TRUE)
-			   	{
-			   		hashmap_operation(HASH_OP_REMOVE, UniqueId, key_value);
-			   		char * const testdup  = strdup(key_value);
-
-			   		substr = strtok(testdup, del);
-			   		while (substr != NULL)
-			   		{
-						arr[count] = substr;
-						count++;
-						substr = strtok(NULL, del);
-			   		}
-
-		            i=0;
-			   		sprintf(Action, "%s", *(arr+i++));
-			   		gun_index = atoi(*(arr+i++));
-			   		CallResultHandler(Action, Payload, gun_index);
-			   		free(testdup);
-			   	}
-
-			   	break;
-
-		   case MESSAGE_TYPE_CALLERROR:
-			   sprintf(ErrorCode, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 2)));
-			   sprintf(ErrorDescription, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 3)));
-			   sprintf(Payload, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 4)));
-
-			   if(hashmap_operation(HASH_OP_GET, UniqueId, key_value) == TRUE)
-			   {
-				   hashmap_operation(HASH_OP_REMOVE, UniqueId, key_value);
-				   sprintf(Action, "%s", key_value);
-				   CallErrorHandler(UniqueId,ErrorCode, ErrorDescription, "");
-			   }
-
-			   break;
-
-			default:
-				break;
+			DEBUG_WARN("Message is invalid JSON format.\n");
 		}
+		json_object_put(obj);
 	}
 	else
 	{

+ 126 - 205
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -2121,6 +2121,8 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 
 	if(line)
 		free(line);
+
+	ShmOCPP16Data->CSUMsg.bits[(connectorId==0?0:connectorId-1)].ChargingProfileConf = 1;
 }
 
 //==========================================
@@ -2349,7 +2351,6 @@ void CheckSystemValue(void)
 	   {
 		   checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP16Data->SmartChargingProfile[gun_index]);
 		   ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileReq = 0;
-		   ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileConf = 1;
 	   }
 
 		//==============================================
@@ -2357,7 +2358,7 @@ void CheckSystemValue(void)
 		//==============================================
 		if(/*(server_sign == TRUE) &&*/ (ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionReq == 1))
 		{
-			ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionReq =0;
+			ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionReq = 0;
 			sendStartTransactionRequest(gun_index);
 			clientTime.StartTransaction = time((time_t*)NULL);
 			clientTime.MeterValues[gun_index] = time((time_t*)NULL);
@@ -2368,7 +2369,7 @@ void CheckSystemValue(void)
 		//==============================================
 		if(/*(server_sign == TRUE) &&*/ ((ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq == 1)))
 		{
-			ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq =0;
+			ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq = 0;
 			sendStopTransactionRequest(gun_index);
 			clientTime.StopTransaction = time((time_t*)NULL);
 		}
@@ -3248,7 +3249,7 @@ int sendStartTransactionRequest(int gun_index)
 	strcpy((char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.ParentIdTag, "");
 	strcpy((char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "");
 	ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId = 0;
-
+	clientTime.MeterValues[gun_index] = time((time_t*)NULL);
 	//J: CHAdeMO   U: CCS1 combo   E: CCS2 combo  G: GBT DCcc
 
 	if(gunType[gun_index] == 'J')
@@ -3376,7 +3377,7 @@ int sendStartTransactionRequest(int gun_index)
 
 #if 1
 	sprintf(tempdata, "StartTransaction,%d", (gun_index));
-	if(hashmap_operation(0, guid, tempdata) == 1)//if(hashmap_operation(0,NULL/*hashMap*/, mapItem[0].key_string, mapItem[0].key_value/*mapItem*/, (void**)(&mapItem)/*(void**)(&mapItem)*/) ==  MAP_OK/*hashmap_put(hashMap, mapItem->key_string, mapItem) == MAP_OK*/)
+	if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)//if(hashmap_operation(0,NULL/*hashMap*/, mapItem[0].key_string, mapItem[0].key_value/*mapItem*/, (void**)(&mapItem)/*(void**)(&mapItem)*/) ==  MAP_OK/*hashmap_put(hashMap, mapItem->key_string, mapItem) == MAP_OK*/)
 	{
 		result = PASS;
 	}
@@ -3782,7 +3783,7 @@ S_FAULT                 =12
 
 		sprintf(tempdata, "StatusNotification,%d", (gun_index));
 
-		if(hashmap_operation(0, guid, tempdata) == 1)//if(hashmap_operation(0,NULL/*hashMap*/, guid, mapItem, tempdata/*(void**)(&mapItem)*//*(void**)(&mapItem)*/) ==  MAP_OK/*hashmap_put(hashMap, mapItem->key_string, mapItem) == MAP_OK*/)
+		if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)//if(hashmap_operation(0,NULL/*hashMap*/, guid, mapItem, tempdata/*(void**)(&mapItem)*//*(void**)(&mapItem)*/) ==  MAP_OK/*hashmap_put(hashMap, mapItem->key_string, mapItem) == MAP_OK*/)
 		{
 			//DEBUG_ERROR("statusNotification mapitem pass");
 			result = PASS;
@@ -4773,10 +4774,10 @@ int sendStopTransactionRequest(int gun_index)
 
 #if 1
 	sprintf(tempdata, "StopTransaction,%d", (gun_index));
-	if(hashmap_operation(0, guid, tempdata) == 1)
+	if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
 	{
-			result = PASS;
-			DEBUG_INFO("StopTransaction mapitem pass\n");
+		result = PASS;
+		//DEBUG_INFO("StopTransaction mapitem pass\n");
 	}
 #endif
 	queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
@@ -4807,9 +4808,10 @@ int sendMeterValuesRequest(int gun_index, ReadingContext dataType)
 	DEBUG_INFO("sendMeterValuesRequest ...\n");
 
 	memset(queuedata, 0, ARRAY_SIZE(queuedata));
+	memset(&ShmOCPP16Data->MeterValues[gun_index], 0, sizeof(struct StructMeterValues));
 	//set value
 	ShmOCPP16Data->MeterValues[gun_index].ConnectorId = gun_index + 1; // gun start from 1~
-	ShmOCPP16Data->MeterValues[gun_index].TransactionId = ((strstr((char*)ShmOCPP16Data->StatusNotification[gun_index].Status, "Charging") != NULL) ? ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId : 0);
+	ShmOCPP16Data->MeterValues[gun_index].TransactionId = ((strstr((char*)ShmOCPP16Data->StatusNotification[gun_index].Status, "Charging") != NULL) ? ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId : -1);
 
 	random_uuid(guid);
 
@@ -5443,7 +5445,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContext dataType)
 
 		}
 
-		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Context, ReadingContextStr[ReadingContext_Sample_Periodic]);
+		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Context, ReadingContextStr[dataType]);
 		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Format, ValueFormatStr[Raw]);
 		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Measurand, MeasurandStr[SoC]);
 		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Phase, PhaseStr[L3_N]);
@@ -5566,194 +5568,79 @@ int sendMeterValuesRequest(int gun_index, ReadingContext dataType)
 	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[9].Unit,UnitOfMeasureStr[UnitOfMeasure_V]);
 
 	// Message create ====================================================================================================
-	if((gunType[gun_index] == 'J')||(gunType[gun_index] == 'U')||(gunType[gun_index] == 'E')||(gunType[gun_index] == 'G')||(gunType[gun_index] == 'O'))
+	if(TRUE)
 	{
-		 sprintf(queuedata,"%d,[%d,\"%s\",\"MeterValues\",{\"connectorId\":%d,\"transactionId\":%d,\"meterValue\":[{\"timestamp\":\"%s\",\"sampledValue\":[{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"}]}]}]"
-				 	 	,gun_index + 1
-				 	 	,MESSAGE_TYPE_CALL
-		 	 			,guid
-		 	 			,ShmOCPP16Data->MeterValues[gun_index].ConnectorId
-		 	 			,ShmOCPP16Data->MeterValues[gun_index].TransactionId
-		 				,(const char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].TimeStamp
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Value
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Context
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Format
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Measurand
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Phase
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Location
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Unit
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Value
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Context
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Format
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Measurand
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Phase
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Location
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Unit
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Context
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Format
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Measurand
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Phase
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Location
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Unit
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Value
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Context
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Format
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Measurand
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Phase
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Location
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Unit
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Value
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Context
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Format
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Measurand
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Phase
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Location
-		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Unit
-						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Value
-						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Context
-						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Format
-						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Measurand
-						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Phase
-						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Location
-						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Unit
-		 	 );
+		json_object *MeterValueReq = json_object_new_object();
+		json_object *MeterValues = json_object_new_array();
+		json_object *sampledValues = json_object_new_array();
+
+		json_object_object_add(MeterValueReq, "connectorId", json_object_new_int(ShmOCPP16Data->MeterValues[gun_index].ConnectorId));
+
+		if(ShmOCPP16Data->MeterValues[gun_index].TransactionId != -1)
+			json_object_object_add(MeterValueReq, "transactionId", json_object_new_int(ShmOCPP16Data->MeterValues[gun_index].TransactionId));
+
+		uint8_t idxMeter = 0;
+		while(strlen((char*)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].TimeStamp) > 0)
+		{
+			json_object *MeterValue = json_object_new_object();
+
+			for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].SampledValue);idxSample++)
+			{
+				if(strlen((char*)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].SampledValue[idxSample].Value) > 0)
+				{
+					json_object *sampledValue = json_object_new_object();
+
+					json_object_object_add(sampledValue, "value", json_object_new_string((char*)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].SampledValue[idxSample].Value));
+
+					if(strlen((char*)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].SampledValue[idxSample].Context) > 0)
+						json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].SampledValue[idxSample].Context));
+
+					if(strlen((char*)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].SampledValue[idxSample].Format) > 0)
+						json_object_object_add(sampledValue, "format", json_object_new_string((char*)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].SampledValue[idxSample].Format));
+
+					if(strlen((char*)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].SampledValue[idxSample].Measurand) > 0)
+						json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].SampledValue[idxSample].Measurand));
+
+					if(strlen((char*)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].SampledValue[idxSample].Phase) > 0)
+						json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].SampledValue[idxSample].Phase));
+
+					if(strlen((char*)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].SampledValue[idxSample].Location) > 0)
+						json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].SampledValue[idxSample].Location));
+
+					if(strlen((char*)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].SampledValue[idxSample].Unit) > 0)
+						json_object_object_add(sampledValue, "unit", json_object_new_string((char*)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].SampledValue[idxSample].Unit));
+
+					json_object_array_add(sampledValues, sampledValue);
+				}
+			}
+			json_object_object_add(MeterValue, "timestamp", json_object_new_string((char*)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].TimeStamp));
+			json_object_object_add(MeterValue, "sampledValue", sampledValues);
+			json_object_array_add(MeterValues, MeterValue);
+			idxMeter++;
+		}
+		json_object_object_add(MeterValueReq, "meterValue", MeterValues);
+
+		sprintf(queuedata,"%d,[%d,\"%s\",\"MeterValues\",%s]"
+				 	 	 ,gun_index + 1
+				 	 	 ,MESSAGE_TYPE_CALL
+		 	 			 ,guid
+		 	 			 ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
+
+		json_object_put(MeterValueReq);
 	 }
-	 else
-	 {
-		 if((ShmSysConfigAndInfo->SysConfig.ModelName[2] != 'Y') && (ShmSysConfigAndInfo->SysConfig.ModelName[2] != 'W'))
-		 {
-			 sprintf(queuedata,"%d,[%d,\"%s\",\"MeterValues\",{\"connectorId\":%d,\"transactionId\":%d,\"meterValue\":[{\"timestamp\":\"%s\",\"sampledValue\":[{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"}]}]}]"
-							,gun_index + 1
-							,MESSAGE_TYPE_CALL
-							,guid
-							,ShmOCPP16Data->MeterValues[gun_index].ConnectorId
-							,ShmOCPP16Data->MeterValues[gun_index].TransactionId
-							,(const char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].TimeStamp
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Value
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Context
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Format
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Measurand
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Phase
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Location
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Unit
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Value
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Context
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Format
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Measurand
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Phase
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Location
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Unit
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Context
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Format
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Measurand
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Phase
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Location
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Unit
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Value
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Context
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Format
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Measurand
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Phase
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Location
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Unit
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Value
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Context
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Format
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Measurand
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Phase
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Location
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Unit
-
-				 );
-		 }
-		 else
-		 {
-			 sprintf(queuedata,"%d,[%d,\"%s\",\"MeterValues\",{\"connectorId\":%d,\"transactionId\":%d,\"meterValue\":[{\"timestamp\":\"%s\",\"sampledValue\":[{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"}]}]}]"
-							,gun_index + 1
-							,MESSAGE_TYPE_CALL
-							,guid
-							,ShmOCPP16Data->MeterValues[gun_index].ConnectorId
-							,ShmOCPP16Data->MeterValues[gun_index].TransactionId
-							,(const char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].TimeStamp
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Value
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Context
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Format
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Measurand
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Phase
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Location
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Unit
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Value
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Context
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Format
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Measurand
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Phase
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Location
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Unit
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Context
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Format
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Measurand
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Phase
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Location
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Unit
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Value
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Context
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Format
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Measurand
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Phase
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Location
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Unit
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Value
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Context
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Format
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Measurand
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Phase
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Location
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Unit
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[6].Value
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[6].Context
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[6].Format
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[6].Measurand
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[6].Phase
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[6].Location
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[6].Unit
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[7].Value
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[7].Context
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[7].Format
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[7].Measurand
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[7].Phase
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[7].Location
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[7].Unit
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[8].Value
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[8].Context
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[8].Format
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[8].Measurand
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[8].Phase
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[8].Location
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[8].Unit
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[9].Value
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[9].Context
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[9].Format
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[9].Measurand
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[9].Phase
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[9].Location
-							,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[9].Unit
-				 );
-		 }
-	}
 
 	// Put request guid to hash map
 	sprintf(tempdata, "MeterValues,%d", (gun_index));
 	if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)//if(hashmap_operation(0,NULL/*hashMap*/, mapItem[0].key_string, mapItem[0].key_value/*mapItem*/, (void**)(&mapItem)/*(void**)(&mapItem)*/) ==  MAP_OK/*hashmap_put(hashMap, mapItem->key_string, mapItem) == MAP_OK*/)
 	{
 	 	result = PASS;
-	 	DEBUG_INFO("MeterValues mapitem pass\n");
+	 	//DEBUG_INFO("MeterValues mapitem pass\n");
 	}
 
-	if(dataType != ReadingContext_Trigger)
-		queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );//addq(guid, queuedata);  ---> remove temporally
+	if((dataType != ReadingContext_Trigger) &&
+	   (dataType != ReadingContext_Sample_Clock) &&
+	   (ShmOCPP16Data->MeterValues[gun_index].TransactionId != -1))
+		queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );
 	else
 		LWS_Send(queuedata +2);
 
@@ -7516,6 +7403,19 @@ int handleClearChargingProfileRequest(char *uuid, char *payload)
 	}// (connectorIsNULL == FALSE) && (connectorIdInt != 0)
 
 end:
+	if(strcmp(comfirmstr, ClearChargingProfileStatusStr[ClearChargingProfileStatus_Accepted]) == 0)
+	{
+		if(connectorIdInt == 0)
+		{
+			for(uint8_t idx=0;idx<gunTotalNumber;idx++)
+			{
+				checkCompositeSchedule((idx+1), 86400, &ShmOCPP16Data->SmartChargingProfile[idx]);
+			}
+		}
+		else
+			checkCompositeSchedule(connectorIdInt, 86400, &ShmOCPP16Data->SmartChargingProfile[connectorIdInt-1]);
+	}
+
 	sendClearChargingProfileConfirmation(uuid, comfirmstr);
 
 	return result;
@@ -7556,7 +7456,8 @@ void createFirmwareVersionByDataTransfer(void)
 
 	sprintf((char*)ShmOCPP16Data->DataTransfer[0].VendorId, "Phihong Technology");
 	sprintf((char*)ShmOCPP16Data->DataTransfer[0].MessageId, "ID_FirmwareVersion");
-	sprintf((char*)ShmOCPP16Data->DataTransfer[0].Data, json_object_to_json_string(FirmwareDataTransfer));
+	sprintf((char*)ShmOCPP16Data->DataTransfer[0].Data, json_object_to_json_string_ext(FirmwareDataTransfer, JSON_C_TO_STRING_PLAIN));
+	json_object_put(FirmwareDataTransfer);
 }
 
 int handleDataTransferRequest(char *uuid, char *payload)
@@ -7599,7 +7500,8 @@ int handleDataTransferRequest(char *uuid, char *payload)
 			createFirmwareVersionByDataTransfer();
 			json_object_object_add(response, "status", json_object_new_string("Accepted"));
 			json_object_object_add(response, "data", json_object_new_string((char*)ShmOCPP16Data->DataTransfer[0].Data));
-			sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string(response));
+			sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string_ext(response, JSON_C_TO_STRING_PLAIN));
+			json_object_put(response);
 		}
 		else if(strstr(tempmessageId, "SetLEDBar") != NULL)
 		{
@@ -7628,7 +7530,8 @@ int handleDataTransferRequest(char *uuid, char *payload)
 			}
 			json_object_put(data);
 
-			sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string(response));
+			sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string_ext(response, JSON_C_TO_STRING_PLAIN));
+			json_object_put(response);
 		}
 		else if(strstr(tempmessageId, "SetUserPrice") != NULL)
 		{
@@ -7650,6 +7553,8 @@ int handleDataTransferRequest(char *uuid, char *payload)
 				json_object_object_add(response, "data", json_object_new_string("Configuration content something wrong."));
 			}
 			json_object_put(data);
+
+			json_object_put(response);
 		}
 		else if(strstr(tempmessageId, "RunningCost") != NULL)
 		{
@@ -7670,6 +7575,8 @@ int handleDataTransferRequest(char *uuid, char *payload)
 				json_object_object_add(response, "data", json_object_new_string("Configuration content something wrong."));
 			}
 			json_object_put(data);
+
+			json_object_put(response);
 		}
 		else if(strstr(tempmessageId, "FinalCost") != NULL)
 		{
@@ -7691,6 +7598,8 @@ int handleDataTransferRequest(char *uuid, char *payload)
 				json_object_object_add(response, "data", json_object_new_string("Configuration content something wrong."));
 			}
 			json_object_put(data);
+
+			json_object_put(response);
 		}
 		else
 		{
@@ -8483,7 +8392,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
 
 				sprintf(cmdBuf, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
 				fp = fopen(cmdBuf, "w");
-				fprintf(fp, "{\"connectorId\":%d,\"csChargingProfiles\":%s}\n", connectorIdInt, json_object_to_json_string(json_object_object_get(RemoteStartTransaction, "chargingProfile")));
+				fprintf(fp, "{\"connectorId\":%d,\"csChargingProfiles\":%s}\n", connectorIdInt, json_object_to_json_string_ext(json_object_object_get(RemoteStartTransaction, "chargingProfile"), JSON_C_TO_STRING_PLAIN));
 				fclose(fp);
 			}
 			else
@@ -10445,6 +10354,19 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 	sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Accepted] );
 
 end:
+	if(strcmp(comfirmstr, ChargingProfileStatusStr[ChargingProfileStatus_Accepted]) == 0)
+	{
+		if(connectorIdInt == 0)
+		{
+			for(uint8_t idx=0;idx<gunTotalNumber;idx++)
+			{
+				checkCompositeSchedule((idx+1), 86400, &ShmOCPP16Data->SmartChargingProfile[idx]);
+			}
+		}
+		else
+			checkCompositeSchedule(connectorIdInt, 86400, &ShmOCPP16Data->SmartChargingProfile[connectorIdInt-1]);
+	}
+
 	sendSetChargingProfileConfirmation(uuid, comfirmstr);
 	return result;
 }
@@ -11890,7 +11812,7 @@ int initialConfigurationTable(void)
 		// MaxChargingProfilesInstalled
 		ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemAccessibility = 0;
 		strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemName, "MaxChargingProfilesInstalled");
-		strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemData, "5" );
+		strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemData, "10" );
 
 		fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","MaxChargingProfilesInstalled", "true", ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemData);
 
@@ -12730,7 +12652,7 @@ void StoreConfigurationTable(void)
 	/*
 	ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemAccessibility = 0;
 	strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemName, "MaxChargingProfilesInstalled");
-	strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemData, "3" );
+	strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemData, "10" );
 	*/
 
 	fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","MaxChargingProfilesInstalled", "true", (char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemData);
@@ -14750,7 +14672,6 @@ int setKeyValue(char *key, char *value)
             }
             else
             {
-
                  sprintf((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemData, "%d", atoi(value) );
                  isSuccess = ConfigurationStatus_Accepted;
             }
@@ -15392,14 +15313,14 @@ int GetTransactionId(int gunindex, unsigned char idTag[], uint8_t isStopTransact
 			{
 				break;
 			}
-			char *revbuf[8] = {0}; //存放分割後的子字串
-			int num = 0;//分割後子字串的個數
-			DEBUG_INFO("str: %s\n", str);
-			splitstring(str,",",revbuf,&num); //呼叫函式進行分割
-			DEBUG_INFO("revbuf[0]: %s\n", revbuf[0]);
-			DEBUG_INFO("revbuf[1]: %s\n", revbuf[1]);
-			DEBUG_INFO("revbuf[2]: %s\n", revbuf[2]);
-
+			char *revbuf[8] = {0}; // Variable store string split
+			int num = 0;// Quantity after string split
+			DEBUG_INFO("Transaction queue data= %s\n", str);
+			splitstring(str,",",revbuf,&num); // String split
+			DEBUG_INFO("             revbuf[0]= %s\n", revbuf[0]);
+			DEBUG_INFO("             revbuf[1]= %s\n", revbuf[1]);
+			DEBUG_INFO("             revbuf[2]= %s\n", revbuf[2]);
+			DEBUG_INFO("------------------------------\n");
 			if((revbuf[1][0] != '\0')&&(revbuf[2][0] != '\0'))
 			{
 				if(isStopTransaction)
@@ -16545,7 +16466,7 @@ void checkTempStopTransaction(int gun_index)
 			sprintf(tempdata, "StopTransaction,%d", (gun_index));
 			if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
 			{
-				DEBUG_INFO("StopTransaction mapitem pass\n");
+				//DEBUG_INFO("StopTransaction mapitem pass\n");
 			}
 			queue_operation(QUEUE_OPERATION_ADD, guid, str);//addq(guid, queuedata); ---> remove temporally
 

+ 13 - 12
EVSE/Modularization/ocppfiles/Module_OcppBackend.c

@@ -620,7 +620,7 @@ int showfront(char *uuid, char *data)
 }
 
 int addq(char *uuid, char *data)
-	{
+{
 	FILE *outfile;
 	char rmFileCmd[100]={0};
 	struct stat stats;
@@ -1048,13 +1048,13 @@ int sentqueue(){
 			strcpy((char*)timestampStr, sstr);
 
 
-			if(hashmap_operation(1, guid, key_value) == TRUE)
+			if(hashmap_operation(HASH_OP_GET, guid, key_value) == TRUE)
 			{
 				//DEBUG_INFO("\n 1. sent queue guid=%s\n",guid);
 			}
 			else
 			{
-				hashmap_operation(0, guid, tempdata);
+				hashmap_operation(HASH_OP_ADD, guid, tempdata);
 				FillStartTransaction(tempconnectorId, IdtagStr, tempmeterStart, tempreservationId, timestampStr);
 				//DEBUG_INFO("\n 2. sent queue guid=%s\n",guid);
 			}
@@ -1068,7 +1068,7 @@ int sentqueue(){
 		 memset(sstr ,0, ARRAY_SIZE(sstr) );
 		 if(loc != NULL)
 		 {
-
+			 // Only MeterValue with transactionId & StopTransaction will arrive here
 			 while ((loc[strlen("transactionId")+2+c] != '}') && (loc[strlen("transactionId")+2+c] != ','))
 			 {
 				sstr[c] = loc[strlen("transactionId")+2+c];
@@ -1078,30 +1078,30 @@ int sentqueue(){
 			sstr[c] = '\0';
 			temptransactionId = atoi(sstr);
 
-			//gettransactionId = GetTransactionId(tempconnectorId, IdtagStr);
 
-			//From StartTransaction取得IdTag, 存到 StartTransactionIdTagTemp,主要是 給Queue中StopTransaction使用(StartTransaction. StopTransaction不同卡號 ),取得真正的TransactionId
+			//Get IdTag from StartTransaction , store to StartTransactionIdTagTemp, For StopTransaction usage in Queue (StartTransaction. StopTransaction user id different), get actual TransactionId
 			GetStartTransactionIdTag(tempconnectorId-1);
 			gettransactionId = GetTransactionId(tempconnectorId, (uint8_t *)StartTransactionIdTagTemp, IsStopTransaction);
 
-			DEBUG_INFO("tempconnectorId = %d\n", tempconnectorId);
-			DEBUG_INFO("temptransactionId = %d\n",temptransactionId);
+			DEBUG_INFO("queue map transactionId   = %d\n", gettransactionId);
+			DEBUG_INFO("original  connectorId     = %d\n", tempconnectorId);
+			DEBUG_INFO("original  transactionId   = %d\n", temptransactionId);
 			DEBUG_INFO("StartTransactionIdTagTemp = %s\n", StartTransactionIdTagTemp);
-			DEBUG_INFO("gettransactionId = %d\n",gettransactionId);
 			if((gettransactionId != 0)&&(temptransactionId != gettransactionId))
 			{
 				//replace transactionId of metervalue or stopTransaction
 				strncpy(strcomposite,str, (loc-str)+2+strlen("transactionId"));
 				sprintf(strcomposite+((loc-str)+2+strlen("transactionId")),"%d",gettransactionId);
 				strcat(strcomposite, loc+strlen("transactionId")+2+c); // 把 字串中transactionId後面的字串串接到 strcomposite後面
-				LWS_Send(strcomposite+2); // skip 2 bytes字串->  槍號,
+				LWS_Send(strcomposite+2); // skip 2 bytes String -> Connector ID,
 			}
 			else
 			{
-				LWS_Send(str+2);  // skip 2 bytes字串->  槍號,
+				LWS_Send(str+2);  // skip 2 bytes String -> Connector ID
 				gettransactionId = temptransactionId;
 			}
 
+			DEBUG_INFO("Final transactionId       = %d\n", gettransactionId);
 			if(IsStopTransaction == TRUE)//if((IsStopTransaction == TRUE)&&(gettransactionId != 0))
 			{
 				SetTransactionIdZero(gettransactionId);
@@ -1109,6 +1109,7 @@ int sentqueue(){
 		 }
 		 else
 		 {
+			 // MeterValue without transactionId & StartTransaction arrive here
 			 LWS_Send(str+2);
 		 }
 
@@ -1192,7 +1193,7 @@ void* processTransactionQueue(void* data)
 
 			// Refresh queue timer
 			startTimeQueue = time((time_t*)NULL);
-			if(counterQueueSent >= 10)
+			if((counterQueueSent >= 10) || (queueNotEmpty == FALSE))
 			{
 				counterQueueSent = 0;
 			}

+ 4 - 4
EVSE/Modularization/ocppfiles/SystemLogMessage.h

@@ -2,10 +2,10 @@
 #define SystemLogMessage_H
 
 #define SystemLogMessage
-#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_OCPPMESSAGE_INFO(format, args...) StoreOcppMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
+#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
+#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
+#define DEBUG_OCPPMESSAGE_INFO(format, args...) StoreOcppMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
 
 int StoreLogMsg(const char *fmt, ...);
 int StoreOcppMsg(const char *fmt, ...);

+ 3 - 3
EVSE/Projects/AW-CCS/Apps/CCS/SystemLogMessage.h

@@ -40,9 +40,9 @@
     #define DEBUG_PRINTF_EVCOMM_SYSTEM_LOG(...)
 #endif
 
-#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
+#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
+#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
 
 int StoreLogMsg(const char *fmt, ...);
 

+ 3 - 3
EVSE/Projects/AW-CCS/Apps/LCM/lcmComm.h

@@ -8,9 +8,9 @@
 #ifndef LCMCOMM_H_
 #define LCMCOMM_H_
 
-#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
+#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
+#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
 
 #define ALIGN_H_LEFT                                  (1<<0)
 #define ALIGN_H_CENTER                                (1<<1)

+ 3 - 3
EVSE/Projects/AW-CCS/Apps/Module_AlarmDetect.c

@@ -29,9 +29,9 @@
 
 #define FILTER_SPEC			2
 
-#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
+#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
+#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
 
 #define Debug
 #define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))

+ 45 - 0
EVSE/Projects/AW-CCS/Apps/Module_ConfigTools.c

@@ -247,6 +247,7 @@ int main(void)
 		printf("\n  system: system configuration menu.");
 		printf("\n  ocpp: ocpp configuration menu.");
 		printf("\n  network: netwok configuration menu.");
+		printf("\n  test: charger start/stop test.");
 		printf("\n  upgrade: trigger firmware upgrade.");
 		printf("\n  save: Save config.");
 		printf("\n  exit: Exit config tools.");
@@ -532,6 +533,50 @@ int main(void)
 				}
 			}
 		}
+		else if(strcmp(cmd, "test") == 0)
+		{
+			memset(cmd, 0x00, ARRAY_SIZE(cmd));
+			printf("\n ***** test menu ******************");
+			printf("\n  start: EVSE start charging request.");
+			printf("\n  stop: EVSE stop charging request.");
+			printf("\n  cancel: return to main menu.");
+			printf("\n *************************************************");
+			printf("\n  Please input operation item: ");
+			scanf("%s", &cmd[0]);
+
+			if(strcmp(cmd, "start") == 0)
+			{
+				memset(cmd, 0x00, ARRAY_SIZE(cmd));
+				printf("\n  Please input gun index(1~2): ");
+				scanf("%s", &cmd[0]);
+
+				if((0 < atoi(cmd)) && (atoi(cmd) < 3))
+				{
+					ShmSysConfigAndInfo->SysInfo.AcChargingData[atoi(cmd)-1].schedule.isTriggerStart = ON;
+				}
+				else
+				{
+					printf("\n  Invalid input gun_index.");
+				}
+			}
+			else if(strcmp(cmd, "stop") == 0)
+			{
+				memset(cmd, 0x00, ARRAY_SIZE(cmd));
+				printf("\n  Please input gun index(1~2): ");
+				scanf("%s", &cmd[0]);
+
+				if((0 < atoi(cmd)) && (atoi(cmd) < 3))
+				{
+					ShmSysConfigAndInfo->SysInfo.AcChargingData[atoi(cmd)-1].schedule.isTriggerStop = ON;
+				}
+				else
+				{
+					printf("\n  Invalid input gun_index.");
+				}
+			}
+			else if(strcmp(cmd, "cancel") == 0)
+			{}
+		}
 		else if(strcmp(cmd, "upgrade") == 0)
 		{
 			printf("\n  Firmware upgrade trigger.");

+ 3 - 5
EVSE/Projects/AW-CCS/Apps/Module_InternalComm.h

@@ -1,16 +1,14 @@
 /*
  * Module_InternalComm.h
  *
- *  Created on: 2020年01月15日
- *      Author: USER
  */
 
 #ifndef MODULE_INTERNALCOMM_H_
 #define MODULE_INTERNALCOMM_H_
 
-#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
+#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
+#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
 
 extern int StoreLogMsg(const char *fmt, ...);
 

+ 4 - 4
EVSE/Projects/AW-CCS/Apps/Module_Speaker.c

@@ -36,10 +36,10 @@
 #include	"define.h"
 #include	"main.h"
 
-#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define EVENT_INFO(format, args...) StoreEventLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
+#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
+#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
+#define EVENT_INFO(format, args...) StoreEventLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
 
 #define Debug
 #define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))

+ 5 - 5
EVSE/Projects/AW-CCS/Apps/main.c

@@ -32,7 +32,7 @@
 #define TIMEOUT_SPEC_AUTH						15000
 #define TIMEOUT_SPEC_HANDSHAKING_LED			185000
 #define TIMEOUT_SPEC_LOGPPRINTOUT				30000
-#define TIMEOUT_SPEC_PROFILE_PREPARE			5000
+#define TIMEOUT_SPEC_PROFILE_PREPARE			60000
 #define TIMEOUT_SPEC_BS_HLC_HANDSHAKE			60000
 #define TIMEOUT_SPEC_EV_READY					30000
 #define TIMEOUT_SPEC_CCS_HEARTBEAT_COUNT_RESET	10000
@@ -2197,9 +2197,9 @@ void checkConnectionTimeout()
 		if(strcmp((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData,"") != 0)
 		{
 			ShmCharger->timeoutSpec.Setting_Timeout_Spec = atoi((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData);
-			if(ShmCharger->timeoutSpec.Setting_Timeout_Spec < TIMEOUT_SPEC_BS_HLC_HANDSHAKE)
+			if((ShmCharger->timeoutSpec.Setting_Timeout_Spec*1000) < TIMEOUT_SPEC_BS_HLC_HANDSHAKE)
 			{
-				ShmCharger->timeoutSpec.Present_Timeout_Spec = TIMEOUT_SPEC_BS_HLC_HANDSHAKE;
+				ShmCharger->timeoutSpec.Present_Timeout_Spec = (TIMEOUT_SPEC_BS_HLC_HANDSHAKE+10000);
 				//DEBUG_INFO("Handshaking timeout specification follow by OCPP Configuration : Fail. Value can't be zero or less than zero.\n.");
 			}
 			else
@@ -3412,11 +3412,11 @@ int main(void)
 						// Debug information
 						if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_LOGPPRINTOUT]) > TIMEOUT_SPEC_LOGPPRINTOUT)
 						{
-							DEBUG_INFO("=======================================================================\n");
+							DEBUG_INFO("===============================================================\n");
 							DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent: %d \n", ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
 							DEBUG_INFO("ShmCharger->gun_info[%d].primaryMcuCp_Pwn_Duty.max_current: %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current);
 							DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent: %d\n", gun_index, ShmCharger->gun_info[gun_index].targetCurrent);
-							DEBUG_INFO("=======================================================================\n");
+							DEBUG_INFO("===============================================================\n");
 							ftime(&startTime[gun_index][TMR_IDX_LOGPPRINTOUT]);
 						}
 

+ 3 - 3
EVSE/Projects/AW-CCS/Apps/main.h

@@ -194,9 +194,9 @@ enum EVSE_NOTIFICATION
 	NOTIFICATION_RENEGOTIATION
 };
 
-#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
+#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
+#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
 
 extern int StoreLogMsg(const char *fmt, ...);