Browse Source

Merge branch 'master' of https://git.phihong.com.tw:30000/System_Integration/CSU3_AM335x

TC_Hsu 4 years ago
parent
commit
f4717ea7d3
52 changed files with 1812 additions and 92 deletions
  1. 9 1
      EVSE/Modularization/Makefile
  2. 17 11
      EVSE/Modularization/Module_4g.c
  3. 3 3
      EVSE/Modularization/Module_EventLogging.c
  4. 1456 0
      EVSE/Modularization/Module_PhBackend.c
  5. 108 0
      EVSE/Modularization/Module_PhBackend.h
  6. 1 1
      EVSE/Modularization/Module_ProduceUtils.c
  7. 1 1
      EVSE/Modularization/Module_RFID.c
  8. 1 1
      EVSE/Modularization/Module_Upgrade.c
  9. 6 7
      EVSE/Modularization/Module_Wifi.c
  10. 30 1
      EVSE/Modularization/ocppfiles/MessageHandler.c
  11. 7 0
      EVSE/Modularization/ocppfiles/Module_OcppBackend.c
  12. 11 5
      EVSE/Projects/AW-CCS/Apps/Module_InternalComm.c
  13. 1 1
      EVSE/Projects/AW-CCS/Apps/Module_InternalComm.h
  14. 61 31
      EVSE/Projects/AW-CCS/Apps/main.c
  15. 4 2
      EVSE/Projects/AW-CCS/Apps/main.h
  16. BIN
      EVSE/Projects/AW-CCS/Images/FactoryDefaultConfig.bin
  17. BIN
      EVSE/Projects/AW-CCS/Images/ramdisk.gz
  18. 1 1
      EVSE/Projects/AW-Regular/Apps/Module_InternalComm.c
  19. 1 1
      EVSE/Projects/AW-Regular/Apps/Module_InternalComm.h
  20. 6 5
      EVSE/Projects/AW-Regular/Apps/main.c
  21. BIN
      EVSE/Projects/AW-Regular/Images/FactoryDefaultConfig.bin
  22. BIN
      EVSE/Projects/AW-Regular/Images/MLO
  23. BIN
      EVSE/Projects/AW-Regular/Images/ramdisk.gz
  24. BIN
      EVSE/Projects/AW-Regular/Images/u-boot.img
  25. BIN
      EVSE/Projects/AW-Regular/Images/zImage
  26. 1 1
      EVSE/Projects/BYTON-GB/Apps/Module_InternalComm.c
  27. 1 1
      EVSE/Projects/BYTON-GB/Apps/Module_InternalComm.h
  28. 6 5
      EVSE/Projects/BYTON-GB/Apps/main.c
  29. BIN
      EVSE/Projects/BYTON-GB/Images/FactoryDefaultConfig.bin
  30. BIN
      EVSE/Projects/BYTON-GB/Images/MLO
  31. BIN
      EVSE/Projects/BYTON-GB/Images/ramdisk.gz
  32. BIN
      EVSE/Projects/BYTON-GB/Images/u-boot.img
  33. BIN
      EVSE/Projects/BYTON-GB/Images/zImage
  34. 1 1
      EVSE/Projects/Noodoe/Apps/Module_FactoryConfig.c
  35. 1 1
      EVSE/Projects/Noodoe/Apps/Module_InternalComm.c
  36. 1 1
      EVSE/Projects/Noodoe/Apps/Module_InternalComm.h
  37. 6 5
      EVSE/Projects/Noodoe/Apps/main.c
  38. BIN
      EVSE/Projects/Noodoe/Images/FactoryDefaultConfig.bin
  39. BIN
      EVSE/Projects/Noodoe/Images/MLO
  40. BIN
      EVSE/Projects/Noodoe/Images/ramdisk.gz
  41. BIN
      EVSE/Projects/Noodoe/Images/u-boot-spl.bin
  42. BIN
      EVSE/Projects/Noodoe/Images/u-boot.img
  43. BIN
      EVSE/Projects/Noodoe/Images/zImage
  44. 11 1
      EVSE/Projects/define.h
  45. BIN
      EVSE/rootfs/lib/firmware/mrvl/USB8801.bin
  46. BIN
      EVSE/rootfs/root/Module_PhBackend
  47. 48 0
      EVSE/rootfs/root/u-blox_tools/bridge_init.conf
  48. BIN
      EVSE/rootfs/root/u-blox_tools/mfgbridge
  49. 6 0
      EVSE/rootfs/usr/bin/run_u-blox_tools.sh
  50. 1 1
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.version
  51. 4 3
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/.am335x-evm.dtb.dts.tmp
  52. 1 0
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/am335x-evm.dts

+ 9 - 1
EVSE/Modularization/Makefile

@@ -4,7 +4,7 @@ export PATH=/bin:/sbin:/usr/bin:$(SDK_PATH_TARGET)/usr/bin:$PATH
 #define library variable
 Lib_SQLite3 = "-L../../../Modularization/ocppfiles" -lsqlite3
 
-all: clean Module_RFIDLib Module_Wifi WebServiceLib OcppBackend Phihong_PsuCommObj Module_4g Module_UpgradeLib Infypwr_PsuCommObj Module_EventLogging Module_ProduceUtils
+all: clean Module_RFIDLib Module_Wifi WebServiceLib OcppBackend Phihong_PsuCommObj Module_4g Module_UpgradeLib Infypwr_PsuCommObj Module_EventLogging Module_ProduceUtils Module_PhBackend
 
 
 clean:
@@ -18,6 +18,7 @@ clean:
 	rm -f libModule_Upgrade.a
 	rm -f libInfypwr_PsuCommObj.a
 	rm -f Module_ProduceUtils
+	rm -f Module_PhBackend
 
 Module_ProduceUtils:
 	rm -f Module_ProduceUtils
@@ -87,3 +88,10 @@ Module_EventLogging:
 	rm -f Module_EventLogging.o
 	mv -f Module_EventLogging ../rootfs/root
 
+Module_PhBackend:
+	rm -f Module_Phbackend
+	$(CC) -D $(Project) -I ../Projects -O0 -g3 -Wall -c -fmessage-length=0 -o Module_PhBackend.o Module_PhBackend.c
+	$(CC) -o Module_PhBackend Module_PhBackend.o
+	rm -f Module_PhBackend.o
+	mv -f Module_PhBackend ../rootfs/root
+

+ 17 - 11
EVSE/Modularization/Module_4g.c

@@ -1,8 +1,10 @@
 /*
- * Module_4g.c
+ *  Module_4g.c
  *
- *  Created on: 2019年11月29日
- *      Author: Eason Yang
+ *  Created on: 2019-11-29
+ *  Update on: 2020-06-18
+ *  Author: Eason Yang
+ *  Version: D0.02
  */
 
 #include    <sys/types.h>
@@ -73,7 +75,7 @@ void trim_s(char *s, unsigned char len);
 void substr(char *dest, const char* src, unsigned int start, unsigned int cnt);
 
 char *portName[3] 			= {"/dev/ttyUSB2", "/dev/ttyUSB2", "/dev/ttyACM2"};
-char *valid_Internet[2] 	= {"8.8.8.8", "www.baidu.com"};
+char *valid_Internet[2] 	= {"8.8.8.8", "180.76.76.76"};
 pid_t	pid;
 
 struct dongle_info
@@ -113,7 +115,7 @@ int StoreLogMsg(const char *fmt, ...)
 	memset(Buf,0,sizeof(Buf));
 	CurrentTime = time(NULL);
 	tm=localtime(&CurrentTime);
-	sprintf(Buf,"echo \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]4g_SystemLog",
+	sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]4g_SystemLog",
 			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);
@@ -788,12 +790,11 @@ int isReachableInternet(void)
 	FILE *fp;
 	char cmd[256];
 	char buf[512];
-	char tmp[512];
+	//char tmp[512];
 
 	for(int idx=0;idx<ARRAY_SIZE(valid_Internet);idx++)
 	{
-		strcpy(cmd, "ping -c 1 -w 3 ");
-		strcat(cmd, valid_Internet[idx]);
+		sprintf(cmd, "ping -c 1 -w 3 -I ppp0 %s", valid_Internet[idx]);
 		fp = popen(cmd, "r");
 		if(fp != NULL)
 		{
@@ -801,12 +802,18 @@ int isReachableInternet(void)
 			{
 				if(strstr(buf, "transmitted") > 0)
 				{
-					sscanf(buf, "%*s%*s%*s%*s%*s%s", tmp);
+					//sscanf(buf, "%*s%*s%*s%*s%*s%s", tmp);
+
+					if(strstr(buf,"100%") != NULL)
+					{
 
-					if(strcmp(tmp,"100%") != 0)
+					}
+					else
 					{
 						result = PASS;
 					}
+					//DEBUG_INFO("%s",buf);
+					//DEBUG_INFO("%s\n",tmp);
 				}
 			}
 		}
@@ -1065,7 +1072,6 @@ int main(void)
 	{
 		if(((Dongle.Model = Check4GModem()) != FAIL))
 		{
-			system("pkill Module_Wifi");
 			ShmStatusCodeData->FaultCode.FaultEvents.bits.Telecom4GModuleBroken = 0;
 
 			Dongle.cnt_SearchModuleFail = 0;

+ 3 - 3
EVSE/Modularization/Module_EventLogging.c

@@ -64,7 +64,7 @@ int StoreLogMsg(const char *fmt, ...)
 	memset(Buf,0,sizeof(Buf));
 	CurrentTime = time(NULL);
 	tm=localtime(&CurrentTime);
-	sprintf(Buf,"echo \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/Eventlog/[%04d.%02d]EventLog",
+	sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/Eventlog/[%04d.%02d]EventLog",
 			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);
@@ -96,7 +96,7 @@ int StoreEventLogMsg(const char *fmt, ...)
 
 	if((ShmSysConfigAndInfo->SysConfig.ModelName != NULL) && (ShmSysConfigAndInfo->SysConfig.SerialNumber != NULL) && (strlen((char*)ShmSysConfigAndInfo->SysConfig.ModelName) >= 14))
 	{
-		sprintf(Buf,"echo \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/EventLog/[%04d.%02d]%s_%s_EventLog",
+		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/EventLog/[%04d.%02d]%s_%s_EventLog",
 					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,
@@ -105,7 +105,7 @@ int StoreEventLogMsg(const char *fmt, ...)
 	}
 	else
 	{
-		sprintf(Buf,"echo \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/EventLog/[%04d.%02d]EventLog",
+		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/EventLog/[%04d.%02d]EventLog",
 					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);

+ 1456 - 0
EVSE/Modularization/Module_PhBackend.c

@@ -0,0 +1,1456 @@
+/*
+ * Module_PhBackend.c
+ *
+ *  Created on: 2020/06/11
+ *      Author: foluswen
+ */
+#include "Module_PhBackend.h"
+
+int StoreLogMsg(const char *fmt, ...)
+{
+	char Buf[4096+256];
+	char buffer[4096];
+	time_t CurrentTime;
+	struct tm *tm;
+	va_list args;
+
+	va_start(args, fmt);
+	int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
+	va_end(args);
+
+	memset(Buf,0,sizeof(Buf));
+	CurrentTime = time(NULL);
+	tm=localtime(&CurrentTime);
+	sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]Module_PhBackend",
+			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);
+#ifdef SystemLogMessage
+	system(Buf);
+#endif
+
+#ifdef ConsloePrintLog
+	printf("[%04d.%02d.%02d %02d:%02d:%02d] - %s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec, buffer);
+#endif
+
+	return rc;
+}
+
+uint8_t split(char *src, const char *separator, char **dest)
+{
+     char *pNext;
+     int count = 0;
+
+     if (src == NULL || strlen(src) == 0)
+        return count;
+     if (separator == NULL || strlen(separator) == 0)
+        return count;
+     pNext = (char *)strtok(src,separator);
+     while(pNext != NULL)
+     {
+         *dest++ = pNext;
+         ++count;
+         pNext = (char *)strtok(NULL,separator);
+    }
+
+     return count;
+}
+
+//==========================================
+// Init all share memory
+//==========================================
+int InitShareMemory()
+{
+	int result = PASS;
+	int MeterSMId;
+
+	//creat ShmSysConfigAndInfo
+	if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0)
+    {
+		#ifdef SystemLogMessage
+		DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
+		#endif
+		result = FAIL;
+	}
+    else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+    {
+    	#ifdef SystemLogMessage
+    	DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
+		#endif
+    	result = FAIL;
+   	 }
+    else
+    {}
+
+   	//creat ShmStatusCodeData
+   	if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0)
+    {
+		#ifdef SystemLogMessage
+   		DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
+		#endif
+   		result = FAIL;
+	}
+    else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+    {
+    	#ifdef SystemLogMessage
+    	DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
+		#endif
+    	result = FAIL;
+   	}
+    else
+    {}
+
+    return result;
+}
+
+uint8_t checksum_valid(struct Message *message)
+{
+	uint8_t chksum = 0;
+
+	for(uint16_t idx=6;idx<(message->buffer[2] | ((uint16_t)message->buffer[3]<<8));idx++)
+		chksum += message->buffer[idx];
+
+	chksum += 11;
+
+	return ((chksum&0xff)==message->buffer[(message->buffer[2] | ((uint16_t)message->buffer[3]<<8))-1]?PASS:FAIL);
+}
+
+uint8_t checksum_cal(struct Message *message)
+{
+	uint8_t chksum = 0;
+
+	for(uint16_t idx=6;idx<(message->size-1);idx++)
+		chksum += message->buffer[idx];
+
+	chksum += 11;
+
+	return (chksum & 0xff);
+}
+
+void showCmdRaw(struct Message *message, uint8_t isTx)
+{
+	if(isTx)
+		DEBUG_INFO("%s -----> Server\n", ShmSysConfigAndInfo->SysConfig.SystemId);
+	else
+		DEBUG_INFO("%s <----- Server\n", ShmSysConfigAndInfo->SysConfig.SystemId);
+
+	DEBUG_INFO("- CMD_%04d ------------------------------------\n", (message->buffer[6] | ((uint16_t)message->buffer[7]<<8)));
+	DEBUG_INFO("%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+	DEBUG_INFO("-----------------------------------------------\n");
+
+	for(uint8_t idx=0;idx<((message->size/16)+1);idx++)
+	{
+		DEBUG_INFO("%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", message->buffer[idx*16+0],
+																									  message->buffer[idx*16+1],
+																									  message->buffer[idx*16+2],
+																									  message->buffer[idx*16+3],
+																									  message->buffer[idx*16+4],
+																									  message->buffer[idx*16+5],
+																									  message->buffer[idx*16+6],
+																									  message->buffer[idx*16+7],
+																									  message->buffer[idx*16+8],
+																									  message->buffer[idx*16+9],
+																									  message->buffer[idx*16+10],
+																									  message->buffer[idx*16+11],
+																									  message->buffer[idx*16+12],
+																									  message->buffer[idx*16+13],
+																									  message->buffer[idx*16+14],
+																									  message->buffer[idx*16+15]);
+	}
+
+	DEBUG_INFO("-----------------------------------------------\n");
+}
+
+void handle_cmd_1001(struct Message *in, struct Message *out)
+{
+	uint32_t startAddr;
+	uint32_t offset = 0;
+	uint8_t	count;
+	uint32_t value;
+
+	DEBUG_INFO("User ID: %d\n", (in->buffer[8] | ((uint16_t)in->buffer[9]<<8)));
+	DEBUG_INFO("CMD SN: %d\n", (in->buffer[10] | ((uint16_t)in->buffer[11]<<8)));
+	if(in->buffer[12])
+			DEBUG_INFO("CMD Type: Set\n");
+	else
+		DEBUG_INFO("CMD Type: Query\n");
+
+	startAddr = in->buffer[13] | ((uint32_t)in->buffer[14]<<8) | ((uint32_t)in->buffer[15]<<16) | ((uint32_t)in->buffer[16]<<24);
+	count = in->buffer[17];
+
+	if(in->buffer[12])
+	{
+		for(int idx=startAddr;idx<(startAddr+count);idx++)
+		{
+			value = in->buffer[20+(offset*4)] | ((uint32_t)in->buffer[21+(offset*4)]<<8) | ((uint32_t)in->buffer[22+(offset*4)]<<16) | ((uint32_t)in->buffer[23+(offset*4)]<<24);
+
+			switch(idx)
+			{
+				case 1:
+					DEBUG_INFO("Sign in interval: %d\n", value);
+					offset++;
+					break;
+				case 2:
+					DEBUG_INFO("Charger type: %d\n", value);
+					offset++;
+					break;
+				case 3:
+					DEBUG_INFO("Charger gun count: %d\n", value);
+					offset++;
+					break;
+				case 4:
+					DEBUG_INFO("Communication No: %d\n", value);
+					offset++;
+					break;
+				case 5:
+					offset++;
+					break;
+				case 6:
+					offset++;
+					break;
+				case 7:
+					offset++;
+					break;
+				case 8:
+					offset++;
+					break;
+				case 9:
+					offset++;
+					break;
+				case 10:
+					offset++;
+					break;
+				case 11:
+					offset++;
+					break;
+				case 12:
+					offset++;
+					break;
+				case 13:
+					offset++;
+					break;
+				case 14:
+					offset++;
+					break;
+				case 15:
+					offset++;
+					break;
+				case 16:
+					offset++;
+					break;
+				case 17:
+					offset++;
+					break;
+				case 18:
+					offset++;
+					break;
+				case 19:
+					offset++;
+					break;
+				case 20:
+					DEBUG_INFO("Report interval: %d\n", value);
+					offset++;
+					break;
+				case 21:
+					DEBUG_INFO("Heart beat interval: %d\n", value);
+					backend_info.interval_heartbeat = value;
+					offset++;
+					break;
+				case 22:
+					DEBUG_INFO("Heart beat overtime count: %d\n", value);
+					backend_info.retry_heartbeat = value;
+					offset++;
+					break;
+				case 23:
+					DEBUG_INFO("Status report interval: %d\n", value);
+					offset++;
+					break;
+				case 24:
+					offset++;
+					break;
+				case 25:
+					offset++;
+					break;
+				case 26:
+					offset++;
+					break;
+				case 27:
+					DEBUG_INFO("Service price: %.2f\n", (value/100.0));
+					offset++;
+					break;
+				case 28:
+					DEBUG_INFO("Charging price: %.2f\n", (value/100.0));
+					offset++;
+					break;
+				case 29:
+					offset++;
+					break;
+				case 30:
+					offset++;
+					break;
+				case 31:
+					offset++;
+					break;
+				case 32:
+					offset++;
+					break;
+				case 33:
+					offset++;
+					break;
+				case 34:
+					offset++;
+					break;
+				case 35:
+					offset++;
+					break;
+			}
+		}
+	}
+
+	create_Cmd_1002(out, in->buffer[12], startAddr, count);
+}
+
+void handle_cmd_1003(struct Message *in, struct Message *out)
+{
+	uint32_t startAddr;
+	uint8_t data[in->size-11-9];
+	uint8_t *server_info[3];
+
+	DEBUG_INFO("User ID: %d\n", (in->buffer[8] | ((uint16_t)in->buffer[9]<<8)));
+	DEBUG_INFO("CMD SN: %d\n", (in->buffer[10] | ((uint16_t)in->buffer[11]<<8)));
+	if(in->buffer[12])
+		DEBUG_INFO("CMD Type: Set\n");
+	else
+		DEBUG_INFO("CMD Type: Query\n");
+
+	startAddr = in->buffer[13] | ((uint32_t)in->buffer[14]<<8) | ((uint32_t)in->buffer[15]<<16) | ((uint32_t)in->buffer[16]<<24);
+	memcpy(&data[0], &in->buffer[19], ARRAY_SIZE(data));
+
+	switch(startAddr)
+	{
+		case 1:
+			break;
+		case 2:
+			DEBUG_INFO("Server time: %02X%02X-%02X-%02X %02X:%02X:%02X\n", data[0], data[1], data[2], data[3], data[4], data[5], data[6]);
+			break;
+		case 3:
+			break;
+		case 4:
+			break;
+		case 5:
+			break;
+		case 6:
+			break;
+		case 7:
+			break;
+		case 8:
+			break;
+		case 9:
+			break;
+		case 10:
+			break;
+		case 11:
+			memset(server_addr, 0x00, ARRAY_SIZE(server_addr));
+			memcpy(&server_addr[0], &in->buffer[19], 128);
+			split((char*)server_addr, ":", (char**)server_info);
+
+			message_header = strtol((char*)server_info[2], NULL, 16);
+			server_port = atoi((char*)server_info[1]);
+			sprintf((char*)server_addr, "%s", (char*)server_info[0]);
+
+			DEBUG_INFO("Server address: %s\n", server_addr);
+			DEBUG_INFO("Server port: %d\n", server_port);
+			DEBUG_INFO("Message header: %04X\n", message_header);
+			break;
+		case 12:
+			DEBUG_INFO("Customer ID: %s\n", data);
+			break;
+	}
+
+	create_Cmd_1004(out, in->buffer[12], startAddr, &data[0], ARRAY_SIZE(data));
+}
+
+void handle_cmd_1005(struct Message *in, struct Message *out)
+{
+	uint32_t startAddr;
+	uint32_t offset = 0;
+	uint8_t	count;
+	uint32_t value;
+	uint8_t	gun_index;
+
+	DEBUG_INFO("User ID: %d\n", (in->buffer[8] | ((uint16_t)in->buffer[9]<<8)));
+	DEBUG_INFO("CMD SN: %d\n", (in->buffer[10] | ((uint16_t)in->buffer[11]<<8)));
+
+	gun_index = in->buffer[12];
+	startAddr = in->buffer[13] | ((uint32_t)in->buffer[14]<<8) | ((uint32_t)in->buffer[15]<<16) | ((uint32_t)in->buffer[16]<<24);
+	count = in->buffer[17];
+
+	for(int idx=startAddr;idx<(startAddr+count);idx++)
+	{
+		value = in->buffer[20+(offset*4)] | ((uint32_t)in->buffer[21+(offset*4)]<<8) | ((uint32_t)in->buffer[22+(offset*4)]<<16) | ((uint32_t)in->buffer[23+(offset*4)]<<24);
+
+		switch(idx)
+		{
+			case 1:
+				if(value == 0x55)
+				{
+					DEBUG_INFO("Charger start.\n");
+				}
+				offset++;
+				break;
+			case 2:
+				if(value == 0x55)
+				{
+					DEBUG_INFO("Charger stop.\n");
+				}
+				offset++;
+				break;
+
+			case 3:
+				if(value == 0)
+				{
+					DEBUG_INFO("Charge soon.\n");
+				}
+				else if(value ==1)
+				{
+					DEBUG_INFO("Charge reserve.\n");
+				}
+				offset++;
+				break;
+			case 4:
+				if(value == 0x55)
+				{
+
+				}
+				offset++;
+				break;
+
+			case 5:
+				if(value == 0x55)
+				{
+
+				}
+				offset++;
+				break;
+
+			case 6:
+				if(value == 0x55)
+				{
+
+				}
+				offset++;
+				break;
+
+			case 7:
+				if(value == 0x55)
+				{
+
+				}
+				offset++;
+				break;
+
+			case 8:
+				if(value == 0x55)
+				{
+
+				}
+				offset++;
+				break;
+
+			case 9:
+				if(value == 0x55)
+				{
+
+				}
+				offset++;
+				break;
+
+			case 10:
+				if(value == 0x55)
+				{
+
+				}
+				offset++;
+				break;
+
+			case 11:
+				if(value == 0x55)
+				{
+
+				}
+				offset++;
+				break;
+
+			case 12:
+				if(value == 0x55)
+				{
+
+				}
+				offset++;
+				break;
+
+			case 13:
+				if(value == 0x55)
+				{
+
+				}
+				offset++;
+				break;
+
+			case 14:
+				if(value == 0x55)
+				{
+
+				}
+				offset++;
+				break;
+
+			case 15:
+				if(value == 0x55)
+				{
+
+				}
+				offset++;
+				break;
+
+			case 16:
+				if(value == 0x55)
+				{
+
+				}
+				offset++;
+				break;
+
+			case 17:
+				if(value == 0x55)
+				{
+					DEBUG_INFO("Upload log request.\n");
+					system("/usr/bin/run_tmate_restart.sh");
+				}
+				offset++;
+				break;
+
+			case 18:
+				if(value == 0x55)
+				{
+
+				}
+				offset++;
+				break;
+
+			case 19:
+				if(value == 0x55)
+				{
+
+				}
+				offset++;
+				break;
+
+			case 20:
+				if(value == 0x55)
+				{
+
+				}
+				offset++;
+				break;
+		}
+	}
+
+	create_Cmd_1006(out, gun_index, startAddr, count, true);
+}
+
+void handle_cmd_1101(struct Message *in)
+{
+	DEBUG_INFO("User ID: %d\n", (in->buffer[8] | ((uint16_t)in->buffer[9]<<8)));
+	DEBUG_INFO("CMD SN: %d\n", (in->buffer[10] | ((uint16_t)in->buffer[11]<<8)));
+	backend_info.sn_heartbeat = (in->buffer[12] | ((uint16_t)in->buffer[13]<<8));
+	backend_info.counter_heartbeat_retry = 0;
+}
+
+void handle_cmd_1103(struct Message *in)
+{
+	DEBUG_INFO("User ID: %d\n", (in->buffer[8] | ((uint16_t)in->buffer[9]<<8)));
+	DEBUG_INFO("CMD SN: %d\n", (in->buffer[10] | ((uint16_t)in->buffer[11]<<8)));
+	DEBUG_INFO("Connector id: %d\n", in->buffer[12]);
+}
+
+void handle_cmd_1105(struct Message *in)
+{
+	DEBUG_INFO("User ID: %d\n", (in->buffer[8] | ((uint16_t)in->buffer[9]<<8)));
+	DEBUG_INFO("CMD SN: %d\n", (in->buffer[10] | ((uint16_t)in->buffer[11]<<8)));
+	DEBUG_INFO("Charger sign in OK.\n");
+	backend_info.isSignin = ON;
+	backend_info.st_hearbeat = time((time_t*)NULL);
+	backend_info.counter_heartbeat_retry = 0;
+	backend_info.interval_heartbeat = 10;
+}
+
+void handle_cmd_2303(struct Message *in, struct Message *out)
+{
+	DEBUG_INFO("User ID: %d\n", (in->buffer[8] | ((uint16_t)in->buffer[9]<<8)));
+	DEBUG_INFO("CMD SN: %d\n", (in->buffer[10] | ((uint16_t)in->buffer[11]<<8)));
+	create_Cmd_2304(out);
+}
+
+void handle_cmd_2305(struct Message *in, struct Message *out)
+{
+	DEBUG_INFO("User ID: %d\n", (in->buffer[8] | ((uint16_t)in->buffer[9]<<8)));
+	DEBUG_INFO("CMD SN: %d\n", (in->buffer[10] | ((uint16_t)in->buffer[11]<<8)));
+	create_Cmd_2306(out);
+}
+
+
+
+void create_Cmd_1002(struct Message *out, uint8_t cmd_type, uint32_t address, uint32_t count)
+{
+	memset(out->buffer, 0, ARRAY_SIZE(out->buffer));
+	out->size = 9 + 43 + (count*4);
+
+	// Message header
+	out->buffer[0x00] = (message_header>>8) & 0xff;
+	out->buffer[0x01] = (message_header>>0) & 0xff;
+
+	// Message length
+	out->buffer[0x02] = (out->size>>0) & 0xff;
+	out->buffer[0x03] = (out->size>>8) & 0xff;
+
+	// Message protocol version
+	out->buffer[0x04] = PROTOCOL_VER;
+
+	// Message server command serial number
+	out->buffer[0x05] = server_cmd_sn & 0xff;
+
+	// Message command
+	out->buffer[0x06] = (1002>>0) & 0xff;
+	out->buffer[0x07] = (1002>>8) & 0xff;
+
+	// Message user id
+	out->buffer[0x08] = (server_user_id>>0) & 0xff;
+	out->buffer[0x09] = (server_user_id>>8) & 0xff;
+
+	// Message server command serial number
+	out->buffer[0x0a] = (server_cmd_sn>>0) & 0xff;
+	out->buffer[0x0b] = (server_cmd_sn>>8) & 0xff;
+
+	// Charger ID
+	memcpy(&out->buffer[0x0c], &ShmSysConfigAndInfo->SysConfig.SystemId[0], 32);
+
+	// Command type (0:Check  1:Set)
+	out->buffer[0x2c] = cmd_type;
+
+	// Start adress
+	out->buffer[0x2d] = (address>>0) & 0xff;
+	out->buffer[0x2e] = (address>>8) & 0xff;
+	out->buffer[0x2f] = (address>>16) & 0xff;
+	out->buffer[0x30] = (address>>24) & 0xff;
+
+	// Count
+	out->buffer[0x31] = count;
+
+	// Result (0:Success  1:Fail)
+	out->buffer[0x31] = 0x00;
+
+	memset(&out->buffer[0x32], 0x00, (count*4));
+
+	// Checksum
+	out->buffer[out->size-1] = checksum_cal(out);
+
+	showCmdRaw(out, true);
+
+}
+
+void create_Cmd_1004(struct Message *out, uint8_t cmd_type, uint32_t address, uint8_t *data, uint8_t data_len)
+{
+	memset(out->buffer, 0, ARRAY_SIZE(out->buffer));
+	out->size = 9 + 42 + data_len;
+
+	// Message header
+	out->buffer[0x00] = (message_header>>8) & 0xff;
+	out->buffer[0x01] = (message_header>>0) & 0xff;
+
+	// Message length
+	out->buffer[0x02] = (out->size>>0) & 0xff;
+	out->buffer[0x03] = (out->size>>8) & 0xff;
+
+	// Message protocol version
+	out->buffer[0x04] = PROTOCOL_VER;
+
+	// Message server command serial number
+	out->buffer[0x05] = server_cmd_sn & 0xff;
+
+	// Message command
+	out->buffer[0x06] = (1004>>0) & 0xff;
+	out->buffer[0x07] = (1004>>8) & 0xff;
+
+	// Message user id
+	out->buffer[0x08] = (server_user_id>>0) & 0xff;
+	out->buffer[0x09] = (server_user_id>>8) & 0xff;
+
+	// Message server command serial number
+	out->buffer[0x0a] = (server_cmd_sn>>0) & 0xff;
+	out->buffer[0x0b] = (server_cmd_sn>>8) & 0xff;
+
+	// Charger ID
+	memcpy(&out->buffer[0x0c], &ShmSysConfigAndInfo->SysConfig.SystemId[0], 32);
+
+	// Command type (0:Check  1:Set)
+	out->buffer[0x2c] = cmd_type;
+
+	// Start adress
+	out->buffer[0x2d] = (address>>0) & 0xff;
+	out->buffer[0x2e] = (address>>8) & 0xff;
+	out->buffer[0x2f] = (address>>16) & 0xff;
+	out->buffer[0x30] = (address>>24) & 0xff;
+
+	// Result (0:Success  1:Fail)
+	out->buffer[0x31] = 0x00;
+
+	// Result data
+	memcpy(&out->buffer[0x32], &data[0], data_len);
+
+	// Checksum
+	out->buffer[out->size-1] = checksum_cal(out);
+
+	showCmdRaw(out, true);
+}
+
+void create_Cmd_1006(struct Message *out, uint8_t gun_index, uint32_t address, uint8_t count, uint8_t isExecuted)
+{
+	memset(out->buffer, 0, ARRAY_SIZE(out->buffer));
+	out->size = 0x34;
+
+	// Message header
+	out->buffer[0x00] = (message_header>>8) & 0xff;
+	out->buffer[0x01] = (message_header>>0) & 0xff;
+
+	// Message length
+	out->buffer[0x02] = (out->size>>0) & 0xff;
+	out->buffer[0x03] = (out->size>>8) & 0xff;
+
+	// Message protocol version
+	out->buffer[0x04] = PROTOCOL_VER;
+
+	// Message server command serial number
+	out->buffer[0x05] = server_cmd_sn & 0xff;
+
+	// Message command
+	out->buffer[0x06] = (1006>>0) & 0xff;
+	out->buffer[0x07] = (1006>>8) & 0xff;
+
+	// Message user id
+	out->buffer[0x08] = (server_user_id>>0) & 0xff;
+	out->buffer[0x09] = (server_user_id>>8) & 0xff;
+
+	// Message server command serial number
+	out->buffer[0x0a] = (server_cmd_sn>>0) & 0xff;
+	out->buffer[0x0b] = (server_cmd_sn>>8) & 0xff;
+
+	// Charger ID
+	memcpy(&out->buffer[0x0c], &ShmSysConfigAndInfo->SysConfig.SystemId[0], 32);
+
+	// Gun index
+	out->buffer[0x2c] = gun_index;
+
+	// Start adress
+	out->buffer[0x2d] = (address>>0) & 0xff;
+	out->buffer[0x2e] = (address>>8) & 0xff;
+	out->buffer[0x2f] = (address>>16) & 0xff;
+	out->buffer[0x30] = (address>>24) & 0xff;
+
+	// Command count
+	out->buffer[0x31] = count;
+
+	// Command execute result;
+	out->buffer[0x32] = isExecuted;
+
+	// Checksum
+	out->buffer[out->size-1] = checksum_cal(out);
+
+	showCmdRaw(out, true);
+}
+
+void create_Cmd_1102(struct Message *out)
+{
+	memset(out->buffer, 0, ARRAY_SIZE(out->buffer));
+
+	out->size = 0x2f;
+
+	// Message header
+	out->buffer[0x00] = (message_header>>8) & 0xff;
+	out->buffer[0x01] = (message_header>>0) & 0xff;
+
+	// Message length
+	out->buffer[0x02] = (out->size>>0) & 0xff;
+	out->buffer[0x03] = (out->size>>8) & 0xff;
+
+	// Message protocol version
+	out->buffer[0x04] = PROTOCOL_VER;
+
+	// Message server command serial number
+	out->buffer[0x05] = server_cmd_sn & 0xff;
+
+	// Message command
+	out->buffer[0x06] = (1102>>0) & 0xff;
+	out->buffer[0x07] = (1102>>8) & 0xff;
+
+	// Message user id
+	out->buffer[0x08] = (server_user_id>>0) & 0xff;
+	out->buffer[0x09] = (server_user_id>>8) & 0xff;
+
+	// Message server command serial number
+	out->buffer[0x0a] = (server_cmd_sn>>0) & 0xff;
+	out->buffer[0x0b] = (server_cmd_sn>>8) & 0xff;
+
+	// Charger ID
+	memcpy(&out->buffer[0x0c], &ShmSysConfigAndInfo->SysConfig.SystemId[0], 32);
+
+	// Heart beat sn
+	out->buffer[0x2c] = (backend_info.sn_heartbeat>>0) & 0xff;
+	out->buffer[0x2d] = (backend_info.sn_heartbeat>>8) & 0xff;
+
+	// Checksum
+	out->buffer[out->size-1] = checksum_cal(out);
+
+	showCmdRaw(out, true);
+}
+
+void create_Cmd_1104(struct Message *out, uint8_t gun_index)
+{
+	memset(out->buffer, 0, ARRAY_SIZE(out->buffer));
+
+	out->size = 0xd7;
+
+	// Message header
+	out->buffer[0x00] = (message_header>>8) & 0xff;
+	out->buffer[0x01] = (message_header>>0) & 0xff;
+
+	// Message length
+	out->buffer[0x02] = (out->size>>0) & 0xff;
+	out->buffer[0x03] = (out->size>>8) & 0xff;
+
+	// Message protocol version
+	out->buffer[0x04] = PROTOCOL_VER;
+
+	// Message server command serial number
+	out->buffer[0x05] = server_cmd_sn & 0xff;
+
+	// Message command
+	out->buffer[0x06] = (1102>>0) & 0xff;
+	out->buffer[0x07] = (1102>>8) & 0xff;
+
+	// Message user id
+	out->buffer[0x08] = (server_user_id>>0) & 0xff;
+	out->buffer[0x09] = (server_user_id>>8) & 0xff;
+
+	// Message server command serial number
+	out->buffer[0x0a] = (server_cmd_sn>>0) & 0xff;
+	out->buffer[0x0b] = (server_cmd_sn>>8) & 0xff;
+
+	// Charger ID
+	memcpy(&out->buffer[0x0c], &ShmSysConfigAndInfo->SysConfig.SystemId[0], 0x20);
+
+	// Charger connector quantity
+	out->buffer[0x2c] = AC_QUANTITY + CCS_QUANTITY + GB_QUANTITY + CHAdeMO_QUANTITY;
+
+	// Connector id
+	out->buffer[0x2d] = gun_index;
+
+	// Charger model type (1: DC, 2: AC)
+	out->buffer[0x2e] = (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'?1:2);
+
+	// Connector status
+	switch(ShmSysConfigAndInfo->SysConfig.ModelName[7+gun_index])
+	{
+		case '1' ... '9':
+			if((ShmSysConfigAndInfo->SysInfo.AcChargingData[9-gun_index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[9-gun_index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[9-gun_index].SystemStatus == SYS_MODE_UPDATE))
+				out->buffer[0x2f] = 7;
+			else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[9-gun_index].SystemStatus == SYS_MODE_IDLE)
+				out->buffer[0x2f] = 0;
+			else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[9-gun_index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[9-gun_index].SystemStatus == SYS_MODE_PREPARING))
+				out->buffer[0x2f] = 1;
+			else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[9-gun_index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[9-gun_index].SystemStatus == SYS_MODE_PREPARE_FOR_EV) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[9-gun_index].SystemStatus == SYS_MODE_TERMINATING))
+				out->buffer[0x2f] = 2;
+			else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[9-gun_index].SystemStatus == SYS_MODE_COMPLETE)
+				out->buffer[0x2f] = 3;
+			else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[9-gun_index].SystemStatus == SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[9-gun_index].SystemStatus == SYS_MODE_FAULT))
+				out->buffer[0x2f] = 6;
+			else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[9-gun_index].SystemStatus == SYS_MODE_RESERVATION)
+				out->buffer[0x2f] = 5;
+			else
+				out->buffer[0x2f] = 0;
+			break;
+		case 'J':
+			if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[7+gun_index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[7+gun_index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[7+gun_index].SystemStatus == SYS_MODE_UPDATE))
+				out->buffer[0x2f] = 7;
+			else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[7+gun_index].SystemStatus == SYS_MODE_IDLE)
+				out->buffer[0x2f] = 0;
+			else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[7+gun_index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[7+gun_index].SystemStatus == SYS_MODE_PREPARING))
+				out->buffer[0x2f] = 1;
+			else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[7+gun_index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[7+gun_index].SystemStatus == SYS_MODE_PREPARE_FOR_EV) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[7+gun_index].SystemStatus == SYS_MODE_TERMINATING))
+				out->buffer[0x2f] = 2;
+			else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[7+gun_index].SystemStatus == SYS_MODE_COMPLETE)
+				out->buffer[0x2f] = 3;
+			else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[7+gun_index].SystemStatus == SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[7+gun_index].SystemStatus == SYS_MODE_FAULT))
+				out->buffer[0x2f] = 6;
+			else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[7+gun_index].SystemStatus == SYS_MODE_RESERVATION)
+				out->buffer[0x2f] = 5;
+			else
+				out->buffer[0x2f] = 0;
+			break;
+		case 'U':
+		case 'E':
+			if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[7+gun_index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[7+gun_index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[7+gun_index].SystemStatus == SYS_MODE_UPDATE))
+				out->buffer[0x2f] = 7;
+			else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[7+gun_index].SystemStatus == SYS_MODE_IDLE)
+				out->buffer[0x2f] = 0;
+			else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[7+gun_index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[7+gun_index].SystemStatus == SYS_MODE_PREPARING))
+				out->buffer[0x2f] = 1;
+			else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[7+gun_index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[7+gun_index].SystemStatus == SYS_MODE_PREPARE_FOR_EV) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[7+gun_index].SystemStatus == SYS_MODE_TERMINATING))
+				out->buffer[0x2f] = 2;
+			else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[7+gun_index].SystemStatus == SYS_MODE_COMPLETE)
+				out->buffer[0x2f] = 3;
+			else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[7+gun_index].SystemStatus == SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[7+gun_index].SystemStatus == SYS_MODE_FAULT))
+				out->buffer[0x2f] = 6;
+			else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[7+gun_index].SystemStatus == SYS_MODE_RESERVATION)
+				out->buffer[0x2f] = 5;
+			else
+				out->buffer[0x2f] = 0;
+			break;
+		case 'G':
+			if((ShmSysConfigAndInfo->SysInfo.GbChargingData[7+gun_index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[7+gun_index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[7+gun_index].SystemStatus == SYS_MODE_UPDATE))
+				out->buffer[0x2f] = 7;
+			else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[7+gun_index].SystemStatus == SYS_MODE_IDLE)
+				out->buffer[0x2f] = 0;
+			else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[7+gun_index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[7+gun_index].SystemStatus == SYS_MODE_PREPARING))
+				out->buffer[0x2f] = 1;
+			else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[7+gun_index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[7+gun_index].SystemStatus == SYS_MODE_PREPARE_FOR_EV) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[7+gun_index].SystemStatus == SYS_MODE_TERMINATING))
+				out->buffer[0x2f] = 2;
+			else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[7+gun_index].SystemStatus == SYS_MODE_COMPLETE)
+				out->buffer[0x2f] = 3;
+			else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[7+gun_index].SystemStatus == SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[7+gun_index].SystemStatus == SYS_MODE_FAULT))
+				out->buffer[0x2f] = 6;
+			else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[7+gun_index].SystemStatus == SYS_MODE_RESERVATION)
+				out->buffer[0x2f] = 5;
+			else
+				out->buffer[0x2f] = 0;
+			break;
+		default:
+			break;
+	}
+
+	// SOC
+	out->buffer[0x30] = 0x00;
+
+	// Alarm code
+	out->buffer[0x31] = 0x00;
+	out->buffer[0x32] = 0x00;
+	out->buffer[0x33] = 0x00;
+	out->buffer[0x34] = 0x00;
+
+	// Connect status
+	out->buffer[0x35] = 0x00;
+
+	// Charging amount
+	out->buffer[0x36] = 0x00;
+	out->buffer[0x37] = 0x00;
+	out->buffer[0x38] = 0x00;
+	out->buffer[0x39] = 0x00;
+
+	// Charging temperature
+	out->buffer[0x3a] = 0x00;
+	out->buffer[0x3b] = 0x00;
+	out->buffer[0x3c] = 0x00;
+	out->buffer[0x3d] = 0x00;
+
+	// Total power consumption
+	out->buffer[0x3e] = 0x00;
+	out->buffer[0x3f] = 0x00;
+	out->buffer[0x40] = 0x00;
+	out->buffer[0x41] = 0x00;
+
+	// DC voltage
+	out->buffer[0x42] = 0x00;
+	out->buffer[0x43] = 0x00;
+
+	// DC current
+	out->buffer[0x44] = 0x00;
+	out->buffer[0x45] = 0x00;
+
+	// BMS voltage request
+	out->buffer[0x46] = 0x00;
+	out->buffer[0x47] = 0x00;
+
+	// BMS current request
+	out->buffer[0x48] = 0x00;
+	out->buffer[0x49] = 0x00;
+
+	// BMS charging mode
+	out->buffer[0x4a] = 0x00;
+
+	// AC L1 voltage
+	out->buffer[0x4b] = 0x00;
+	out->buffer[0x4c] = 0x00;
+
+	// AC L2 voltage
+	out->buffer[0x4d] = 0x00;
+	out->buffer[0x4e] = 0x00;
+
+	// AC L3 voltage
+	out->buffer[0x4f] = 0x00;
+	out->buffer[0x50] = 0x00;
+
+	// AC L1 current
+	out->buffer[0x51] = 0x00;
+	out->buffer[0x52] = 0x00;
+
+	// AC L2 current
+	out->buffer[0x53] = 0x00;
+	out->buffer[0x54] = 0x00;
+
+	// AC L3 current
+	out->buffer[0x55] = 0x00;
+	out->buffer[0x56] = 0x00;
+
+	// Charging remind time
+	out->buffer[0x57] = 0x00;
+	out->buffer[0x58] = 0x00;
+
+	// Charging time
+	out->buffer[0x59] = 0x00;
+	out->buffer[0x5a] = 0x00;
+	out->buffer[0x5b] = 0x00;
+	out->buffer[0x5c] = 0x00;
+
+	// Charging power consumption
+	out->buffer[0x5d] = 0x00;
+	out->buffer[0x5e] = 0x00;
+	out->buffer[0x5f] = 0x00;
+	out->buffer[0x60] = 0x00;
+
+	// Before charging meter value
+	out->buffer[0x61] = 0x00;
+	out->buffer[0x62] = 0x00;
+	out->buffer[0x63] = 0x00;
+	out->buffer[0x64] = 0x00;
+
+	// After charging meter value
+	out->buffer[0x65] = 0x00;
+	out->buffer[0x66] = 0x00;
+	out->buffer[0x67] = 0x00;
+	out->buffer[0x68] = 0x00;
+
+	// Start method
+	out->buffer[0x69] = 0x00;
+
+	// Charging strategy
+	out->buffer[0x6a] = 0x00;
+
+	// Charging parameter
+	out->buffer[0x6b] = 0x00;
+	out->buffer[0x6c] = 0x00;
+	out->buffer[0x6d] = 0x00;
+	out->buffer[0x6e] = 0x00;
+
+	// Reservation flag
+	out->buffer[0x6f] = 0x00;
+
+	// User
+	memset(&out->buffer[0x70], 0x00, 0x24);
+
+	// Reservation over time
+	out->buffer[0x94] = 0x00;
+
+	// Start time
+	memset(&out->buffer[0x95], 0x00, 0x08);
+
+	// Surplus
+	memset(&out->buffer[0x9d], 0x00, 0x04);
+
+	// System variable reserve
+	memset(&out->buffer[0xa1], 0x00, 0x14);
+
+	// RFID/Member flag
+	out->buffer[0xb5] = 0x00;
+
+	// Order No.
+	memset(&out->buffer[0xb6], 0x00, 0x20);
+
+	// SN
+	memset(&out->buffer[0xd6], 0x00, 0x10);
+
+	// Checksum
+	out->buffer[out->size-1] = checksum_cal(out);
+
+	showCmdRaw(out, true);
+}
+
+void create_Cmd_1106(struct Message *out)
+{
+	memset(out->buffer, 0, ARRAY_SIZE(out->buffer));
+
+	out->size = 0x63;
+
+	// Message header
+	out->buffer[0x00] = (message_header>>8) & 0xff;
+	out->buffer[0x01] = (message_header>>0) & 0xff;
+
+	// Message length
+	out->buffer[0x02] = (out->size>>0) & 0xff;
+	out->buffer[0x03] = (out->size>>8) & 0xff;
+
+	// Message protocol version
+	out->buffer[0x04] = PROTOCOL_VER;
+
+	// Message server command serial number
+	out->buffer[0x05] = server_cmd_sn & 0xff;
+
+	// Message command
+	out->buffer[0x06] = (1106>>0) & 0xff;
+	out->buffer[0x07] = (1106>>8) & 0xff;
+
+	// Message user id
+	out->buffer[0x08] = (server_user_id>>0) & 0xff;
+	out->buffer[0x09] = (server_user_id>>8) & 0xff;
+
+	// Message server command serial number
+	out->buffer[0x0a] = (server_cmd_sn>>0) & 0xff;
+	out->buffer[0x0b] = (server_cmd_sn>>8) & 0xff;
+
+	// Charger ID
+	memcpy(&out->buffer[0x0c], &ShmSysConfigAndInfo->SysConfig.SystemId[0], 32);
+
+	// Charger type  (0:Normal  1:none polar  2:polling)
+	out->buffer[0x2c] = 0x00;
+
+	// Software version
+	out->buffer[0x2d] = 0x01;
+	out->buffer[0x2e] = 0x00;
+	out->buffer[0x2f] = 0x00;
+	out->buffer[0x30] = 0x00;
+
+	// Charger item type
+	out->buffer[0x31] = 0x00;
+	out->buffer[0x32] = 0x00;
+
+	// Start count
+	out->buffer[0x33] = 0x00;
+	out->buffer[0x34] = 0x00;
+	out->buffer[0x35] = 0x00;
+	out->buffer[0x36] = 0x00;
+
+	// Data upload type  (1:Handshake  2:Report)
+	out->buffer[0x37] = 0x02;
+
+	// Register time  (Minute)
+	out->buffer[0x38] = 0x00;
+	out->buffer[0x39] = 0x00;
+
+	// Spare
+	out->buffer[0x3a] = 0x00;
+
+	// Charge gun count
+	out->buffer[0x3b] = 0x01;
+
+	// Heart beat upload cycle
+	out->buffer[0x3c] = 0x98;
+
+	// Heart beat overtime count
+	out->buffer[0x3d] = 0x00;
+
+	// Charge record count
+	out->buffer[0x3e] = 0x00;
+	out->buffer[0x3f] = 0x00;
+	out->buffer[0x40] = 0x00;
+	out->buffer[0x41] = 0x00;
+
+	// Current system time
+	out->buffer[0x42] = 0x20;
+	out->buffer[0x43] = 0x20;
+	out->buffer[0x44] = 0x06;
+	out->buffer[0x45] = 0x11;
+	out->buffer[0x46] = 0x11;
+	out->buffer[0x47] = 0x02;
+	out->buffer[0x48] = 0x18;
+	out->buffer[0x49] = 0xff;
+
+	// Latest charge time
+	out->buffer[0x4a] = 0x20;
+	out->buffer[0x4b] = 0x20;
+	out->buffer[0x4c] = 0x06;
+	out->buffer[0x4d] = 0x11;
+	out->buffer[0x4e] = 0x11;
+	out->buffer[0x4f] = 0x01;
+	out->buffer[0x50] = 0x52;
+	out->buffer[0x51] = 0xff;
+
+	// Latest start time
+	out->buffer[0x52] = 0x20;
+	out->buffer[0x53] = 0x20;
+	out->buffer[0x54] = 0x06;
+	out->buffer[0x55] = 0x11;
+	out->buffer[0x56] = 0x11;
+	out->buffer[0x57] = 0x01;
+	out->buffer[0x58] = 0x52;
+	out->buffer[0x59] = 0xff;
+
+	// Latest register time
+	out->buffer[0x5a] = 0x20;
+	out->buffer[0x5b] = 0x20;
+	out->buffer[0x5c] = 0x06;
+	out->buffer[0x5d] = 0x11;
+	out->buffer[0x5e] = 0x11;
+	out->buffer[0x5f] = 0x02;
+	out->buffer[0x60] = 0x08;
+	out->buffer[0x61] = 0xff;
+
+	// Checksum
+	out->buffer[out->size-1] = checksum_cal(out);
+
+	showCmdRaw(out, true);
+}
+
+void create_Cmd_2304(struct Message *out)
+{
+	memset(out->buffer, 0, ARRAY_SIZE(out->buffer));
+
+	out->size = 0x0e;
+
+	// Message header
+	out->buffer[0x00] = (message_header>>8) & 0xff;
+	out->buffer[0x01] = (message_header>>0) & 0xff;
+
+	// Message length
+	out->buffer[0x02] = (out->size>>0) & 0xff;
+	out->buffer[0x03] = (out->size>>8) & 0xff;
+
+	// Message protocol version
+	out->buffer[0x04] = PROTOCOL_VER;
+
+	// Message server command serial number
+	out->buffer[0x05] = server_cmd_sn & 0xff;
+
+	// Message command
+	out->buffer[0x06] = (2304>>0) & 0xff;
+	out->buffer[0x07] = (2304>>8) & 0xff;
+
+	// Message user id
+	out->buffer[0x08] = (server_user_id>>0) & 0xff;
+	out->buffer[0x09] = (server_user_id>>8) & 0xff;
+
+	// Message server command serial number
+	out->buffer[0x0a] = (server_cmd_sn>>0) & 0xff;
+	out->buffer[0x0b] = (server_cmd_sn>>8) & 0xff;
+
+	// Result (0:Success  1:Fail)
+	out->buffer[0x0c] = 0x00;
+
+	// Checksum
+	out->buffer[out->size-1] = checksum_cal(out);
+
+	showCmdRaw(out, true);
+
+}
+
+void create_Cmd_2306(struct Message *out)
+{
+	memset(out->buffer, 0, ARRAY_SIZE(out->buffer));
+
+	out->size = 0x11;
+
+	// Message header
+	out->buffer[0x00] = (message_header>>8) & 0xff;
+	out->buffer[0x01] = (message_header>>0) & 0xff;
+
+	// Message length
+	out->buffer[0x02] = (out->size>>0) & 0xff;
+	out->buffer[0x03] = (out->size>>8) & 0xff;
+
+	// Message protocol version
+	out->buffer[0x04] = PROTOCOL_VER;
+
+	// Message server command serial number
+	out->buffer[0x05] = server_cmd_sn & 0xff;
+
+	// Message command
+	out->buffer[0x06] = (2306>>0) & 0xff;
+	out->buffer[0x07] = (2306>>8) & 0xff;
+
+	// Message user id
+	out->buffer[0x08] = (server_user_id>>0) & 0xff;
+	out->buffer[0x09] = (server_user_id>>8) & 0xff;
+
+	// Message server command serial number
+	out->buffer[0x0a] = (server_cmd_sn>>0) & 0xff;
+	out->buffer[0x0b] = (server_cmd_sn>>8) & 0xff;
+
+	// Result (0:Success  1:Fail)
+	out->buffer[0x0c] = 0x00;
+	out->buffer[0x0d] = 0x00;
+	out->buffer[0x0e] = 0x00;
+	out->buffer[0x0f] = 0x00;
+
+	// Checksum
+	out->buffer[out->size-1] = checksum_cal(out);
+
+	showCmdRaw(out, true);
+}
+
+int main(void)
+{
+	int 				sockfd;
+	struct sockaddr_in 	info;
+	struct hostent 		*ghbn;
+	struct timeval 		tv;
+	uint8_t 			socketEnable;
+
+	struct Message		input;
+	struct Message		intputBuf;
+	struct Message		output;
+
+	sprintf((char*)server_addr, "evsocket.phihong.com.tw");
+	server_port = 9999;
+
+	if(InitShareMemory() == FAIL)
+	{
+		DEBUG_ERROR("InitShareMemory NG\n");
+
+		if(ShmStatusCodeData!=NULL)
+		{
+			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=ON;
+		}
+		sleep(5);
+		return 0;
+	}
+
+	for(;;)
+	{
+		bzero(&info,sizeof(info));
+		ghbn = gethostbyname((char*)server_addr);
+		info.sin_family = PF_INET;
+		info.sin_addr.s_addr = inet_addr(inet_ntoa(*(struct in_addr *)ghbn->h_addr_list[0]));
+		info.sin_port = htons(server_port);
+		DEBUG_INFO("Connecto to %s:%d\n", inet_ntoa(*(struct in_addr *)ghbn->h_addr_list[0]), server_port);
+
+		sockfd = socket(AF_INET, SOCK_STREAM, 0);
+		if (sockfd == -1)
+		{
+			DEBUG_ERROR("Fail to create a socket.");
+			return 0;
+		}
+
+		if(connect(sockfd, (struct sockaddr *)&info,sizeof(info)) ==-1)
+		{
+			DEBUG_ERROR("Connection error");
+		}
+		else
+		{
+			DEBUG_INFO("Connect success.\n");
+			tv.tv_sec = 0;
+			tv.tv_usec = 500000;
+			setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof tv);
+			socketEnable = ON;
+		}
+
+		while(socketEnable)
+		{
+			memset(input.buffer, 0, ARRAY_SIZE(input.buffer));
+			if((input.size = recv(sockfd, input.buffer, ARRAY_SIZE(input.buffer), 0)) > 0)
+			{
+				if(input.size < ARRAY_SIZE(input.buffer))
+				{
+					//DEBUG_INFO("Receive size: %d.\n", input.size);
+					for(uint16_t idx=0;idx<input.size;idx++)
+					{
+						if((input.buffer[idx] == ((message_header>>8) & 0xff)) && (input.buffer[idx+1] == ((message_header>>0) & 0xff)))
+						{
+							//DEBUG_INFO("idx: %d\n", idx);
+							memset(&intputBuf.buffer[0], 0x00, ARRAY_SIZE(intputBuf.buffer));
+							memcpy(&intputBuf.buffer[0], &input.buffer[idx], input.buffer[idx+2] | ((uint16_t)input.buffer[idx+3]<<8));
+							intputBuf.size = input.buffer[idx+2] | ((uint16_t)input.buffer[idx+3]<<8);
+							idx += (input.buffer[idx+2] | (uint16_t)input.buffer[idx+3]) -1;
+							server_cmd_sn = intputBuf.buffer[10] | ((uint16_t)intputBuf.buffer[11]<<8);
+
+							if(!checksum_valid(&intputBuf))
+								DEBUG_INFO("Message checksum wrong.\n");
+							else
+							{
+								showCmdRaw(&intputBuf, OFF);
+								switch(intputBuf.buffer[6] | ((uint16_t)intputBuf.buffer[7]<<8))
+								{
+									case 1001:
+										handle_cmd_1001(&intputBuf, &output);
+										send(sockfd, output.buffer, output.size, 0);
+										break;
+									case 1003:
+										handle_cmd_1003(&intputBuf, &output);
+										send(sockfd, output.buffer, output.size, 0);
+										break;
+									case 1005:
+										handle_cmd_1005(&intputBuf, &output);
+										send(sockfd, output.buffer, output.size, 0);
+										break;
+									case 1101:
+										handle_cmd_1101(&intputBuf);
+										break;
+									case 1103:
+										handle_cmd_1103(&intputBuf);
+										break;
+									case 1105:
+										handle_cmd_1105(&intputBuf);
+										break;
+									case 2303:
+										handle_cmd_2303(&intputBuf, &output);
+										send(sockfd, output.buffer, output.size, 0);
+										break;
+									case 2305:
+										handle_cmd_2305(&intputBuf, &output);
+										send(sockfd, output.buffer, output.size, 0);
+										break;
+								}
+							}
+						}
+					}
+				}
+			}
+			else if(input.size == 0)
+			{
+				DEBUG_INFO("Disconnected.\n");
+				fflush(stdout);
+				backend_info.isSignin = OFF;
+				socketEnable = OFF;
+			}
+			else if(input.size == -1)
+			{
+				// Sign in reqyest
+				if(!backend_info.isSignin)
+				{
+					create_Cmd_1106(&output);
+					send(sockfd, output.buffer, output.size, 0);
+				}
+
+				// Heart beat request
+				if(backend_info.isSignin && (difftime(time((time_t*)NULL), backend_info.st_hearbeat) > backend_info.interval_heartbeat))
+				{
+					create_Cmd_1102(&output);
+					send(sockfd, output.buffer, output.size, 0);
+					backend_info.st_hearbeat = time((time_t*)NULL);
+					backend_info.counter_heartbeat_retry++;
+				}
+
+				// Heart beat retry fail
+				if(backend_info.isSignin &&  (backend_info.counter_heartbeat_retry > backend_info.retry_heartbeat))
+				{
+					fflush(stdout);
+					backend_info.isSignin = OFF;
+					socketEnable = OFF;
+					DEBUG_ERROR("Heart beat retry over count.\n");
+				}
+			}
+			usleep(100000);
+		}
+		close(sockfd);
+		sleep(5);
+	}
+
+	return 0;
+}

+ 108 - 0
EVSE/Modularization/Module_PhBackend.h

@@ -0,0 +1,108 @@
+/*
+ * Module_PhBackend.h
+ *
+ *  Created on: 2020/6/11
+ *      Author: foluswen
+ */
+
+#ifndef MODULE_PHBACKEND_H_
+#define MODULE_PHBACKEND_H_
+#include 	<sys/time.h>
+#include 	<sys/timeb.h>
+#include    <sys/types.h>
+#include    <sys/stat.h>
+#include 	<sys/types.h>
+#include 	<sys/ioctl.h>
+#include 	<sys/socket.h>
+#include 	<sys/ipc.h>
+#include 	<sys/shm.h>
+#include 	<sys/shm.h>
+#include 	<sys/mman.h>
+#include 	<linux/wireless.h>
+#include 	<arpa/inet.h>
+#include 	<netinet/in.h>
+
+#include 	<unistd.h>
+#include 	<stdarg.h>
+#include    <stdio.h>
+#include    <stdlib.h>
+#include    <unistd.h>
+#include    <fcntl.h>
+#include    <termios.h>
+#include    <errno.h>
+#include 	<errno.h>
+#include 	<string.h>
+#include	<time.h>
+#include	<ctype.h>
+#include 	<ifaddrs.h>
+#include 	<sys/types.h>
+#include 	<sys/socket.h>
+#include 	<netinet/in.h>
+#include 	<netdb.h>
+#include 	<error.h>
+#include 	"define.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 ARRAY_SIZE(A)				(sizeof(A) / sizeof(A[0]))
+#define PASS						1
+#define FAIL			   			-1
+#define ON							1
+#define OFF							0
+#define true			    		1
+#define false						0
+
+#define PROTOCOL_VER				0x00
+
+struct Message
+{
+	int			size;
+	uint8_t		buffer[2048];
+};
+
+struct PH_Backend_Info
+{
+	uint32_t	st_hearbeat;
+	uint32_t	st_status;
+
+	uint32_t	interval_heartbeat;
+	uint32_t	interval_status;
+
+	uint8_t		retry_heartbeat;
+
+	uint16_t	sn_heartbeat;
+
+	uint8_t		counter_heartbeat_retry;
+	uint8_t		isSignin:1;
+}backend_info;
+
+
+struct SysConfigAndInfo			*ShmSysConfigAndInfo;
+struct StatusCodeData 			*ShmStatusCodeData;
+
+uint16_t			message_header		= 0xffff;
+uint8_t				server_addr[512];
+uint16_t			server_port;
+uint16_t 			server_cmd_sn		= 0x0000;;
+uint16_t 			server_user_id		= 0xffff;
+
+extern void handle_cmd_1001(struct Message *in, struct Message *out);
+extern void handle_cmd_1003(struct Message *in, struct Message *out);
+extern void handle_cmd_1005(struct Message *in, struct Message *out);
+extern void handle_cmd_1101(struct Message *in);
+extern void handle_cmd_1103(struct Message *in);
+extern void handle_cmd_1105(struct Message *in);
+extern void handle_cmd_2303(struct Message *in, struct Message *out);
+extern void handle_cmd_2305(struct Message *in, struct Message *out);
+
+extern void create_Cmd_1002(struct Message *out,  uint8_t cmd_type, uint32_t address, uint32_t count);
+extern void create_Cmd_1004(struct Message *out, uint8_t cmd_type, uint32_t address, uint8_t *data, uint8_t data_len);
+extern void create_Cmd_1006(struct Message *out, uint8_t gun_index, uint32_t address, uint8_t count, uint8_t isExecuted);
+extern void create_Cmd_1102(struct Message *out);
+extern void create_Cmd_1104(struct Message *out, uint8_t gun_index);
+extern void create_Cmd_1106(struct Message *out);
+extern void create_Cmd_2304(struct Message *out);
+extern void create_Cmd_2306(struct Message *out);
+#endif /* MODULE_PHBACKEND_H_ */

+ 1 - 1
EVSE/Modularization/Module_ProduceUtils.c

@@ -61,7 +61,7 @@ int StoreLogMsg(const char *fmt, ...)
 	memset(Buf,0,sizeof(Buf));
 	CurrentTime = time(NULL);
 	tm=localtime(&CurrentTime);
-	sprintf(Buf,"echo \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]ProduceUtils_SystemLog",
+	sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]ProduceUtils_SystemLog",
 			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);

+ 1 - 1
EVSE/Modularization/Module_RFID.c

@@ -98,7 +98,7 @@ int StoreLogMessage(const char *fmt, ...)
 	CurrentTime = time(NULL);
 	tm = localtime(&CurrentTime);
 	sprintf(Buf,
-			"echo \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]RFID_SystemLog",
+			"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]RFID_SystemLog",
 			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);
 	system(Buf);

+ 1 - 1
EVSE/Modularization/Module_Upgrade.c

@@ -37,7 +37,7 @@ int storeLogMsg(const char *fmt, ...)
     memset(Buf,0,sizeof(Buf));
     CurrentTime = time(NULL);
     tm=localtime(&CurrentTime);
-    sprintf(Buf,"echo \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]Upgrade_SystemLog",
+    sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]Upgrade_SystemLog",
             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);

+ 6 - 7
EVSE/Modularization/Module_Wifi.c

@@ -1,10 +1,10 @@
 /*
- * Module_Wifi.c
+ *  Module_Wifi.c
  *
  *  Created on: 2020-01-14
- *  Update on: 2020-05-27
+ *  Update on: 2020-06-18
  *  Author: Jerry Wang, Eason Yang, Folus Wen
- *  Version: D0.03
+ *  Version: D0.04
  */
 
 #include 	<sys/time.h>
@@ -264,7 +264,7 @@ int StoreLogMsg(const char *fmt, ...)
 	memset(Buf,0,sizeof(Buf));
 	CurrentTime = time(NULL);
 	tm=localtime(&CurrentTime);
-	sprintf(Buf,"echo \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]Wifi_SystemLog",
+	sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]Wifi_SystemLog",
 			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);
@@ -592,8 +592,7 @@ int isReachableInternet()
 
 	for(int idx=0;idx<ARRAY_SIZE(valid_Internet);idx++)
 	{
-		strcpy(cmd, "ping -c 1 -w 3 ");
-		strcat(cmd, valid_Internet[idx]);
+		sprintf(cmd, "ping -c 1 -w 3 -I %s %s", Wifi.currentInterface, valid_Internet[idx]);
 		fp = popen(cmd, "r");
 		if(fp != NULL)
 		{
@@ -3868,4 +3867,4 @@ int main(void)
 	}
 
 	return 0;
-}
+}

+ 30 - 1
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -7088,7 +7088,7 @@ int handleDataTransferRequest(char *uuid, char *payload)
 	int result = FAIL;
 	char tempvendorId[255]={0};
 	char tempmessageId[50]={0};
-	char tempdata[50]={0};
+	char tempdata[512]={0};
 	char message[2048]={0};
 
 	DEBUG_INFO("handleDataTransferRequest...\n");
@@ -7122,6 +7122,35 @@ int handleDataTransferRequest(char *uuid, char *payload)
 			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));
 		}
+		else if(strstr(tempmessageId, "SetLEDBar") != NULL)
+		{
+			json_object *data;
+			data = json_tokener_parse(tempdata);
+			if(!is_error(data))
+			{
+				ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity = json_object_get_int(json_object_object_get(data, "Intensity"));
+
+				ShmSysConfigAndInfo->SysConfig.LedInfo.Red[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "R"));
+				ShmSysConfigAndInfo->SysConfig.LedInfo.Green[0]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "G"));
+				ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "B"));
+				ShmSysConfigAndInfo->SysConfig.LedInfo.Red[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "R"));
+				ShmSysConfigAndInfo->SysConfig.LedInfo.Green[1]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "G"));
+				ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "B"));
+				ShmSysConfigAndInfo->SysConfig.LedInfo.Red[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "R"));
+				ShmSysConfigAndInfo->SysConfig.LedInfo.Green[2]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "G"));
+				ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "B"));
+
+				json_object_object_add(response, "status", json_object_new_string("Accepted"));
+			}
+			else
+			{
+				json_object_object_add(response, "status", json_object_new_string("Rejected"));
+				json_object_object_add(response, "data", json_object_new_string("Configuration content something wrong."));
+			}
+			json_object_put(data);
+
+			sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string(response));
+		}
 		else
 		{
 			// Can not find valid message id

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

@@ -1150,6 +1150,13 @@ void* processWatchdog()
 
 			startTimeDog = time((time_t*)NULL);
 		}
+		
+		if(system("pidof -s Module_PhBackend > /dev/null") != 0)
+		{
+			DEBUG_INFO("Module_PhBackend not running, restart it.\r\n");
+			system("/root/Module_PhBackend &");
+		}
+
 		sleep(1);
 	}
 	pthread_exit(NULL); //

+ 11 - 5
EVSE/Projects/AW-CCS/Apps/Module_InternalComm.c

@@ -946,7 +946,7 @@ unsigned char Query_Ble_Central_ID(unsigned char fd, unsigned char targetAddr, B
 	return result;
 }
 
-unsigned char Query_Power_Consumption(unsigned char fd, unsigned char targetAddr, Power_Consumption *Ret_Buf)
+unsigned char Query_Power_Consumption(unsigned char fd, unsigned char targetAddr, Power_Consumption *Ret_Buf_T, Power_Consumption *Ret_Buf_L1, Power_Consumption *Ret_Buf_L2, Power_Consumption *Ret_Buf_L3)
 {
 	unsigned char result = FAIL;
 	unsigned char tx[7] = {0xaa, 0x00, targetAddr, CMD_QUERY_POWER_CONSUMPTION, 0x00, 0x00, 0x00};
@@ -969,7 +969,10 @@ unsigned char Query_Power_Consumption(unsigned char fd, unsigned char targetAddr
 		   (rx[1] == tx[2]) &&
 		   (rx[3] == tx[3]))
 		{
-			Ret_Buf-> power_consumption = ((uint32_t)rx[6] | (((uint32_t)rx[7])<<8) | (((uint32_t)rx[8])<<16) | (((uint32_t)rx[9])<<24));
+			Ret_Buf_T-> power_consumption = ((uint32_t)rx[6] | (((uint32_t)rx[7])<<8) | (((uint32_t)rx[8])<<16) | (((uint32_t)rx[9])<<24));
+			Ret_Buf_L1-> power_consumption = ((uint32_t)rx[10] | (((uint32_t)rx[11])<<8) | (((uint32_t)rx[12])<<16) | (((uint32_t)rx[13])<<24));
+			Ret_Buf_L2-> power_consumption = ((uint32_t)rx[14] | (((uint32_t)rx[15])<<8) | (((uint32_t)rx[16])<<16) | (((uint32_t)rx[17])<<24));
+			Ret_Buf_L3-> power_consumption = ((uint32_t)rx[18] | (((uint32_t)rx[19])<<8) | (((uint32_t)rx[20])<<16) | (((uint32_t)rx[21])<<24));
 			result = PASS;
 		}
 	}
@@ -1296,7 +1299,7 @@ unsigned char Config_AC_MCU_LEGACY_REQUEST(unsigned char fd, unsigned char targe
 	tx[0] = 0xaa;
 	tx[1] = 0x00;
 	tx[2] = targetAddr;
-	tx[3] = CMD_CONFIG_MCU_MODE;
+	tx[3] = CMD_CONFIG_LEGACY_REQUEST;
 	tx[4] = 0x02;
 	tx[5] = 0x00;
 	tx[6] = Set_Buf->isLegacyRequest;
@@ -2460,7 +2463,7 @@ int main(void)
 						//===============================
 						// Query primary MCU power consumption
 						//===============================
-						if(Query_Power_Consumption(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1), &ShmCharger->gun_info[gun_index].powerConsumption))
+						if(Query_Power_Consumption(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1), &ShmCharger->gun_info[gun_index].powerConsumptionTotal, &ShmCharger->gun_info[gun_index].powerConsumption[0], &ShmCharger->gun_info[gun_index].powerConsumption[2], &ShmCharger->gun_info[gun_index].powerConsumption[2]))
 						{
 							failCount[gun_index] = 0;
 						}
@@ -2702,7 +2705,10 @@ int main(void)
 						DEBUG_INFO("==================================================\r\n");
 						DEBUG_INFO("======== Normal priority polling : Case 13 =======\r\n");
 						DEBUG_INFO("==================================================\r\n");
-						DEBUG_INFO("MCU-%d get power consumption : %f kWh\r\n",gun_index, ((float)ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100));
+						DEBUG_INFO("MCU-%d get total power consumption : %f kWh\r\n",gun_index, ((float)ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption/100));
+						DEBUG_INFO("MCU-%d get L1N_L12 power consumption : %f kWh\r\n",gun_index, ((float)ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption/100));
+						DEBUG_INFO("MCU-%d get L2N_L23 power consumption : %f kWh\r\n",gun_index, ((float)ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption/100));
+						DEBUG_INFO("MCU-%d get L3N_L31 power consumption : %f kWh\r\n",gun_index, ((float)ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption/100));
 					}
 					else if(stepIndex == 17)
 					{

+ 1 - 1
EVSE/Projects/AW-CCS/Apps/Module_InternalComm.h

@@ -44,7 +44,7 @@ enum MESSAGE_COMMAND
 	CMD_CONFIG_RTC = 0x87,
 	CMD_CONFIG_AC_LED = 0x88,
 	CMD_CONFIG_CURRENT_LINIT = 0x89,
-	CMD_CONFIG_MCU_MODE = 0x8A,
+	CMD_CONFIG_LEGACY_REQUEST = 0x8A,
 	CMD_CONFIG_MCU_RESET_REQUEST = 0x8C,
 	CMD_CONFIG_MCU_SET_BREATHE_LED_TIMING = 0x8D,
 	CMD_CONFIG_MCU_SET_LED_BRIGHTNESS = 0x8E,

+ 61 - 31
EVSE/Projects/AW-CCS/Apps/main.c

@@ -161,7 +161,7 @@ int StoreLogMsg(const char *fmt, ...)
 
 	if((ShmSysConfigAndInfo->SysConfig.ModelName != NULL) && (ShmSysConfigAndInfo->SysConfig.SerialNumber != NULL) && (strlen((char*)ShmSysConfigAndInfo->SysConfig.ModelName) >= 14))
 	{
-		sprintf(Buf,"echo \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]%s_%s_SystemLog",
+		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]%s_%s_SystemLog",
 					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,
@@ -170,7 +170,7 @@ int StoreLogMsg(const char *fmt, ...)
 	}
 	else
 	{
-		sprintf(Buf,"echo \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
+		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
 					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);
@@ -979,7 +979,6 @@ void InitEthernet()
 		{
 			if(isReachableInternet() == PASS)
 			{
-				ShmSysConfigAndInfo->SysInfo.InternetConn = ON;
 				ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet=OFF;
 				cnt_pingDNS_Fail = 0;
 			}
@@ -987,10 +986,21 @@ void InitEthernet()
 			{
 				if(++cnt_pingDNS_Fail > 3)
 				{
-					ShmSysConfigAndInfo->SysInfo.InternetConn = OFF;
+					
 					ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet=ON;
 				}
 			}
+			
+			if(ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet &&
+				ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi &&
+				ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi)
+			{
+				ShmSysConfigAndInfo->SysInfo.InternetConn = OFF;
+			}
+			else
+			{
+				ShmSysConfigAndInfo->SysInfo.InternetConn = ON;
+			}
 
 			sleep(5);
 		}
@@ -1186,7 +1196,7 @@ void get_firmware_version(unsigned char gun_index)
 	strcpy((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ShmCharger->gun_info[gun_index].ver.Version_FW);
 
 	// Get CSU root file system version
-	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "D0.18.00.0000.00");
+	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "D0.22.00.0000.00");
 
 	// Get AC connector type from model name
 	for(uint8_t idx=0;idx<3;idx++)
@@ -1678,8 +1688,7 @@ int isReachableInternet()
 
 	for(int idx=0;idx<ARRAY_SIZE(valid_Internet);idx++)
 	{
-		strcpy(cmd, "ping -c 1 -w 3 ");
-		strcat(cmd, valid_Internet[idx]);
+		sprintf(cmd, "ping -c 1 -w 3 -I eth0 %s", valid_Internet[idx]);
 		fp = popen(cmd, "r");
 		if(fp != NULL)
 		{
@@ -2568,7 +2577,7 @@ int main(void)
 								if((ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission == OFF) && (ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty != CCS_PWM_DUTY_5))
 								{
 									DEBUG_INFO("Wait CCS give up negotiagting.\r\n");
-									ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_CP_STAT_E;
+									ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_CP_STATE_E;
 									ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;						
 									ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_CP_STATE_E;
 									ShmCharger->gun_info[gun_index].chargingMode = CHARGING_MODE_BS;
@@ -2642,23 +2651,16 @@ int main(void)
 							case HANDSHAKE_BS_MODE:
 								if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C)
 									setRelay(gun_index,ON);
-								if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > ShmCharger->timeoutSpec.Present_Timeout_Spec)
-								{
-									setLedMotion(gun_index, LED_ACTION_HANDSHAKE_FAIL);
-
-									if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > (ShmCharger->timeoutSpec.Present_Timeout_Spec+5000))
-									{
-										DEBUG_INFO("Handshaking timeout...\r\n");
-										setChargerMode(gun_index, SYS_MODE_IDLE);
-									}
-								}
-								else if((ShmCharger->gun_info[gun_index].primaryMcuState.relay_state == ON))
+								if((ShmCharger->gun_info[gun_index].primaryMcuState.relay_state == ON))
 								{
 									ShmCharger->gun_info[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].isUnlockerConnetor = OFF;
 									ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = 0;
 									getDateTimeString((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartDateTime);
-									ShmCharger->gun_info[gun_index].powerConsumption.power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumption.power_consumption;
-									ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
+									ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption;
+									ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption;
+									ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption;
+									ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption;
+									ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption/100);
 									memcpy((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
 
 									memcpy((char*)ShmOCPP16Data->StartTransaction[gun_index].IdTag, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ARRAY_SIZE(ShmOCPP16Data->StartTransaction[gun_index].IdTag));
@@ -2684,8 +2686,11 @@ int main(void)
 									ShmCharger->gun_info[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].isUnlockerConnetor = OFF;
 									ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = 0;
 									getDateTimeString((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartDateTime);
-									ShmCharger->gun_info[gun_index].powerConsumption.power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumption.power_consumption;
-									ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
+									ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption;
+									ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption;
+									ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption;
+									ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption;
+									ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption/100);
 									memcpy((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
 
 									memcpy((char*)ShmOCPP16Data->StartTransaction[gun_index].IdTag, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ARRAY_SIZE(ShmOCPP16Data->StartTransaction[gun_index].IdTag));
@@ -2741,9 +2746,9 @@ int main(void)
 						ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = 1;	
 						ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;	
 						
-//#ifdef	CCS_SIMULATION_DATA				
+#ifdef	CCS_SIMULATION_DATA				
 						ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty = CCS_PWM_DUTY_100;						
-//#endif	//CCS_SIMULATION_DATA
+#endif	//CCS_SIMULATION_DATA
 					}
 
 					// Use RFID card to stop handshaking
@@ -2767,6 +2772,25 @@ int main(void)
 						ShmCharger->gun_info[gun_index].rfidReq = OFF;
 					}
 					
+					if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > ShmCharger->timeoutSpec.Present_Timeout_Spec)
+					{
+						setLedMotion(gun_index, LED_ACTION_HANDSHAKE_FAIL);
+
+						if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > (ShmCharger->timeoutSpec.Present_Timeout_Spec+5000))
+						{
+							DEBUG_INFO("Handshaking timeout...\r\n");
+							
+							//Cancel CCS task negotiating
+							ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;	
+							ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = 1;	
+							ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;	
+						
+#ifdef	CCS_SIMULATION_DATA				
+							ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty = CCS_PWM_DUTY_100;						
+#endif	//CCS_SIMULATION_DATA
+						}
+					}		
+					
 					if((ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty == ON) && ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty != CCS_PWM_DUTY_5)
 					{
 						ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_100;
@@ -2799,10 +2823,13 @@ int main(void)
 							else
 							{
 								setLedMotion(gun_index,LED_ACTION_CHARGING);
-								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
+								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption/100);
 								ftime(&endChargingTime[gun_index]);
 								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration = DiffTimeb(startChargingTime[gun_index], endChargingTime[gun_index])/1000;
-								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = ((float)(ShmCharger->gun_info[gun_index].powerConsumption.power_consumption - ShmCharger->gun_info[gun_index].powerConsumption.power_consumption_at_start))/100;
+								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = ((float)(ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption - ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption_at_start))/100;
+								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = ((float)(ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption_at_start))/100;
+								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = ((float)(ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption_at_start))/100;
+								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = ((float)(ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption_at_start))/100;
 
 								// Response StartTransactionConf
 								if(ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionConf == ON)
@@ -2984,10 +3011,13 @@ int main(void)
 							else
 							{
 								setLedMotion(gun_index,LED_ACTION_CHARGING);
-								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
+								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption/100);
 								ftime(&endChargingTime[gun_index]);
 								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration = DiffTimeb(startChargingTime[gun_index], endChargingTime[gun_index])/1000;
-								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = ((float)(ShmCharger->gun_info[gun_index].powerConsumption.power_consumption - ShmCharger->gun_info[gun_index].powerConsumption.power_consumption_at_start))/100;
+								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = ((float)(ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption - ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption_at_start))/100;
+								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = ((float)(ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption_at_start))/100;
+								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = ((float)(ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption_at_start))/100;
+								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = ((float)(ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption_at_start))/100;
 
 								// Response StartTransactionConf
 								if(ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionConf == ON)
@@ -3582,7 +3612,7 @@ int main(void)
 								DEBUG_INFO("Gun-%d : StopReason [ %s ]...\r\n.",gun_index,ShmOCPP16Data->StopTransaction[gun_index].StopReason);
 
 								memcpy((char*)ShmOCPP16Data->StopTransaction[gun_index].IdTag, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ARRAY_SIZE(ShmOCPP16Data->StopTransaction[gun_index].IdTag));
-								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
+								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption/100);
 								ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq = ON;
 
 								ShmCharger->gun_info[gun_index].rfidReq = OFF;
@@ -3627,7 +3657,7 @@ int main(void)
 								DEBUG_INFO("Gun-%d : StopReason [ %s ]...\r\n.",gun_index,ShmOCPP16Data->StopTransaction[gun_index].StopReason);
 
 								memcpy((char*)ShmOCPP16Data->StopTransaction[gun_index].IdTag, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ARRAY_SIZE(ShmOCPP16Data->StopTransaction[gun_index].IdTag));
-								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
+								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption/100);
 								ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq = ON;
 
 								ShmCharger->gun_info[gun_index].rfidReq = OFF;

+ 4 - 2
EVSE/Projects/AW-CCS/Apps/main.h

@@ -148,7 +148,8 @@
 //=================================
 //#define CCS_SIMULATION_DATA
 
-#define CCS_PWM_DUTY_CP_STAT_E			0			
+#define CCS_PWM_DUTY_CP_STATE_F			0	
+#define CCS_PWM_DUTY_CP_STATE_E			1		
 #define CCS_PWM_DUTY_5					5
 #define CCS_PWM_DUTY_100				100
 
@@ -593,7 +594,8 @@ typedef struct GUN_INFO
 	Ac_Primary_Mcu_Alarm							primaryMcuAlarm;
 	Ac_Primary_Mcu_Led								primaryMcuLed;
 	Mcu_Op_Flag										mcuFlag;
-	Power_Consumption								powerConsumption;
+	Power_Consumption								powerConsumptionTotal;
+	Power_Consumption								powerConsumption[3];
 	Legacy_Request									legacyRequest;
 	System_Alarm_Code								systemAlarmCode;
 	Ac_Primary_Mcu_Cp_Pwm_Duty						primaryMcuCp_Pwn_Duty;

BIN
EVSE/Projects/AW-CCS/Images/FactoryDefaultConfig.bin


BIN
EVSE/Projects/AW-CCS/Images/ramdisk.gz


+ 1 - 1
EVSE/Projects/AW-Regular/Apps/Module_InternalComm.c

@@ -1286,7 +1286,7 @@ unsigned char Config_AC_MCU_LEGACY_REQUEST(unsigned char fd, unsigned char targe
 	tx[0] = 0xaa;
 	tx[1] = 0x00;
 	tx[2] = targetAddr;
-	tx[3] = CMD_CONFIG_MCU_MODE;
+	tx[3] = CMD_CONFIG_LEGACY_REQUEST;
 	tx[4] = 0x02;
 	tx[5] = 0x00;
 	tx[6] = Set_Buf->isLegacyRequest;

+ 1 - 1
EVSE/Projects/AW-Regular/Apps/Module_InternalComm.h

@@ -44,7 +44,7 @@ enum MESSAGE_COMMAND
 	CMD_CONFIG_RTC = 0x87,
 	CMD_CONFIG_AC_LED = 0x88,
 	CMD_CONFIG_CURRENT_LINIT = 0x89,
-	CMD_CONFIG_MCU_MODE = 0x8A,
+	CMD_CONFIG_LEGACY_REQUEST = 0x8A,
 	CMD_CONFIG_MCU_RESET_REQUEST = 0x8C,
 	CMD_CONFIG_MCU_SET_BREATHE_LED_TIMING = 0x8D,
 	CMD_CONFIG_MCU_SET_LED_BRIGHTNESS = 0x8E,

+ 6 - 5
EVSE/Projects/AW-Regular/Apps/main.c

@@ -1181,7 +1181,7 @@ void get_firmware_version(unsigned char gun_index)
 	strcpy((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ShmCharger->gun_info[gun_index].ver.Version_FW);
 
 	// Get CSU root file system version
-	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "B0.47.00.0000.00");
+	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "B0.48.00.0000.00");
 
 	// Get AC connector type from model name
 	for(uint8_t idx=0;idx<3;idx++)
@@ -2572,6 +2572,7 @@ int main(void)
 
 						// Checking profile id > 0 and current time is between charging profile validFrom & validTo
 						if((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileId>0) &&
+						   (ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileReq != ON) &&
 						   (((strlen((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidFrom)>0) && (strlen((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidTo)>0)) ? isProfileValid(gun_index) : ON))
 						{
 							// Debug information
@@ -2599,7 +2600,7 @@ int main(void)
 									for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
 									{
 										if((getScheduleStart(gun_index) > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
-										   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod != 0)))
+										   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod > 0)))
 										{
 											ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
 											DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);
@@ -2619,7 +2620,7 @@ int main(void)
 									for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
 									{
 										if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
-										   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod != 0)))
+										   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod > 0)))
 										{
 											ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
 											DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);
@@ -2641,7 +2642,7 @@ int main(void)
 										for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
 										{
 											if((getStartSinceToday() > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
-											   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod != 0)))
+											   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod > 0)))
 											{
 												ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
 												DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);
@@ -2656,7 +2657,7 @@ int main(void)
 										for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
 										{
 											if((getStartSinceWeek() > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
-											   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod != 0)))
+											   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod > 0)))
 											{
 												ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
 												DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);

BIN
EVSE/Projects/AW-Regular/Images/FactoryDefaultConfig.bin


BIN
EVSE/Projects/AW-Regular/Images/MLO


BIN
EVSE/Projects/AW-Regular/Images/ramdisk.gz


BIN
EVSE/Projects/AW-Regular/Images/u-boot.img


BIN
EVSE/Projects/AW-Regular/Images/zImage


+ 1 - 1
EVSE/Projects/BYTON-GB/Apps/Module_InternalComm.c

@@ -1286,7 +1286,7 @@ unsigned char Config_AC_MCU_LEGACY_REQUEST(unsigned char fd, unsigned char targe
 	tx[0] = 0xaa;
 	tx[1] = 0x00;
 	tx[2] = targetAddr;
-	tx[3] = CMD_CONFIG_MCU_MODE;
+	tx[3] = CMD_CONFIG_LEGACY_REQUEST;
 	tx[4] = 0x02;
 	tx[5] = 0x00;
 	tx[6] = Set_Buf->isLegacyRequest;

+ 1 - 1
EVSE/Projects/BYTON-GB/Apps/Module_InternalComm.h

@@ -44,7 +44,7 @@ enum MESSAGE_COMMAND
 	CMD_CONFIG_RTC = 0x87,
 	CMD_CONFIG_AC_LED = 0x88,
 	CMD_CONFIG_CURRENT_LINIT = 0x89,
-	CMD_CONFIG_MCU_MODE = 0x8A,
+	CMD_CONFIG_LEGACY_REQUEST = 0x8A,
 	CMD_CONFIG_MCU_RESET_REQUEST = 0x8C,
 	CMD_CONFIG_MCU_SET_BREATHE_LED_TIMING = 0x8D,
 	CMD_CONFIG_MCU_SET_LED_BRIGHTNESS = 0x8E,

+ 6 - 5
EVSE/Projects/BYTON-GB/Apps/main.c

@@ -1181,7 +1181,7 @@ void get_firmware_version(unsigned char gun_index)
 	strcpy((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ShmCharger->gun_info[gun_index].ver.Version_FW);
 
 	// Get CSU root file system version
-	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "B0.33.00.0000.00");
+	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "B0.34.00.0000.00");
 
 	// Get AC connector type from model name
 	for(uint8_t idx=0;idx<3;idx++)
@@ -2668,6 +2668,7 @@ int main(void)
 
 						// Checking profile id > 0 and current time is between charging profile validFrom & validTo
 						if((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileId>0) &&
+						   (ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileReq != ON) &&
 						   (((strlen((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidFrom)>0) && (strlen((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidTo)>0)) ? isProfileValid(gun_index) : ON))
 						{
 							// Debug information
@@ -2695,7 +2696,7 @@ int main(void)
 									for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
 									{
 										if((getScheduleStart(gun_index) > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
-										   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod != 0)))
+										   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod > 0)))
 										{
 											ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
 											DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);
@@ -2715,7 +2716,7 @@ int main(void)
 									for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
 									{
 										if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
-										   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod != 0)))
+										   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod > 0)))
 										{
 											ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
 											DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);
@@ -2737,7 +2738,7 @@ int main(void)
 										for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
 										{
 											if((getStartSinceToday() > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
-											   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod != 0)))
+											   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod > 0)))
 											{
 												ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
 												DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);
@@ -2752,7 +2753,7 @@ int main(void)
 										for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
 										{
 											if((getStartSinceWeek() > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
-											   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod != 0)))
+											   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod > 0)))
 											{
 												ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
 												DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);

BIN
EVSE/Projects/BYTON-GB/Images/FactoryDefaultConfig.bin


BIN
EVSE/Projects/BYTON-GB/Images/MLO


BIN
EVSE/Projects/BYTON-GB/Images/ramdisk.gz


BIN
EVSE/Projects/BYTON-GB/Images/u-boot.img


BIN
EVSE/Projects/BYTON-GB/Images/zImage


+ 1 - 1
EVSE/Projects/Noodoe/Apps/Module_FactoryConfig.c

@@ -281,7 +281,7 @@ int main(int argc, char *argv[])
 
 	// Backend configuration
 	SysConfig.BackendConnTimeout=300; 		// 300 seconds
-	SysConfig.OfflinePolicy = 2;			// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
+	SysConfig.OfflinePolicy = 0;			// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
 	SysConfig.OfflineMaxChargeEnergy = 0;	// 0: Same as MaxChargeEnergy	Other: 1~65535KWH
 	SysConfig.OfflineMaxChargeDuration = 0; // 0: Same as MaxChargeDuration Other: 1~65535 minutes
 	strcpy((char*)SysConfig.OcppServerURL, "");

+ 1 - 1
EVSE/Projects/Noodoe/Apps/Module_InternalComm.c

@@ -1286,7 +1286,7 @@ unsigned char Config_AC_MCU_LEGACY_REQUEST(unsigned char fd, unsigned char targe
 	tx[0] = 0xaa;
 	tx[1] = 0x00;
 	tx[2] = targetAddr;
-	tx[3] = CMD_CONFIG_MCU_MODE;
+	tx[3] = CMD_CONFIG_LEGACY_REQUEST;
 	tx[4] = 0x02;
 	tx[5] = 0x00;
 	tx[6] = Set_Buf->isLegacyRequest;

+ 1 - 1
EVSE/Projects/Noodoe/Apps/Module_InternalComm.h

@@ -44,7 +44,7 @@ enum MESSAGE_COMMAND
 	CMD_CONFIG_RTC = 0x87,
 	CMD_CONFIG_AC_LED = 0x88,
 	CMD_CONFIG_CURRENT_LINIT = 0x89,
-	CMD_CONFIG_MCU_MODE = 0x8A,
+	CMD_CONFIG_LEGACY_REQUEST = 0x8A,
 	CMD_CONFIG_MCU_RESET_REQUEST = 0x8C,
 	CMD_CONFIG_MCU_SET_BREATHE_LED_TIMING = 0x8D,
 	CMD_CONFIG_MCU_SET_LED_BRIGHTNESS = 0x8E,

+ 6 - 5
EVSE/Projects/Noodoe/Apps/main.c

@@ -1181,7 +1181,7 @@ void get_firmware_version(unsigned char gun_index)
 	strcpy((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ShmCharger->gun_info[gun_index].ver.Version_FW);
 
 	// Get CSU root file system version
-	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "B0.36.00.0000.00");
+	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "B0.37.00.0000.00");
 
 	// Get AC connector type from model name
 	for(uint8_t idx=0;idx<3;idx++)
@@ -2583,6 +2583,7 @@ int main(void)
 
 						// Checking profile id > 0 and current time is between charging profile validFrom & validTo
 						if((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileId>0) &&
+						   (ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileReq != ON) &&
 						   (((strlen((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidFrom)>0) && (strlen((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidTo)>0)) ? isProfileValid(gun_index) : ON))
 						{
 							// Debug information
@@ -2610,7 +2611,7 @@ int main(void)
 									for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
 									{
 										if((getScheduleStart(gun_index) > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
-										   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod != 0)))
+										   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod > 0)))
 										{
 											ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
 											DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);
@@ -2630,7 +2631,7 @@ int main(void)
 									for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
 									{
 										if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
-										   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod != 0)))
+										   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod > 0)))
 										{
 											ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
 											DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);
@@ -2652,7 +2653,7 @@ int main(void)
 										for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
 										{
 											if((getStartSinceToday() > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
-											   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod != 0)))
+											   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod > 0)))
 											{
 												ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
 												DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);
@@ -2667,7 +2668,7 @@ int main(void)
 										for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
 										{
 											if((getStartSinceWeek() > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
-											   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod != 0)))
+											   (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod > 0)))
 											{
 												ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
 												DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);

BIN
EVSE/Projects/Noodoe/Images/FactoryDefaultConfig.bin


BIN
EVSE/Projects/Noodoe/Images/MLO


BIN
EVSE/Projects/Noodoe/Images/ramdisk.gz


BIN
EVSE/Projects/Noodoe/Images/u-boot-spl.bin


BIN
EVSE/Projects/Noodoe/Images/u-boot.img


BIN
EVSE/Projects/Noodoe/Images/zImage


+ 11 - 1
EVSE/Projects/define.h

@@ -306,6 +306,15 @@ struct BillingConfigData
 	float 				Cur_fee;					// display current fee
 };
 
+struct LED
+{
+	unsigned char 			Intensity;					// LED bar intensity	0: Darkest	1: Medium	2: Brightest
+
+	unsigned char			Red[3];						// Red color	0~100, element 0: IDLE		1: CHARGING		2: FAULT
+	unsigned char			Green[3];					// Green color	0~100, element 0: IDLE		1: CHARGING		2: FAULT
+	unsigned char			Blue[3];					// Blue color	0~100, element 0: IDLE		1: CHARGING		2: FAULT
+};
+
 struct SysConfigData
 {
 	/**************System***************/
@@ -360,8 +369,9 @@ struct SysConfigData
 	unsigned short	   		OfflineMaxChargeDuration;	//0: same as MaxChargeDuration, 1 ~ 65535 minutes
 	unsigned char 			OcppServerURL[512];			//http: non-secure OCPP 1.5-S, https: secure OCPP 1.5-S, ws: non-secure OCPP 1.6-J, wss: secure OCPP 1.6-J"
 	unsigned char 			ChargeBoxId[128];
-	unsigned char			chargePointVendor[20];			//the Vendor of the ChargePoint
+	unsigned char			chargePointVendor[20];		//the Vendor of the ChargePoint
 	unsigned int 			Checksum;					//4 bytes checksum
+	struct LED				LedInfo;					// LED configuration info
 };
 
 struct ChargingInfoData

BIN
EVSE/rootfs/lib/firmware/mrvl/USB8801.bin


BIN
EVSE/rootfs/root/Module_PhBackend


+ 48 - 0
EVSE/rootfs/root/u-blox_tools/bridge_init.conf

@@ -0,0 +1,48 @@
+#
+# File:	bridge_init.conf
+#
+#
+# Labtool-Bridge configuration file
+# Lines that start with # are treated as comments
+# Lines that start with % are treated as end of file
+# Each line should not exceed 80 characters
+# Format: Param_name=value
+#
+#################################################################################
+
+# Server Port #
+Server_port=9930
+
+# Client Port #
+Client_port=9931
+
+# WLAN Interface name
+WLAN_interface_name="mlan0"
+
+# BT Interface name
+BT_interface_name="hci0"
+
+# Protocol (TCP or UDP)
+Protocol="TCP"
+
+# serial port
+Serial="/dev/ttyAMA0"
+
+# baudrate
+BAUD=115200
+
+# bridge mode
+Mode="Auto"
+
+# Load script
+Load_script="/root/Desktop/load.sh"
+
+# Unload script
+Unload_script="/root/Desktop/unload.sh"
+
+# tftp command
+tftp_command="tftp 192.168.1.1 -c get "
+
+# default fw name and path
+fw="/lib/firmware/mrvl/usb8801_uapsta.bin"
+%

BIN
EVSE/rootfs/root/u-blox_tools/mfgbridge


+ 6 - 0
EVSE/rootfs/usr/bin/run_u-blox_tools.sh

@@ -0,0 +1,6 @@
+#!/bin/sh
+rmmod usb8xxx
+rmmod mlan
+insmod /lib/modules/mlan.ko
+insmod /lib/modules/usb8801.ko mfg_mode=1 drv_mode=1 fw_name=mrvl/USB8801.bin
+cd /root/u-blox_tools;sleep 1;./mfgbridge

+ 1 - 1
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.version

@@ -1 +1 @@
-6
+7

+ 4 - 3
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/.am335x-evm.dtb.dts.tmp

@@ -1444,6 +1444,7 @@
                 compatible = "nxp,pcf85063";
                 reg = <0x51>;
         };
+
 };
 
 &usb {
@@ -1478,7 +1479,7 @@
 &elm {
  status = "okay";
 };
-# 402 "arch/arm/boot/dts/am335x-evm.dts"
+# 403 "arch/arm/boot/dts/am335x-evm.dts"
 &gpmc {
  status = "okay";
  pinctrl-names = "default", "sleep";
@@ -1664,7 +1665,7 @@
   };
  };
 };
-# 508 "arch/arm/boot/dts/am335x-evm.dts" 2
+# 509 "arch/arm/boot/dts/am335x-evm.dts" 2
 
 &tps {
  vcc1-supply = <&vbat>;
@@ -1763,7 +1764,7 @@
   phy-mode = "mii";
 
 };
-# 614 "arch/arm/boot/dts/am335x-evm.dts"
+# 615 "arch/arm/boot/dts/am335x-evm.dts"
 &tscadc {
  status = "okay";
 

+ 1 - 0
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/am335x-evm.dts

@@ -344,6 +344,7 @@
                 compatible = "nxp,pcf85063";
                 reg = <0x51>;
         };
+
 };
 #endif
 &usb {