Browse Source

Merge branch 'master' into DO360

Wendell 2 years ago
parent
commit
6cae898684
85 changed files with 2979 additions and 1171 deletions
  1. 34 6
      EVSE/Modularization/Makefile
  2. 620 0
      EVSE/Modularization/Module_Payment_Bazel8.c
  3. 100 0
      EVSE/Modularization/Module_Payment_Bazel8.h
  4. 23 9
      EVSE/Modularization/Module_PowerSharing.c
  5. 1 0
      EVSE/Modularization/Module_PowerSharing.h
  6. 8 0
      EVSE/Modularization/WebService.c
  7. 5 5
      EVSE/Modularization/ocpp20/MessageHandler.c
  8. 5 5
      EVSE/Modularization/ocppfiles/MessageHandler.c
  9. 5 5
      EVSE/Modularization/ocppph/MessageHandler.c
  10. 1 0
      EVSE/Projects/AW-CCS/Apps/CCS/CsuComm.c
  11. 22 9
      EVSE/Projects/AW-CCS/Apps/LCM/Module_LcmControl.c
  12. 18 0
      EVSE/Projects/AW-CCS/Apps/Module_ConfigTools.c
  13. 410 393
      EVSE/Projects/AW-CCS/Apps/Module_InternalComm.c
  14. 120 63
      EVSE/Projects/AW-CCS/Apps/main.c
  15. 17 16
      EVSE/Projects/AW-CCS/Apps/main.h
  16. 2 6
      EVSE/Projects/AW-Regular/Apps/Module_InternalComm.c
  17. 9 5
      EVSE/Projects/AW-Regular/Apps/main.c
  18. 1 0
      EVSE/Projects/AX80/Apps/CCS/CsuComm.c
  19. 370 268
      EVSE/Projects/AX80/Apps/Module_AlarmDetect.c
  20. 18 0
      EVSE/Projects/AX80/Apps/Module_ConfigTools.c
  21. 132 3
      EVSE/Projects/AX80/Apps/main.c
  22. 8 4
      EVSE/Projects/AX80/Apps/main.h
  23. 33 21
      EVSE/Projects/DD360Tcci/Apps/CSU/RFID.c
  24. 22 24
      EVSE/Projects/DD360Tcci/Apps/CSU/main.c
  25. 1 1
      EVSE/Projects/DD360Tcci/Apps/CSU/main.h
  26. 41 1
      EVSE/Projects/DD360Tcci/Apps/Config.h
  27. 13 11
      EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.c
  28. 3 0
      EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.h
  29. 5 1
      EVSE/Projects/DD360Tcci/Apps/ModuleEvComm/Module_EvRxComm.c
  30. 3 5
      EVSE/Projects/DD360Tcci/Apps/ModuleEvComm/Module_EvTxComm.c
  31. 1 1
      EVSE/Projects/DD360Tcci/Apps/ModuleInternalComm/FanBoard.c
  32. 13 35
      EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.c
  33. 2 0
      EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.h
  34. 16 6
      EVSE/Projects/DD360Tcci/Apps/ReadCmdline.c
  35. 0 1
      EVSE/Projects/DD360Tcci/Apps/SelectGun/SelectGun.h
  36. 29 0
      EVSE/Projects/DD360Tcci/Apps/ShareMemory/shmMem.c
  37. 1 0
      EVSE/Projects/DD360Tcci/Apps/ShareMemory/shmMem.h
  38. BIN
      EVSE/Projects/DD360Tcci/Images/ramdisk.gz
  39. BIN
      EVSE/Projects/DD360Tcci/output/FactoryConfig
  40. BIN
      EVSE/Projects/DD360Tcci/output/Module_ChkSysTask
  41. BIN
      EVSE/Projects/DD360Tcci/output/Module_DoComm
  42. BIN
      EVSE/Projects/DD360Tcci/output/Module_EvComm
  43. BIN
      EVSE/Projects/DD360Tcci/output/Module_EventLogging
  44. BIN
      EVSE/Projects/DD360Tcci/output/Module_InternalComm
  45. BIN
      EVSE/Projects/DD360Tcci/output/Module_LcmControl
  46. BIN
      EVSE/Projects/DD360Tcci/output/Module_PrimaryComm
  47. BIN
      EVSE/Projects/DD360Tcci/output/Module_UpdateFW
  48. BIN
      EVSE/Projects/DD360Tcci/output/ReadCmdline
  49. BIN
      EVSE/Projects/DD360Tcci/output/main
  50. 108 41
      EVSE/Projects/DD360UCar/Apps/CSU/main.c
  51. 35 2
      EVSE/Projects/DD360UCar/Apps/Config.h
  52. 1 1
      EVSE/Projects/DD360UCar/Apps/Define/define.c
  53. 32 30
      EVSE/Projects/DD360UCar/Apps/Define/define.h
  54. 435 126
      EVSE/Projects/DD360UCar/Apps/ModuleDoComm/DoComm.c
  55. 16 3
      EVSE/Projects/DD360UCar/Apps/ModuleDoComm/DoComm.h
  56. 14 1
      EVSE/Projects/DD360UCar/Apps/ModuleEvComm/Ev_Comm.c
  57. 26 27
      EVSE/Projects/DD360UCar/Apps/ModuleEvComm/Module_EvRxComm.c
  58. 2 1
      EVSE/Projects/DD360UCar/Apps/ModuleEvComm/Module_EvTxComm.c
  59. 6 4
      EVSE/Projects/DD360UCar/Apps/ModuleLcmCtrl/Module_LcmControl.c
  60. 1 0
      EVSE/Projects/DD360UCar/Apps/ModuleLcmCtrl/Module_LcmControl.h
  61. 71 0
      EVSE/Projects/DD360UCar/Apps/ReadCmdline.c
  62. 2 1
      EVSE/Projects/DD360UCar/Apps/SelectGun/SelectGun.h
  63. 29 0
      EVSE/Projects/DD360UCar/Apps/ShareMemory/shmMem.c
  64. 1 0
      EVSE/Projects/DD360UCar/Apps/ShareMemory/shmMem.h
  65. BIN
      EVSE/Projects/DD360UCar/Images/ramdisk.gz
  66. BIN
      EVSE/Projects/DD360UCar/output/FactoryConfig
  67. BIN
      EVSE/Projects/DD360UCar/output/Module_ChkSysTask
  68. BIN
      EVSE/Projects/DD360UCar/output/Module_DoComm
  69. BIN
      EVSE/Projects/DD360UCar/output/Module_EvComm
  70. BIN
      EVSE/Projects/DD360UCar/output/Module_EventLogging
  71. BIN
      EVSE/Projects/DD360UCar/output/Module_InternalComm
  72. BIN
      EVSE/Projects/DD360UCar/output/Module_LcmControl
  73. BIN
      EVSE/Projects/DD360UCar/output/Module_PrimaryComm
  74. BIN
      EVSE/Projects/DD360UCar/output/Module_UpdateFW
  75. BIN
      EVSE/Projects/DD360UCar/output/ReadCmdline
  76. BIN
      EVSE/Projects/DD360UCar/output/main
  77. BIN
      EVSE/Projects/DD360UCar/output/simulation
  78. 2 2
      EVSE/Projects/Noodoe/Apps/Module_ConfigTools.c
  79. 22 19
      EVSE/Projects/Noodoe/Apps/main.c
  80. 37 2
      EVSE/Projects/define.h
  81. 1 0
      EVSE/rootfs/root/.gitignore
  82. BIN
      EVSE/rootfs/root/Module_PowerSharing
  83. 22 6
      EVSE/rootfs/var/www/set_backend.php
  84. 3 0
      EVSE/rootfs/var/www/set_backend_action.php
  85. 1 1
      EVSE/rootfs/var/www/set_system.php

+ 34 - 6
EVSE/Modularization/Makefile

@@ -4,11 +4,12 @@ export PATH=/bin:/sbin:/usr/bin:$(SDK_PATH_TARGET)/usr/bin:$PATH
 #define library variable
 Lib_SQLite3 = "-L../../../Modularization/ocppfiles" -lsqlite3
 Lib_RatedCurrentLib = "-L./" -lm -lModule_RatedCurrent
+Lib_Xml = "-L../GPL/libxml2-2.7.6/release/lib" -lxml2
 
-all: clean Module_RFIDLib Module_SystexLib Module_RatedCurrentLib Module_UpgradeLib Module_Wifi \
-     WebServiceLib Ocpp16 Phihong_PsuCommObj Module_4g Infypwr_PsuCommObj \
-     Module_EventLogging Module_ProduceUtils \
-     Ocpp20 Module_Payment Module_DcMeter Ocppph Module_PowerSharing_Task
+all: clean Module_RFIDLib Module_SystexLib Infypwr_PsuCommObj Phihong_PsuCommObj Module_RatedCurrentLib Module_UpgradeLib \
+     Module_Wifi Module_4g WebServiceLib Module_EventLogging Module_ProduceUtils Module_DcMeter Module_PowerSharing_Task \
+     Ocpp16 Ocpp20 Ocppph \
+     Module_Payment Module_Payment_Bazel8
 
 clean:
 	rm -f libModule_RFID.a
@@ -28,6 +29,7 @@ clean:
 	rm -f Module_PowerSharing
 
 Module_ProduceUtils:
+	@echo "===== Module_ProduceUtils =========================================="
 	rm -f Module_ProduceUtils
 	$(CC) -D $(Project) -O0  -Wall -c -fmessage-length=0 -I ../Projects -o Module_ProduceUtils.o Module_ProduceUtils.c
 	$(CC) -o Module_ProduceUtils Module_ProduceUtils.o
@@ -35,24 +37,28 @@ Module_ProduceUtils:
 	mv -f Module_ProduceUtils ../rootfs/root
 
 Module_RatedCurrentLib:
+	@echo "===== Module_RatedCurrentLib ======================================="
 	rm -f libModule_RatedCurrent.a
 	$(CC) -D $(Project) -O0  -Wall -c -fmessage-length=0 -o Module_RatedCurrent.o Module_RatedCurrent.c
 	$(AR) -r libModule_RatedCurrent.a Module_RatedCurrent.o
 	rm -f Module_RatedCurrent.o
 
 Module_RFIDLib:
+	@echo "===== Module_RFIDLib ==============================================="
 	rm -f libModule_RFID.a
 	$(CC) -D $(Project) -O0  -Wall -c -fmessage-length=0 -o Module_RFID.o Module_RFID.c
 	$(AR) -r libModule_RFID.a Module_RFID.o
 	rm -f Module_RFID.o
 
 Module_SystexLib:
+	@echo "===== Module_SystexLib ============================================="
 	rm -f libModule_Systex.a
 	$(CC) -D $(Project) -O0  -Wall -c -fmessage-length=0 -o Module_Systex.o Module_Systex.c
 	$(AR) -r libModule_Systex.a Module_Systex.o
 	rm -f Module_Systex.o
 
 Module_Wifi:
+	@echo "===== Module_Wifi =================================================="
 	rm -f Module_Wifi
 	$(CC) -D $(Project) -I ../Projects -I .//ocppfiles -I ../GPL/json-c-json-c-0.13.1-20180305/release/include -O0  -Wall -c -fmessage-length=0 -o Module_Wifi.o Module_Wifi.c
 	$(CC) -o Module_Wifi Module_Wifi.o ${Lib_SQLite3} -L ../GPL/json-c-json-c-0.13.1-20180305/release/lib -ljson-c
@@ -60,6 +66,7 @@ Module_Wifi:
 	mv -f Module_Wifi ../rootfs/root
 
 Module_4g:
+	@echo "===== Module_4g ==================================================="
 	rm -f Module_4g
 	$(CC) -D $(Project) -I ../Projects -O0  -Wall -c -fmessage-length=0 -o Module_4g.o Module_4g.c
 	$(CC) -o Module_4g Module_4g.o
@@ -67,6 +74,7 @@ Module_4g:
 	mv -f Module_4g ../rootfs/root
 
 WebServiceLib:
+	@echo "===== WebServiceLib =============================================="
 	rm -f WebService
 	$(CC) -D $(Project) -I ../GPL/json-c-json-c-0.13.1-20180305/release/include/json-c -I ../Projects -O0  -Wall -c -fmessage-length=0 -o WebService.o -ljson-c -lm -w WebService.c
 	$(CC) -L ../GPL/json-c-json-c-0.13.1-20180305/release/lib -o WebService WebService.o -ljson-c -lm
@@ -78,41 +86,46 @@ WebServiceLib:
 	mv -f logPackTools ../rootfs/root/
 
 Ocppph:
+	@echo "===== Ocppph ====================================================="
 	rm -f OcppBackendPH;
 	$(CC) -D $(TLS_EXPIRED) -D $(Project) -D__USE_XOPEN -D_GNU_SOURCE ./ocppph/Module_OcppBackend.c ./ocppph/MessageHandler.c ./ocppph/JsonParser.c ./ocppph/SystemLogMessage.c ./ocppph/hashmap.c ./ocppph/common.c -I ../Projects -I ../GPL/libwebsockets-2.2.2-stable/release/include -I ../GPL/json-c-json-c-0.13.1-20180305/release/include -include ./Module_RatedCurrent.h  -L ../GPL/libwebsockets-2.2.2-stable/release/lib -L ../GPL/openssl-1.0.2g/release/lib -L ../GPL/json-c-json-c-0.13.1-20180305/release/lib -L ./ -lwebsockets -lrt -luuid -lpthread -lc -lsqlite3 -ljson-c ${Lib_RatedCurrentLib} -o OcppBackendPH
 	mv -f OcppBackendPH ../rootfs/root/
 
 Ocpp16:
+	@echo "===== Ocpp16 ====================================================="
 	rm -f OcppBackend;
 	$(CC) -D $(TLS_EXPIRED) -D $(Project) -D__USE_XOPEN -D_GNU_SOURCE ./ocppfiles/Module_OcppBackend.c ./ocppfiles/MessageHandler.c ./ocppfiles/JsonParser.c ./ocppfiles/SystemLogMessage.c ./ocppfiles/hashmap.c ./ocppfiles/common.c -I ../Projects -I ../GPL/libwebsockets-2.2.2-stable/release/include -I ../GPL/json-c-json-c-0.13.1-20180305/release/include -include ./Module_RatedCurrent.h -L ../GPL/libwebsockets-2.2.2-stable/release/lib -L ../GPL/openssl-1.0.2g/release/lib -L ../GPL/json-c-json-c-0.13.1-20180305/release/lib -L ./ -lwebsockets -lrt -luuid -lpthread -lc -lsqlite3 -ljson-c ${Lib_RatedCurrentLib} -o OcppBackend
 	mv -f OcppBackend ../rootfs/root/
 
 Ocpp20:
+	@echo "===== Ocpp20 ====================================================="
 	rm -f OcppBackend20;
 	$(CC) -D $(TLS_EXPIRED) -D $(Project) -D__USE_XOPEN -D_GNU_SOURCE ./ocpp20/Module_OcppBackend20.c ./ocpp20/MessageHandler.c ./ocpp20/JsonParser.c ./ocpp20/SystemLogMessage.c ./ocpp20/hashmap.c ./ocpp20/common.c -I ../Projects -I ../GPL/libwebsockets-2.2.2-stable/release/include -I ../GPL/json-c-json-c-0.13.1-20180305/release/include -include ./Module_RatedCurrent.h  -L ../GPL/libwebsockets-2.2.2-stable/release/lib -L ../GPL/openssl-1.0.2g/release/lib -L ../GPL/json-c-json-c-0.13.1-20180305/release/lib -L ./ -lwebsockets -lrt -luuid -lpthread -lc -lsqlite3 -ljson-c ${Lib_RatedCurrentLib} -o OcppBackend20
 	mv -f OcppBackend20 ../rootfs/root/
 
-
-
 Phihong_PsuCommObj:
+	@echo "===== Module_PsuCommObj =========================================="
 	rm -f libPhihong_PsuCommObj.a
 	$(CC) -D $(Project) -O0  -Wall -c -fmessage-length=0 -o Phihong_PsuCommObj.o Phihong_PsuCommObj.c
 	$(AR) -r libPhihong_PsuCommObj.a Phihong_PsuCommObj.o
 	rm -f Phihong_PsuCommObj.o
 
 Infypwr_PsuCommObj:
+	@echo "===== Infypwr_PsuCommObj =========================================="
 	rm -f libInfypwr_PsuCommObj.a
 	$(CC) -D $(Project) -O0  -Wall -c -fmessage-length=0 -o Infypwr_PsuCommObj.o Infypwr_PsuCommObj.c
 	$(AR) -r libInfypwr_PsuCommObj.a Infypwr_PsuCommObj.o
 	rm -f Infypwr_PsuCommObj.o
 
 Module_UpgradeLib:
+	@echo "===== Module_UpgradeLib =========================================="
 	rm -f libModule_Upgrade.a
 	$(CC) -D $(Project) -O0  -Wall -c -fmessage-length=0 -o Module_Upgrade.o Module_Upgrade.c
 	$(AR) -r libModule_Upgrade.a Module_Upgrade.o
 	rm -f Module_Upgrade.o
 
 Module_EventLogging:
+	@echo "===== Module_EventLogging ========================================"
 	rm -f Module_EventLogging
 	$(CC) -D $(Project) -I ../Projects -I ./ocppfiles -O0  -Wall -c -fmessage-length=0 -o Module_EventLogging.o Module_EventLogging.c
 	$(CC) -L ./ocppfiles -lsqlite3 -o Module_EventLogging Module_EventLogging.o
@@ -120,6 +133,7 @@ Module_EventLogging:
 	mv -f Module_EventLogging ../rootfs/root
 
 Module_PhBackend:
+	@echo "===== Module_PhBackend ==========================================="
 	rm -f Module_Phbackend
 	$(CC) -D $(Project) -I ../Projects -O0  -Wall -c -fmessage-length=0 -o Module_PhBackend.o Module_PhBackend.c
 	$(CC) -o Module_PhBackend Module_PhBackend.o ${Lib_RatedCurrentLib}
@@ -127,6 +141,7 @@ Module_PhBackend:
 	mv -f Module_PhBackend ../rootfs/root
 
 Module_InitUpgrade:
+	@echo "===== Module_InitUpgrade ========================================="
 	rm -f Module_InitUpgrade
 	$(CC) -D $(Project) -I ../Projects -O0  -Wall -c -fmessage-length=0 -o Module_InitUpgrade.o Module_InitUpgrade.c
 	$(CC) -o Module_InitUpgrade Module_InitUpgrade.o
@@ -134,18 +149,29 @@ Module_InitUpgrade:
 	mv -f Module_InitUpgrade ../rootfs/root
 
 Module_Payment:
+	@echo "===== Module_Payment ============================================="
 	rm -f Module_Payment
 	$(CC) -D $(Project) -I ../Projects -O0  -Wall -c -fmessage-length=0 -o Module_Payment.o Module_Payment.c
 	$(CC) -o Module_Payment Module_Payment.o
 	rm -f Module_Payment.o
 	mv -f Module_Payment ../rootfs/root
 
+Module_Payment_Bazel8:
+	@echo "===== Module_Payment_Bazel8 ======================================"
+	rm -f Module_Payment_Bazel8
+	$(CC) -D $(Project) -I ../Projects -I ../GPL/libxml2-2.7.6/release/include/libxml2 -O0  -Wall -c -fmessage-length=0 -o Module_Payment_Bazel8.o Module_Payment_Bazel8.c
+	$(CC) -o Module_Payment_Bazel8 Module_Payment_Bazel8.o -lrt ${Lib_Xml}
+	rm -f Module_Payment_Bazel8.o
+	mv -f Module_Payment_Bazel8 ../rootfs/root
+
 Module_DcMeter:
+	@echo "===== Module_DcMeter ============================================="
 	rm -f Module_DcMeter;
 	$(CC) -D $(Project) "-Wl,-rpath-link,../rootfs/lib" ./DcMeter/Module_DcMeter.c ./DcMeter/meterComm.c ./DcMeter/curlApi.c ./DcMeter/SystemLogMessage.c -I ./ -I ../Projects -I ../GPL/curl-7.37.1/release/include -I ../GPL/json-c-json-c-0.13.1-20180305/release/include -L ../GPL/json-c-json-c-0.13.1-20180305/release/lib -L ../GPL/curl-7.37.1/release/lib -ljson-c -lcurl -lssl -o Module_DcMeter ${Lib_RatedCurrentLib}
 	mv -f Module_DcMeter ../rootfs/root/
 
 Module_PCBTest:
+	@echo "===== Module_PCBTest ============================================="
 	rm -f Module_PCBTest
 	$(CC) -o Module_PCBTest ./PCBTest/Module_PCBTest.c ./PCBTest/Comm_Test.c ./PCBTest/Ethernet_Test.c ./PCBTest/IO_Test.c ./PCBTest/PrimaryMCU_Test.c ./PCBTest/Storage_Test.c -I ./
 	mv -f Module_PCBTest ../rootfs/root
@@ -156,3 +182,5 @@ Module_PowerSharing_Task:
 	$(CC) -D $(Project) "-I../Projects" "-I./ocppfiles" "-include./Module_RatedCurrent.h" -O0  -Wall -fmessage-length=0 Module_PowerSharing.c ${Lib_RatedCurrentLib} -lm -lrt -o Module_PowerSharing
 	rm -f *.o
 	mv -f Module_PowerSharing ../rootfs/root
+
+

+ 620 - 0
EVSE/Modularization/Module_Payment_Bazel8.c

@@ -0,0 +1,620 @@
+/*
+ * Module_Payment_Ominixpay.c
+ *
+ *  Created on: 2022/04/29
+ *      Author: Folus Wen
+ */
+
+#include "Module_Payment_Bazel8.h"
+
+struct COMMAND commandRaw;
+struct timespec	tmr[TIMER_CNT];
+
+//==========================================
+// Common routine
+//==========================================
+int StoreLogMsg(const char *fmt, ...)
+{
+	char Buf[65536+256];
+	char buffer[65536];
+	//char Buf[4096+256];
+	//char buffer[4096];
+	time_t CurrentTime;
+	struct tm *tm;
+	struct timeval tv;
+	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);
+	gettimeofday(&tv, NULL); // get microseconds, 10^-6
+
+	sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s\" >>  /Storage/SystemLog/[%04d.%02d]PaymentLog",
+			tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec,
+			buffer,
+			tm->tm_year+1900,tm->tm_mon+1);
+	system((const char*)Buf);
+
+#ifdef ConsloePrintLog
+	printf("[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec, buffer);
+#endif
+
+	return rc;
+}
+/**
+ * Execute shell command
+ * @param cmd: shell command string
+ * @return shell command execution result
+ */
+int runShellCmd(const char*cmd)
+{
+	int result = FAIL;
+	char buf[256];
+	FILE *fp;
+
+	fp = popen(cmd, "r");
+	if(fp != NULL)
+	{
+		while(fgets(buf, sizeof(buf), fp) != NULL)
+		{
+			DEBUG_INFO("%s\n", buf);
+		}
+
+		result = PASS;
+	}
+	pclose(fp);
+
+	return result;
+}
+
+/**
+ *
+ * @param timer
+ */
+void refreshStartTimer(struct timespec *timer)
+{
+	clock_gettime(CLOCK_MONOTONIC, timer);
+}
+
+/**
+ *
+ * @param timer
+ * @return
+ */
+int getDiffSecNow(struct timespec timer)
+{
+	struct timespec timerNow;
+
+	clock_gettime(CLOCK_MONOTONIC, &timerNow);
+
+	return (int)((((unsigned long)(timerNow.tv_sec - timer.tv_sec) * 1000) + ((unsigned long)((timerNow.tv_nsec / 1000000) - (timer.tv_nsec / 1000000))))/1000);
+}
+
+/**
+ *
+ * @param ST
+ */
+long long DiffTimebWithNow(struct timeb ST)
+{
+	//return milli-second
+	struct timeb ET;
+	long long StartTime,StopTime;
+
+	ftime(&ET);
+	StartTime=(long long)ST.time;
+	StopTime=(long long)ET.time;
+	return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
+}
+
+/**
+ *
+ * @return
+ */
+int getTimePassSinceToday()
+{
+	int result = -1;
+	static time_t lastTime;
+	time_t t;
+	struct tm *tmStartToday;
+	struct timeb tbStartToday;
+
+	t=time(NULL);
+	if(difftime(t, lastTime)>0)
+	{
+		tmStartToday=localtime(&t);
+
+		tmStartToday->tm_hour = 0;
+		tmStartToday->tm_min = 0;
+		tmStartToday->tm_sec = 0;
+
+		tbStartToday.time = mktime(tmStartToday);
+		tbStartToday.millitm = 0;
+		result = DiffTimebWithNow(tbStartToday)/1000;
+		lastTime = t;
+	}
+
+	return result;
+}
+/**
+ * Calculate time differential
+ * @param ST: start time
+ * @param ET: end time
+ * @return time differential in million seconds
+ */
+int DiffTimeb(struct timeb ST, struct timeb ET)
+{
+	//return milli-second
+	unsigned int StartTime,StopTime;
+
+	StartTime=(unsigned int)ST.time;
+	StopTime=(unsigned int)ET.time;
+	return (StopTime-StartTime)*1000+ET.millitm-ST.millitm;
+}
+
+/**
+ * Show communication raw data to debug info
+ * @param data: raw data
+ * @param len: data length
+ * @param isRX: is receive data
+ */
+void show_raw(uint8_t *data, uint16_t len, uint8_t isRX)
+{
+	uint8_t output[512]={0};
+
+	if(isRX)
+		DEBUG_INFO("RX ---------------------------------------------\n");
+	else
+		DEBUG_INFO("TX ---------------------------------------------\n");
+
+	DEBUG_INFO(" 0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F \n");
+	DEBUG_INFO("------------------------------------------------\n");
+
+	memset(output, 0x00, ARRAY_SIZE(output));
+	for(int idx=0;idx<len;idx++)
+	{
+		if(strlen((char*)output)<48)
+			sprintf((char*)output, "%s%02X ", output, data[idx]);
+		else
+		{
+			DEBUG_INFO("%s\n", output);
+			memset(output, 0x00, ARRAY_SIZE(output));
+			sprintf((char*)output, "%s%02X ", output, data[idx]);
+		}
+	}
+	DEBUG_INFO("%s\n", output);
+}
+
+/**
+ *
+ * @param dec: number in dec
+ * @return number in bcd
+ */
+int decTobcd(int dec)
+{
+	return (dec/10 * 16)+ (dec%10);
+}
+
+/**
+ *
+ * @param data: message array
+ * @param dataLen: command & data field length in array
+ * @return check sum result
+ */
+int calChksum(unsigned char *data)
+{
+	int result = 0;
+
+	for(uint16_t idx=0;idx<(((data[1] << 8) | (data[1]))+3);idx++)
+	{
+		result ^= data[idx];
+	}
+
+	return (result&0xff);
+}
+
+//==========================================
+// Init share memory
+//==========================================
+/**
+ * Share memory initialization
+ * @return function result
+ */
+int InitShareMemory()
+{
+	int result = PASS;
+	int MeterSMId;
+
+#ifndef X86
+	//init ShmSysConfigAndInfo
+	if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0)
+    {
+		DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
+		result = FAIL;
+	}
+    else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+    {
+    	DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
+    	result = FAIL;
+   	 }
+    else
+    {}
+
+	//init ShmStatusCodeData
+	if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0)
+	{
+		DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
+		result = FAIL;
+	}
+	else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+	{
+		DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
+		result = FAIL;
+	}
+	else
+	{}
+
+   	//init ShmOCPP16Data
+   	if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data),  0777)) < 0)
+	{
+		DEBUG_ERROR("shmget ShmOCPP16Data NG\n");
+		result = FAIL;
+	}
+	else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+	{
+		DEBUG_ERROR("shmat ShmOCPP16Data NG\n");
+		result = FAIL;
+	}
+	else
+	{}
+#endif
+
+   	return result;
+}
+
+//==========================================
+// Init com port
+//==========================================
+/**
+ * TTY port initialization
+ * @return port initial result
+ */
+int InitComPort()
+{
+	int fd;
+	struct termios tios;
+
+	fd = open(TTY_PORT, O_RDWR);
+	if(fd<=0)
+	{
+		return FAIL;
+	}
+	ioctl (fd, TCGETS, &tios);
+	tios.c_cflag = B9600| CS8 | CLOCAL | CREAD;
+	tios.c_lflag = 0;
+	tios.c_iflag = 0;
+	tios.c_oflag = 0;
+	tios.c_cc[VMIN]=0;						// data length threshold, 0 bytes
+	tios.c_cc[VTIME]=(unsigned char)5;		// timeout threshold, 0.5 seconds
+	tios.c_lflag=0;
+	tcflush(fd, TCIFLUSH);
+	ioctl (fd, TCSETS, &tios);
+
+	return fd;
+}
+
+/**
+ *
+ * @param serial port handle
+ * @param request message data
+ * @param response message data
+ * @return
+ */
+int pollingRequest(int uart, unsigned char* cmd)
+{
+	int result=FAIL;
+
+	tcflush(uart,TCIOFLUSH);
+	cmd[(cmd[1]<<8)|(cmd[2])] = calChksum(cmd);
+
+	//show_raw(cmd, cmd_len, NO);
+	if(write(uart, cmd, ARRAY_SIZE(cmd)) > 0)
+	{
+		result = PASS;
+	}
+	else
+	{
+		DEBUG_ERROR("pollingRequest fail.\n");
+	}
+
+	return result;
+}
+
+/**
+ *
+ * @param uart
+ * @param rx
+ * @return
+ */
+int pollingResponse(int uart, unsigned char* rx)
+{
+	int result=FAIL;
+
+	read(uart, rx, RAW_DATA_LENGTH);
+	//show_raw(rx, rx_len, YES);
+
+	if(calChksum(&rx[0]) == rx[(((rx[1] << 8) | (rx[1]))+3)])
+	{
+		result = PASS;
+	}
+
+	return result;
+}
+
+/**
+ *
+ * @param uart
+ * @return
+ */
+int getInputBufferCount(int uart)
+{
+	int bytes_avail;
+	ioctl(uart, FIONREAD, &bytes_avail);
+
+	return bytes_avail;
+}
+
+/**
+ *
+ * @param node
+ * @param node_name
+ * @return
+ */
+xmlNode *find_node(xmlNode *node, char *node_name)
+{
+	xmlNode *result;
+
+	if (node == NULL) return NULL;
+
+	while(node)
+	{
+		if((node->type == XML_ELEMENT_NODE) && (strcmp((char*)node->name, node_name) == 0)) return node;
+
+		if((result = find_node(node->children, node_name))) return result;
+
+		node = node->next;
+	}
+
+  return NULL;
+}
+
+//==========================================
+// Reader operation function
+//==========================================
+int preAuthRequest(int uart)
+{
+	char xmlBody[512]={0};
+
+	xmlBuffer * outputXmlPtr = xmlBufferCreate();
+	xmlDocPtr doc = NULL;
+	xmlNodePtr node_req = NULL;
+	xmlNodePtr node_cmd = NULL;
+	xmlNodePtr node_param = NULL;
+	xmlNodePtr node_param_Txn = NULL;
+
+	// Create xml message
+	doc = xmlNewDoc(BAD_CAST "1.0");
+	node_req = xmlNewNode(NULL, BAD_CAST "Req");
+	xmlDocSetRootElement(doc, node_req);
+
+	node_cmd = xmlNewNode(NULL, BAD_CAST "Cmd");
+	xmlNewChild(node_cmd, NULL, BAD_CAST "CmdId", BAD_CAST "TxnStart");
+	xmlNewChild(node_cmd, NULL, BAD_CAST "CmdTout", BAD_CAST "30");
+	xmlAddChild(node_req, node_cmd);
+
+	node_param = xmlNewNode(NULL, BAD_CAST "Param");
+	node_param_Txn = xmlNewNode(NULL, BAD_CAST "Txn");
+	xmlNewChild(node_param_Txn, NULL, BAD_CAST "TxnType", BAD_CAST "AuthOnly");
+	xmlNewChild(node_param_Txn, NULL, BAD_CAST "CurrCode", BAD_CAST "840");
+	xmlNewChild(node_param_Txn, NULL, BAD_CAST "TxnAmt", BAD_CAST "100");
+	xmlAddChild(node_param, node_param_Txn);
+	xmlAddChild(node_req, node_param);
+
+    xmlNodeDump(outputXmlPtr, NULL, (xmlNode *)node_req, 0, 0);
+    sprintf(xmlBody, "%s", (const char *)outputXmlPtr->content);
+
+    xmlBufferFree(outputXmlPtr);
+    xmlFreeDoc(doc);
+    xmlCleanupParser();
+    xmlMemoryDump();
+
+	// Create protocol message
+	memset(commandRaw.requestData, 0x00, ARRAY_SIZE(commandRaw.requestData));
+
+	commandRaw.requestData[0] = STX;
+	commandRaw.requestData[1] = (strlen(xmlBody)>>8)&0xff;
+	commandRaw.requestData[2] = (strlen(xmlBody)>>0)&0xff;
+	memcpy(&commandRaw.requestData[3], xmlBody, strlen(xmlBody));
+
+
+	return pollingRequest(uart, commandRaw.requestData);
+}
+
+int preAuthResponse(int uart)
+{
+	int result = pollingResponse(uart, commandRaw.responseData);
+	//char *xmlTestBody = "<Event><MesgId>21</MesgId><MesgStr>PLEASE PRESENT CARD</MesgStr></Event>";
+	//char *xmlTestBody = "<Event><MesgId>27</MesgId><MesgStr>AUTHORIZING. PLEASE WAIT...</MesgStr></Event>";
+	//char *xmlTestBody = "<Resp><Cmd><CmdId>TxnStartResp</CmdId><StatusCode>001F</StatusCode><StatusText>TransactionDeferred</StatusText></Cmd><Data><Txn><TxnId>62</TxnId></Txn></Data></Resp>";
+	char xmlTestBody[512] = {0};
+
+	if(result == PASS)
+	{
+		memcpy(xmlTestBody, &commandRaw.responseData[3], ((commandRaw.responseData[1] << 8) | commandRaw.responseData[2]));
+
+		xmlDocPtr doc = xmlParseDoc((const xmlChar *)xmlTestBody);
+		xmlNode *root_element = xmlDocGetRootElement(doc);
+
+		if(find_node(root_element, "Event") != NULL)
+		{
+			DEBUG_INFO("===== Get event =======================\n");
+			ShmSysConfigAndInfo->SysInfo.bazel8.event.messageId = atoi((char*)xmlNodeGetContent(find_node(root_element, "MesgId")));
+			sprintf(ShmSysConfigAndInfo->SysInfo.bazel8.event.messageString, "%s", xmlNodeGetContent(find_node(root_element, "MesgId")));
+			ShmSysConfigAndInfo->SysInfo.bazel8.event.isGetOn = ON;
+
+			DEBUG_INFO("Message id: %d\n", ShmSysConfigAndInfo->SysInfo.bazel8.event.messageId);
+			DEBUG_INFO("%s: %s\n", root_element->children->next->name, xmlNodeGetContent(root_element->children->next));
+		}
+		else if((find_node(root_element, "Resp") != NULL) && (strstr((char*)xmlNodeGetContent(find_node(root_element, "CmdId")), "TxnStartResp") != NULL))
+		{
+			DEBUG_INFO("===== Get response =======================\n");
+			sprintf(ShmSysConfigAndInfo->SysInfo.bazel8.txResp.statusCode, "%s", xmlNodeGetContent(find_node(root_element, "StatusCode")));
+			sprintf(ShmSysConfigAndInfo->SysInfo.bazel8.txResp.statusText, "%s", xmlNodeGetContent(find_node(root_element, "StatusText")));
+			sprintf(ShmSysConfigAndInfo->SysInfo.bazel8.txResp.txnId, "%s", xmlNodeGetContent(find_node(root_element, "TxnId")));
+			ShmSysConfigAndInfo->SysInfo.bazel8.txResp.isGetOn = ON;
+
+			DEBUG_INFO("Status code: %s\n", ShmSysConfigAndInfo->SysInfo.bazel8.txResp.statusCode);
+			DEBUG_INFO("Status text: %s\n", ShmSysConfigAndInfo->SysInfo.bazel8.txResp.statusText);
+			DEBUG_INFO("TxnId: %s\n", ShmSysConfigAndInfo->SysInfo.bazel8.txResp.txnId);
+		}
+		else
+		{
+			DEBUG_INFO("===== Get unknown node =======================\n");
+		}
+
+	    xmlFreeDoc(doc);
+	    xmlCleanupParser();
+	    xmlMemoryDump();
+	}
+
+	return result;
+}
+
+//==========================================
+// Main loop
+//==========================================
+int main(void)
+{
+	int UartFd;
+	int preAuthRetry = 0;
+	int cmdRepeatCount = 0;
+
+	//===============================================
+	// Initialization
+	//===============================================
+#ifndef X86
+	if(InitShareMemory() == FAIL)
+	{
+		DEBUG_ERROR("InitShareMemory NG\n");
+
+		if(ShmStatusCodeData!=NULL)
+		{
+			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
+		}
+		sleep(5);
+		return FAIL;
+	}
+#endif
+
+	UartFd=InitComPort();
+	if(UartFd<0)
+	{
+		DEBUG_ERROR("InitComPort NG\n");
+		if(ShmStatusCodeData!=NULL)
+		{
+#ifndef X86
+			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed=1;
+#endif
+		}
+		sleep(5);
+		return FAIL;
+	}
+	else
+	{
+		DEBUG_INFO("%s port open success.\n", TTY_PORT);
+	}
+
+	DEBUG_INFO("Payment module initialize completed.\n");
+
+	//===============================================
+	// Main loop
+	//===============================================
+	for(;;)
+	{
+		if(ShmSysConfigAndInfo->SysInfo.bazel8.cmdPreAuth.isReq)
+		{
+			// Pre auth request
+			if(!ShmSysConfigAndInfo->SysInfo.bazel8.cmdPreAuth.isWaitRes)
+			{
+				ShmSysConfigAndInfo->SysInfo.bazel8.cmdPreAuth.isRes = false;
+				ShmSysConfigAndInfo->SysInfo.bazel8.event.isGetOn = false;
+				ShmSysConfigAndInfo->SysInfo.bazel8.txResp.isGetOn = false;
+
+				if(preAuthRequest(UartFd))
+				{
+					ShmSysConfigAndInfo->SysInfo.bazel8.cmdPreAuth.isWaitRes = true;
+					cmdRepeatCount = 0;
+					refreshStartTimer(&tmr[TIMER_READ_RESPONSE]);
+				}
+
+				if(cmdRepeatCount > SPEC_REQUEST_RETRY)
+				{
+					DEBUG_WARN("preAuthRequest fail over count(%d).", cmdRepeatCount);
+					cmdRepeatCount = 0;
+					ShmSysConfigAndInfo->SysInfo.bazel8.cmdPreAuth.isReq = false;
+					ShmSysConfigAndInfo->SysInfo.bazel8.cmdPreAuth.isResultPass = false;
+					ShmSysConfigAndInfo->SysInfo.bazel8.cmdPreAuth.isRes = true;
+				}
+				else
+				{
+					cmdRepeatCount += 1;
+				}
+			}
+			else
+			{
+				if((getInputBufferCount(UartFd) >= RAW_DATA_LENGTH))
+				{
+					if(preAuthResponse(UartFd))
+					{
+						if(ShmSysConfigAndInfo->SysInfo.bazel8.event.isGetOn)
+						{
+							/*
+							 *	TODO:
+							 *	1. Announce CSU event content.
+							 */
+							ShmSysConfigAndInfo->SysInfo.bazel8.event.isGetOn = false;
+						}
+						else if(ShmSysConfigAndInfo->SysInfo.bazel8.txResp.isGetOn)
+						{
+							ShmSysConfigAndInfo->SysInfo.bazel8.cmdPreAuth.isResultPass = ((strstr(ShmSysConfigAndInfo->SysInfo.bazel8.txResp.statusCode, "0000") != NULL)?true:false);
+
+							if(ShmSysConfigAndInfo->SysInfo.bazel8.cmdPreAuth.isResultPass || (preAuthRetry++ >= 3))
+							{
+								ShmSysConfigAndInfo->SysInfo.bazel8.cmdPreAuth.isReq = false;
+								ShmSysConfigAndInfo->SysInfo.bazel8.cmdPreAuth.isRes = true;
+
+								preAuthRetry = 0;
+							}
+							ShmSysConfigAndInfo->SysInfo.bazel8.cmdPreAuth.isWaitRes = false;
+						}
+					}
+				}
+
+				if((getDiffSecNow(tmr[TIMER_READ_RESPONSE]) > TIMEOUT_REQUEST))
+				{
+					ShmSysConfigAndInfo->SysInfo.bazel8.cmdPreAuth.isReq = false;
+					ShmSysConfigAndInfo->SysInfo.bazel8.cmdPreAuth.isWaitRes = false;
+					ShmSysConfigAndInfo->SysInfo.bazel8.cmdPreAuth.isResultPass = false;
+					ShmSysConfigAndInfo->SysInfo.bazel8.cmdPreAuth.isRes = true;
+					DEBUG_WARN("Wait pre auth response timeout(%d secs).", TIMEOUT_REQUEST);
+				}
+			}
+		}
+
+		sleep(3);
+	}
+
+	return FAIL;
+}

+ 100 - 0
EVSE/Modularization/Module_Payment_Bazel8.h

@@ -0,0 +1,100 @@
+/*
+ * Module_Payment_Omnixpay.h
+ *
+ *  Created on: 2022/01/24
+ *      Author: folus
+ */
+
+#ifndef MODULE_PAYMENT_BAZEL8_H_
+#define MODULE_PAYMENT_BAZEL8_H_
+//#define	X86
+
+#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 	<math.h>
+#include	<limits.h>
+#include	<stdint.h>
+#include 	<libxml/parser.h>
+#include 	<libxml/tree.h>
+
+#ifndef X86
+	#include	"define.h"
+	#define TTY_PORT		"/dev/ttyS2"
+#else
+	#define ConsloePrintLog
+	#define TTY_PORT		"/dev/ttyUSB0"
+#endif
+
+#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+
+#define is_error(ptr) 				((unsigned long)ptr > (unsigned long)-4000L)
+#define ARRAY_SIZE(A)				(sizeof(A) / sizeof(A[0]))
+#define PASS						1
+#define FAIL			   			-1
+#define ON							1
+#define OFF							0
+#define YES							1
+#define NO							0
+
+#define RAW_DATA_LENGTH				32
+#define SPEC_REQUEST_RETRY			3
+#define TIMEOUT_REQUEST				40
+
+struct SysConfigAndInfo				*ShmSysConfigAndInfo;
+struct StatusCodeData 				*ShmStatusCodeData;
+struct OCPP16Data 					*ShmOCPP16Data;
+
+enum TIMER
+{
+	TIMER_READ_RESPONSE,
+	TIMER_INDEX_1,
+	TIMER_CNT
+};
+
+enum Boolean
+{
+	false=0,
+	true
+};
+
+enum MESSAGE_HEADER
+{
+	STX=0xC2
+};
+
+struct COMMAND
+{
+	uint8_t requestData[1024];
+	uint8_t responseData[1024];
+};
+
+
+#endif /* MODULE_PAYMENT_BAZEL8_H_ */

+ 23 - 9
EVSE/Modularization/Module_PowerSharing.c

@@ -273,7 +273,7 @@ uint16_t checkChargingProfileLimit()
 	 * 	TODO:
 	 * 	1. Default capacity check
 	 */
-	uint16_t targetMaxCurrent = modelnameInfo.ratedPower/220;
+	uint16_t targetMaxCurrent = ((ShmSysConfigAndInfo->SysConfig.PowerSharingCapacityPower==0)?(modelnameInfo.ratedPower/220):(ShmSysConfigAndInfo->SysConfig.PowerSharingCapacityPower/220));
 
 	if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 	{
@@ -689,12 +689,26 @@ int conn_update_status(int socketFd, Connector_Info *connectorInfo, uint8_t conn
 				   (ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent != connectorInfo[gun_index].availableSharingCurrent) ||
 				   (ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].presentOutputCurrent != connectorInfo[gun_index].presentOutputCurrent))
 				{
+					switch(connectorInfo[gun_index].connectorType)
+					{
+						case CONNECTOR_TYPE_AC:
+							DEBUG_INFO("Conn-%d gun_%d type: AC signle phase.\n", idx, gun_index);
+							break;
+						case CONNECTOR_TYPE_AC_THREE:
+							DEBUG_INFO("Conn-%d gun_%d type: AC three phase.\n", idx, gun_index);
+							break;
+						case CONNECTOR_TYPE_DC:
+							DEBUG_INFO("Conn-%d gun_%d type: DC.\n", idx, gun_index);
+							break;
+					}
+
 					DEBUG_INFO("Conn-%d gun_%d connected: %s\n", idx, gun_index, (connectorInfo[gun_index].isGunConnected?"Yes":"No"));
 					DEBUG_INFO("Conn-%d gun_%d available current: %d\n", idx, gun_index, connectorInfo[gun_index].availableSharingCurrent);
 					DEBUG_INFO("Conn-%d gun_%d preset output current: %d\n", idx, gun_index, connectorInfo[gun_index].presentOutputCurrent);
 					DEBUG_INFO("==================================\n");
 				}
 
+				ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].connectorType = connectorInfo[gun_index].connectorType;
 				ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].isGunConnected = connectorInfo[gun_index].isGunConnected;
 				ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].presentOutputCurrent = connectorInfo[gun_index].presentOutputCurrent;
 			}
@@ -716,7 +730,7 @@ int conn_getOnHandCurrent(void)
 		{
 			for(uint8_t gun_index=0;gun_index<ShmPowerSharing->Connection_Info[idx].connectorCount;gun_index++)
 			{
-				result += ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent;
+				result += (ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].connectorType == CONNECTOR_TYPE_AC_THREE?ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent*3:ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent);
 			}
 		}
 	}
@@ -844,7 +858,7 @@ int tcpSocketServer(void)
 										for(uint8_t gun_index=0;gun_index<input.buffer[3];gun_index++)
 										{
 											connectorInfo[gun_index].connectorType = input.buffer[4+(gun_index*6)];
-											if(connectorInfo[gun_index].connectorType == CONNECTOR_TYPE_AC)
+											if((connectorInfo[gun_index].connectorType == CONNECTOR_TYPE_AC) || (connectorInfo[gun_index].connectorType == CONNECTOR_TYPE_AC_THREE))
 											{
 												connectorInfo[gun_index].isGunConnected = ((2<=input.buffer[4+(gun_index*6)+1]) && (input.buffer[4+(gun_index*6)+1]<=7)?TRUE:FALSE);
 											}
@@ -1021,7 +1035,7 @@ int tcpSocketClient(void)
 						{
 							uint8_t tempIndex;
 
-							output.buffer[4+(gun_index*6)] = (gunType[gun_index]==GUN_TYPE_AC?CONNECTOR_TYPE_AC:CONNECTOR_TYPE_DC);
+							output.buffer[4+(gun_index*6)] = (gunType[gun_index]==GUN_TYPE_AC?(ShmSysConfigAndInfo->SysConfig.AcPhaseCount==3?CONNECTOR_TYPE_AC_THREE:CONNECTOR_TYPE_AC):CONNECTOR_TYPE_DC);
 
 							switch(gunType[gun_index])
 							{
@@ -1245,7 +1259,7 @@ int balance_check_loop(void)
 					if(ShmPowerSharing->Connection_Info[idx].isSocketConnected &&
 					   ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].isGunConnected)
 					{
-						ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent = (ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].connectorType==CONNECTOR_TYPE_AC?SHARE_MIN_AC:SHARE_MIN_DC);
+						ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent = (ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].connectorType==CONNECTOR_TYPE_DC?SHARE_MIN_DC:SHARE_MIN_AC);
 					}
 					else
 					{
@@ -1275,16 +1289,16 @@ int balance_check_loop(void)
 					{
 						if((ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent-ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].presentOutputCurrent) > 3)
 						{
-							if((ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent - ((ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent-ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].presentOutputCurrent)>>1)) >= (ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].connectorType==CONNECTOR_TYPE_AC?SHARE_MIN_AC:SHARE_MIN_DC))
+							if((ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent - ((ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent-ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].presentOutputCurrent)>>1)) >= (ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].connectorType==CONNECTOR_TYPE_DC?SHARE_MIN_DC:SHARE_MIN_AC))
 								ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent -= (ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent-ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].presentOutputCurrent)>>1;
 							else
-								ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent = (ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].connectorType==CONNECTOR_TYPE_AC?SHARE_MIN_AC:SHARE_MIN_DC);
+								ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent = (ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].connectorType==CONNECTOR_TYPE_DC?SHARE_MIN_DC:SHARE_MIN_AC);
 						}
 						else if((abs(ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].presentOutputCurrent-ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent) <= 1) &&
 								(ShmPowerSharing->onHandCurrent > 0))
 
 						{
-							ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent += ShmPowerSharing->onHandCurrent/(ShmPowerSharing->connectedConnectorQty==0?1:ShmPowerSharing->connectedConnectorQty);
+							ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent += (ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].connectorType==CONNECTOR_TYPE_AC_THREE?(ShmPowerSharing->onHandCurrent/(ShmPowerSharing->connectedConnectorQty==0?1:ShmPowerSharing->connectedConnectorQty))/3:ShmPowerSharing->onHandCurrent/(ShmPowerSharing->connectedConnectorQty==0?1:ShmPowerSharing->connectedConnectorQty));
 						}
 						else
 						{}
@@ -1295,7 +1309,7 @@ int balance_check_loop(void)
 				{
 					if(ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent != 0)
 					{
-						DEBUG_INFO("Dupfd-%d on conn_info-%d update sharing current(A): 0\n", ShmPowerSharing->Connection_Info[idx].socketFd, idx);
+						DEBUG_INFO("Dupfd-%d on conn-%d available current reset to 0A\n", ShmPowerSharing->Connection_Info[idx].socketFd, idx);
 					}
 					ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent = 0;
 				}

+ 1 - 0
EVSE/Modularization/Module_PowerSharing.h

@@ -103,6 +103,7 @@ enum GUN_TYPE
 enum CONNECTOR_TYPE
 {
 	CONNECTOR_TYPE_AC=0,
+	CONNECTOR_TYPE_AC_THREE,
 	CONNECTOR_TYPE_DC
 };
 

+ 8 - 0
EVSE/Modularization/WebService.c

@@ -1071,6 +1071,7 @@ int main(int argc, char *argv[]) {
 			char *OcppSecurityPassword=NULL;
 			char *MaintainServerSecurityPassword=NULL;
 			int isEnableLocalPowerSharging=0;
+			int PowerSharingCapacity=0;
 			char *PowerSharingServerIP=NULL;
 			char *OcppReceiptrURL=NULL;
 			char *MaintainServerURL=NULL;
@@ -1132,6 +1133,10 @@ int main(int argc, char *argv[]) {
 				isEnableLocalPowerSharging = json_object_get_int(val_obj);
 				ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing = isEnableLocalPowerSharging;
 			}
+			if( json_object_object_get_ex(jobj, "PowerSharingCapacity", &val_obj) ) {
+				PowerSharingCapacity = json_object_get_int(val_obj);
+				ShmSysConfigAndInfo->SysConfig.PowerSharingCapacityPower = PowerSharingCapacity;
+			}
 			if( json_object_object_get_ex(jobj, "PowerSharingServerIP", &val_obj) ) {
 				PowerSharingServerIP = (char*)json_object_get_string(val_obj);
 				strcpy((char *)&ShmSysConfigAndInfo->SysConfig.PowerSharingServerIP,PowerSharingServerIP);
@@ -1881,6 +1886,7 @@ int main(int argc, char *argv[]) {
 		struct json_object *MaintainServerSecurityProfile;
 		struct json_object *MaintainServerSecurityPassword;
 		struct json_object *isEnableLocalPowerSharging;
+		struct json_object *PowerSharingCapacity;
 		struct json_object *PowerSharingServerIP;
 		struct json_object *OcppReceiptrURL;
 		struct json_object *MaintainServerURL;
@@ -2568,6 +2574,7 @@ int main(int argc, char *argv[]) {
 		MaintainServerURL = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.MaintainServerURL);
 		if(strcmp(IsDO, "AX") == 0 ){
 			isEnableLocalPowerSharging = json_object_new_int(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing);
+			PowerSharingCapacity = json_object_new_int(ShmSysConfigAndInfo->SysConfig.PowerSharingCapacityPower);
 			PowerSharingServerIP = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.PowerSharingServerIP);
 		}
 		if(strcmp(IsDO, "AX") == 0|| strcmp(IsAcDc, "D") == 0){
@@ -2999,6 +3006,7 @@ int main(int argc, char *argv[]) {
 		json_object_object_add(jobj4,"MaintainServerURL",MaintainServerURL);
 		if(strcmp(IsDO, "AX") == 0){
 			json_object_object_add(jobj4,"isEnableLocalPowerSharging",isEnableLocalPowerSharging);
+			json_object_object_add(jobj4,"PowerSharingCapacity",PowerSharingCapacity);
 			json_object_object_add(jobj4,"PowerSharingServerIP",PowerSharingServerIP);
 		}
 		if(strcmp(IsDO, "AX") == 0 || strcmp(IsAcDc, "D") == 0){

+ 5 - 5
EVSE/Modularization/ocpp20/MessageHandler.c

@@ -19123,13 +19123,13 @@ int httpDownLoadFile(char *location, char *path, char *filename,char *url)
 		system(rmFileCmd);
 	}
 	memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
-	sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120 --no-check-certificate",filename, url);
+	sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --no-check-certificate",filename, url);
 	DEBUG_INFO("Download command: %s\n",ftpbuf);
 
 	systemresult = system(ftpbuf);
 	if(systemresult != 0)
 	{
-		DEBUG_INFO("http DownLoad error!\n");
+		DEBUG_INFO("HTTP/HTTPS download fail!\n");
 		result = FALSE;
 	}
 	system("pkill ping");
@@ -19157,19 +19157,19 @@ int ftpDownLoadFile(char *location, char *user, char *password, int port, char *
 
 	memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
 
-	sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
+	sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120",filename, url);
 	DEBUG_INFO("Download command: %s\n",ftpbuf);
 
 	systemresult = system(ftpbuf);
 	if(systemresult != 0)
 	{
-		sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120 --no-passive-ftp",filename, url);
+		sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --no-passive-ftp",filename, url);
 		DEBUG_INFO("Download command: %s\n",ftpbuf);
 
 		systemresult = system(ftpbuf);
 		if(systemresult != 0)
 		{
-			DEBUG_WARN("wget error!\n");
+			DEBUG_WARN("FTP download fail!\n");
 			result = FALSE;
 		}
 	}

+ 5 - 5
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -20129,13 +20129,13 @@ int httpDownLoadFile(char *location, char *path, char *filename,char *url)
 		system(rmFileCmd);
 	}
 	memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
-	sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120 --no-check-certificate",filename, url);
+	sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --no-check-certificate",filename, url);
 	DEBUG_INFO("Download command: %s\n",ftpbuf);
 
 	systemresult = system(ftpbuf);
 	if(systemresult != 0)
 	{
-		DEBUG_INFO("http DownLoad error!\n");
+		DEBUG_INFO("HTTP/HTTPS downLoad fail!\n");
 		result = FALSE;
 	}
 	system("pkill ping");
@@ -20163,19 +20163,19 @@ int ftpDownLoadFile(char *location, char *user, char *password, int port, char *
 
 	memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
 
-	sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
+	sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120",filename, url);
 	DEBUG_INFO("Download command: %s\n",ftpbuf);
 
 	systemresult = system(ftpbuf);
 	if(systemresult != 0)
 	{
-		sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120 --no-passive-ftp",filename, url);
+		sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --no-passive-ftp",filename, url);
 		DEBUG_INFO("Download command: %s\n",ftpbuf);
 
 		systemresult = system(ftpbuf);
 		if(systemresult != 0)
 		{
-			DEBUG_WARN("wget error!\n");
+			DEBUG_WARN("FTP download fail!\n");
 			result = FALSE;
 		}
 	}

+ 5 - 5
EVSE/Modularization/ocppph/MessageHandler.c

@@ -19408,13 +19408,13 @@ int httpDownLoadFile(char *location, char *path, char *filename,char *url)
 		system(rmFileCmd);
 	}
 	memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
-	sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120 --no-check-certificate",filename, url);
+	sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --no-check-certificate",filename, url);
 	DEBUG_INFO("Download command: %s\n",ftpbuf);
 
 	systemresult = system(ftpbuf);
 	if(systemresult != 0)
 	{
-		DEBUG_INFO("http DownLoad error!\n");
+		DEBUG_INFO("HTTP/HTTPS downLoad fail!\n");
 		result = FALSE;
 	}
 	system("pkill ping");
@@ -19442,19 +19442,19 @@ int ftpDownLoadFile(char *location, char *user, char *password, int port, char *
 
 	memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
 
-	sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
+	sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120",filename, url);
 	DEBUG_INFO("Download command: %s\n",ftpbuf);
 
 	systemresult = system(ftpbuf);
 	if(systemresult != 0)
 	{
-		sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120 --no-passive-ftp",filename, url);
+		sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --no-passive-ftp",filename, url);
 		DEBUG_INFO("Download command: %s\n",ftpbuf);
 
 		systemresult = system(ftpbuf);
 		if(systemresult != 0)
 		{
-			DEBUG_WARN("wget error!\n");
+			DEBUG_WARN("FTP download fail!\n");
 			result = FALSE;
 		}
 	}

+ 1 - 0
EVSE/Projects/AW-CCS/Apps/CCS/CsuComm.c

@@ -2859,6 +2859,7 @@ int CsuCommAC_SHM_Rx_Update()
    ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus=Check_V2G_Flow_Status();
    ShmCharger->gun_info[gun_index].acCcsInfo.EVChargeProgress = ShmCcsData->V2GMessage_ISO15118_2014.PowerDeliveryRequest.ChargeProgress;
    ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty=ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].CpDuty;
+   memcpy(ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID, EVCOMM_SYS_INFO.EVCCID, sizeof(ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID));
     //----------[1] Permission --------
    // ShmInternalComm->ChargingPermission_new = (unsigned char) CSUCOMMAC_SHM.ChargingPermission;
     ShmInternalComm->ChargingPermission_new=ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission;

+ 22 - 9
EVSE/Projects/AW-CCS/Apps/LCM/Module_LcmControl.c

@@ -2,9 +2,9 @@
  * Module_LcmControl.c
  *
  * Created on : 2020-10-20
- * Update on : 2022-03-01
+ * Update on : 2022-04-27
  * Author : Folus Wen, Eason Yang
- * Version : V0.27
+ * Version : V0.28
  *
  */
 
@@ -125,7 +125,7 @@ int Uart1Fd;
 //=======================================
 // Record version and date
 //=======================================
-char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.27", "2022-03-01", "REV.03.00"};
+char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.28", "2022-04-27", "REV.03.00"};
 
 //=======================================
 // Common routine
@@ -586,7 +586,7 @@ void page_charging(uint8_t gun_index, uint8_t system_mode)
 
 void page_complete(uint8_t gun_index, uint8_t system_mode)
 {
-	if((strcmp((char *)&ShmSysConfigAndInfo->SysConfig.OcppReceiptrURL,"") == 0))
+	if((ShmSysConfigAndInfo->SysInfo.OcppConnStatus != ON))
 	{
 		if(getCurrentPage() != SYSTEM_SCREEN_COMPLETE)
 		{
@@ -598,15 +598,28 @@ void page_complete(uint8_t gun_index, uint8_t system_mode)
 	}
 	else
 	{
-		if(getCurrentPage() != SYSTEM_SCREEN_COMPLETE_WITH_QRCODE)
+		if((strcmp((char *)&ShmSysConfigAndInfo->SysConfig.OcppReceiptrURL,"") == 0))
 		{
-			setCurrentPage(SYSTEM_SCREEN_COMPLETE_WITH_QRCODE);
-			setQRCodeReceipt(gun_index);
-			DEBUG_INFO("Setting page to complete with receipt qr code.\n");
+			if(getCurrentPage() != SYSTEM_SCREEN_COMPLETE)
+			{
+				setCurrentPage(SYSTEM_SCREEN_COMPLETE);
+				DEBUG_INFO("Setting page to complete.\n");
+			}
+			else
+			{}
 		}
 		else
 		{
-			setQRCodeReceipt(gun_index);
+			if(getCurrentPage() != SYSTEM_SCREEN_COMPLETE_WITH_QRCODE)
+			{
+				setCurrentPage(SYSTEM_SCREEN_COMPLETE_WITH_QRCODE);
+				setQRCodeReceipt(gun_index);
+				DEBUG_INFO("Setting page to complete with receipt qr code.\n");
+			}
+			else
+			{
+				setQRCodeReceipt(gun_index);
+			}
 		}
 	}
 

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

@@ -286,6 +286,7 @@ int main(void)
 			printf("\n  modelname: EVSE model name.");
 			printf("\n  serialnumber: EVSE serial number.");
 			printf("\n  authentication: Authentication function.");
+			printf("\n  authbyevccid: Authorize by EVCCID.");
 			printf("\n  rfidendian: RFID read endian.");
 			printf("\n **************************************************");
 			printf("\n  Please input operation item: ");
@@ -350,6 +351,23 @@ int main(void)
 				else
 					DEBUG_INFO("Authentication: Enable\n");
 			}
+			else if(strcmp(cmd, "authbyevccid") == 0)
+                        {
+                                memset(cmd, 0x00, ARRAY_SIZE(cmd));
+                                printf("\n ***** authbyevccid *******************************");
+                                printf("\n  Current mode: %d", ShmSysConfigAndInfo->SysConfig.isAuthrizeByEVCCID);
+                                printf("\n  0: Disable.");
+                                printf("\n  1: Enable.");
+                                printf("\n **************************************************");
+                                printf("\n  Please input authorize by EVCCID configuration value: ");
+                                scanf("%s", &cmd[0]);
+
+                                ShmSysConfigAndInfo->SysConfig.isAuthrizeByEVCCID = ((0<=atoi(cmd))&&(atoi(cmd)<=1)?atoi(cmd):0);
+                                if(!ShmSysConfigAndInfo->SysConfig.isAuthrizeByEVCCID)
+                                        DEBUG_INFO("Authotize by EVCCID: Disable\n");
+                                else
+                                        DEBUG_INFO("Authorize by EVCCID: Enable\n");
+                        }
 			else if(strcmp(cmd, "rfidendian") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));

+ 410 - 393
EVSE/Projects/AW-CCS/Apps/Module_InternalComm.c

@@ -1927,6 +1927,415 @@ int main(void)
 		DEBUG_INFO("ttyS1 port open success.\n");
 	}
 
+	if(fork() == 0)
+	{
+		for(;;)
+		{
+			for(int gun_index=0;gun_index<AC_QUANTITY;gun_index++)
+			{
+				//==========================================================
+				// High priority polling log print out
+				//==========================================================
+				//==================================================
+				// Case 1: Config primary MCU LED
+				//==================================================
+				if((previousCharger.gun_info[gun_index].primaryMcuLed.mode != ShmCharger->gun_info[gun_index].primaryMcuLed.mode) ||
+				   (previousCharger.gun_info[gun_index].primaryMcuLed.alarm_code != ShmCharger->gun_info[gun_index].primaryMcuLed.alarm_code))
+				{
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("***** High priority polling : Case 1 ******\n");
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("MCU-%d set Led mode : %d\n",gun_index, ShmCharger->gun_info[gun_index].primaryMcuLed.mode);
+					DEBUG_INFO("MCU-%d set Alarm code : %x\n",gun_index, ShmCharger->gun_info[gun_index].primaryMcuLed.alarm_code);
+
+					previousCharger.gun_info[gun_index].primaryMcuLed.mode = ShmCharger->gun_info[gun_index].primaryMcuLed.mode;
+					previousCharger.gun_info[gun_index].primaryMcuLed.alarm_code = ShmCharger->gun_info[gun_index].primaryMcuLed.alarm_code;
+				}
+
+				//==================================================
+				// Case 2: Config primary Legacy request
+				//==================================================
+				if(previousCharger.gun_info[gun_index].legacyRequest.isLegacyRequest != ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest)
+				{
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("***** High priority polling : Case 2 ******\n");
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("MCU-%d set relay request : %d\n", gun_index, ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest);
+
+					previousCharger.gun_info[gun_index].legacyRequest.isLegacyRequest = ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest;
+				}
+
+				//==================================================
+				// Case 3: Query primary MCU status
+				//==================================================
+				if((previousCharger.gun_info[gun_index].primaryMcuState.cp_state != ShmCharger->gun_info[gun_index].primaryMcuState.cp_state) ||
+				   (previousCharger.gun_info[gun_index].primaryMcuState.current_limit != ShmCharger->gun_info[gun_index].primaryMcuState.current_limit) ||
+				   (previousCharger.gun_info[gun_index].primaryMcuState.relay_state != ShmCharger->gun_info[gun_index].primaryMcuState.relay_state) ||
+				   (previousCharger.gun_info[gun_index].primaryMcuState.rotatory_switch != ShmCharger->gun_info[gun_index].primaryMcuState.rotatory_switch) ||
+				   (previousCharger.gun_info[gun_index].primaryMcuState.socket_e.isSocketEMode != ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEMode) ||
+				   (previousCharger.gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn != ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn))
+				{
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("***** High priority polling : Case 3 ******\n");
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("MCU-%d get Pilot State : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.cp_state);
+					DEBUG_INFO("MCU-%d get Pilot Duty : %.2f\n", gun_index, (float)ShmCharger->gun_info[gun_index].primaryMcuState.current_limit);
+					DEBUG_INFO("MCU-%d get Pilot Voltage Positive : %.2f\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.cp_voltage_positive);
+					DEBUG_INFO("MCU-%d get Pilot Voltage Negative : %.2f\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.cp_voltage_negtive);
+
+					if(ShmCharger->gun_info[gun_index].primaryMcuState.relay_state == ON)
+					{
+						if(ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn == ON)
+							DEBUG_INFO("Relay on mode : CHARGING_MODE_SOCKETE. \n");
+						else
+							DEBUG_INFO("Relay on mode : CHARGING_MODE_BS / CHARGING_MODE_HLC. \n");
+					}
+
+					DEBUG_INFO("MCU-%d get Relay State : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.relay_state);
+					DEBUG_INFO("MCU-%d get Rating Current : %.2f\n", gun_index, (float)ShmCharger->gun_info[gun_index].primaryMcuState.rating_current);
+					DEBUG_INFO("MCU-%d get Rotary switch : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.rotatory_switch);
+					DEBUG_INFO("MCU-%d get is on Socket-E mode : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEMode);
+					DEBUG_INFO("MCU-%d get Socket-E detect pin : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn);
+					DEBUG_INFO("MCU-%d get Locker State : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.locker_state);
+					DEBUG_INFO("MCU-%d get Shutter State : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.shutter_state);
+					DEBUG_INFO("MCU-%d get Meter State : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.meter_state);
+					DEBUG_INFO("MCU-%d get PP State : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.pp_state);
+
+					previousCharger.gun_info[gun_index].primaryMcuState.cp_state = ShmCharger->gun_info[gun_index].primaryMcuState.cp_state;
+					previousCharger.gun_info[gun_index].primaryMcuState.current_limit = ShmCharger->gun_info[gun_index].primaryMcuState.current_limit;
+					previousCharger.gun_info[gun_index].primaryMcuState.rotatory_switch = ShmCharger->gun_info[gun_index].primaryMcuState.rotatory_switch;
+					previousCharger.gun_info[gun_index].primaryMcuState.relay_state = ShmCharger->gun_info[gun_index].primaryMcuState.relay_state;
+					previousCharger.gun_info[gun_index].primaryMcuState.socket_e.isSocketEMode = ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEMode;
+					previousCharger.gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn = ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn;
+				}
+
+				//==================================================
+				// Case 4: Query primary MCU Alarm code
+				//==================================================
+				if((previousCharger.gun_info[gun_index].primaryMcuAlarm.InputAlarmCode != ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode))
+				{
+					if((ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode>0))
+					{
+						DEBUG_INFO("*******************************************\n");
+						DEBUG_INFO("***** High priority polling : Case 4 ******\n");
+						DEBUG_INFO("*******************************************\n");
+						DEBUG_INFO("MCU-%d get OVP_L1 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OVP_L1);
+						DEBUG_INFO("MCU-%d get UVP_L1 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.UVP_L1);
+						DEBUG_INFO("MCU-%d get OCP_L1 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OCP_L1);
+						if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
+						{
+							DEBUG_INFO("MCU-%d get OVP_L2 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OVP_L2);
+							DEBUG_INFO("MCU-%d get UVP_L2 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.UVP_L2);
+							DEBUG_INFO("MCU-%d get OCP_L2 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OCP_L2);
+							DEBUG_INFO("MCU-%d get OVP_L3 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OVP_L3);
+							DEBUG_INFO("MCU-%d get UVP_L3 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.UVP_L3);
+							DEBUG_INFO("MCU-%d get OCP_L3 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OCP_L3);
+						}
+						DEBUG_INFO("MCU-%d get OTP : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OTP);
+						DEBUG_INFO("MCU-%d get gmi_fault : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.gmi_fault);
+						DEBUG_INFO("MCU-%d get cp_fault : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.cp_fault);
+						DEBUG_INFO("MCU-%d get ac_leak : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.ac_leak);
+						DEBUG_INFO("MCU-%d get dc_leak : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.dc_leak);
+						DEBUG_INFO("MCU-%d get mcu_selftest_fail : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.mcu_selftest_fail);
+						DEBUG_INFO("MCU-%d get handshaking_timeout : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.handshaking_timeout);
+						DEBUG_INFO("MCU-%d get emergency_stop : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.emergency_stop);
+						DEBUG_INFO("MCU-%d get relay_welding : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.relay_welding);
+						DEBUG_INFO("MCU-%d get leak_module_fail : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.leak_module_fail);
+						DEBUG_INFO("MCU-%d get shutter_fault : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.shutter_fault);
+						DEBUG_INFO("MCU-%d get locker_fault : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.locker_fault);
+						DEBUG_INFO("MCU-%d get power_drop : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.power_drop);
+						DEBUG_INFO("MCU-%d get rotate_switch_fault : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.rotate_switch_fault);
+						DEBUG_INFO("MCU-%d get short_circuit_L1 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.short_circuit_L1);
+						if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
+						{
+							DEBUG_INFO("MCU-%d get short_circuit_L2 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.short_circuit_L2);
+							DEBUG_INFO("MCU-%d get short_circuit_L3 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.short_circuit_L3);
+						}
+						DEBUG_INFO("MCU-%d get relay_drive_fault : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.relay_drive_fault);
+						DEBUG_INFO("MCU-%d get meter_comm_timeout : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.meter_comm_timeout);
+						DEBUG_INFO("MCU-%d get meter_ic_comm_timeout : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.meter_ic_comm_timeout);
+						DEBUG_INFO("MCU-%d get pilot_negative_error : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.pilot_negative_error);
+						DEBUG_INFO("MCU-%d get InputAlarmCode : %x\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode);
+					}
+
+					previousCharger.gun_info[gun_index].primaryMcuAlarm.InputAlarmCode = ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode;
+				}
+
+				//==================================================
+				// Case 5: Query primary MCU BLE config
+				//==================================================
+				/*
+				if((previousCharger.gun_info[gun_index].bleConfigData.isLogin != ShmCharger->gun_info[gun_index].bleConfigData.isLogin) ||
+				   (previousCharger.gun_info[gun_index].bleConfigData.isRequestStart != ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart) ||
+				   (previousCharger.gun_info[gun_index].bleConfigData.isRequestStop != ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop))
+				{
+					if(ShmCharger->gun_info[gun_index].bleConfigData.isLogin == ON)
+					{
+						DEBUG_INFO("*******************************************\n");
+						DEBUG_INFO("***** High priority polling : Case 5 ******\n");
+						DEBUG_INFO("*******************************************\n");
+						DEBUG_INFO("MCU-%d get isUserLogin : %d\n", gun_index, ShmCharger->gun_info[gun_index].bleConfigData.isLogin);
+						DEBUG_INFO("MCU-%d get isRequestStartCharger : %d\n", gun_index, ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart);
+						DEBUG_INFO("MCU-%d get isRequestStopCharger : %d\n", gun_index, ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop);
+					}
+
+					previousCharger.gun_info[gun_index].bleConfigData.isLogin = ShmCharger->gun_info[gun_index].bleConfigData.isLogin;
+					previousCharger.gun_info[gun_index].bleConfigData.isRequestStart = ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart;
+					previousCharger.gun_info[gun_index].bleConfigData.isRequestStop = ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop;
+				}
+				*/
+
+				//==================================================
+				// Case 6: Query primary MCU ble login id
+				//==================================================
+				/*
+				if((strcmp((char *)&previousCharger.gun_info[gun_index].bleLoginCentralId.id,(char *)&ShmCharger->gun_info[gun_index].bleLoginCentralId.id) != 0))
+				{
+					if(strcmp((char *)&ShmCharger->gun_info[gun_index].bleLoginCentralId.id,"") != 0)
+					{
+						DEBUG_INFO("*******************************************\n");
+						DEBUG_INFO("***** High priority polling : Case 6 ******\n");
+						DEBUG_INFO("*******************************************\n");
+						DEBUG_INFO("MCU-%d get ble central id : %s\n", gun_index, ShmCharger->gun_info[gun_index].bleLoginCentralId.id);
+					}
+
+					memcpy(&previousCharger.gun_info[gun_index].bleLoginCentralId.id, ShmCharger->gun_info[gun_index].bleLoginCentralId.id, ARRAY_SIZE(ShmCharger->gun_info[gun_index].bleLoginCentralId.id));
+				}
+				*/
+
+				//==================================================
+				// Case 8: Config primary MCU duty
+				//==================================================
+				if(previousCharger.gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current != ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current)
+				{
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("***** High priority polling : Case 8 ******\n");
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("MCU-%d set cp pwn duty : %d\n",gun_index, ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current);
+
+					previousCharger.gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current;
+				}
+
+				//==================================================
+				// Case 10: Query primary MCU power consumption
+				//==================================================
+				if((previousCharger.gun_info[gun_index].powerConsumptionTotal.power_consumption != ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption) ||
+				   (previousCharger.gun_info[gun_index].powerConsumption[0].power_consumption != ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption) ||
+				   (previousCharger.gun_info[gun_index].powerConsumption[1].power_consumption != ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption) ||
+				   (previousCharger.gun_info[gun_index].powerConsumption[2].power_consumption != ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption))
+				{
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("***** High priority polling : Case 10 *****\n");
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("MCU-%d get total power consumption : %f kWh\n",gun_index, ((float)ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption/10000.0));
+					DEBUG_INFO("MCU-%d get L1N_L12 power consumption : %f kWh\n",gun_index, ((float)ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption/10000.0));
+					if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
+					{
+						DEBUG_INFO("MCU-%d get L2N_L23 power consumption : %f kWh\n",gun_index, ((float)ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption/10000.0));
+						DEBUG_INFO("MCU-%d get L3N_L31 power consumption : %f kWh\n",gun_index, ((float)ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption/10000.0));
+					}
+
+					previousCharger.gun_info[gun_index].powerConsumptionTotal.power_consumption = ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption;
+					previousCharger.gun_info[gun_index].powerConsumption[0].power_consumption = ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption;
+					previousCharger.gun_info[gun_index].powerConsumption[1].power_consumption = ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption;
+					previousCharger.gun_info[gun_index].powerConsumption[2].power_consumption = ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption;
+				}
+
+				//==================================================
+				// Case 11: Query primary Out put current config
+				//==================================================
+				if(((int)previousCharger.gun_info[gun_index].outputCurrent.L1N_L12[0] != (int)ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0]) ||
+				   ((int)previousCharger.gun_info[gun_index].outputCurrent.L2N_L23[0] != (int)ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0]) ||
+				   ((int)previousCharger.gun_info[gun_index].outputCurrent.L3N_L31[0] != (int)ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0]))
+				{
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("***** High priority polling : Case 11 *****\n");
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("MCU-%d get output current L1: %f\n", gun_index, (float)ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0]);
+					if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
+					{
+						DEBUG_INFO("MCU-%d get output current L2: %f\n", gun_index, (float)ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0]);
+						DEBUG_INFO("MCU-%d get output current L3: %f\n", gun_index, (float)ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0]);
+					}
+
+					previousCharger.gun_info[gun_index].outputCurrent.L1N_L12[0] = ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0];
+					previousCharger.gun_info[gun_index].outputCurrent.L2N_L23[0] = ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0];
+					previousCharger.gun_info[gun_index].outputCurrent.L3N_L31[0] = ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0];
+				}
+
+				//==========================================================
+				// Low priority polling log print out
+				//==========================================================
+				//==================================================
+				// Case 1: Query primary In put voltage
+				//==================================================
+				if(((int)previousCharger.gun_info[gun_index].inputVoltage.L1N_L12 != (int)ShmCharger->gun_info[gun_index].inputVoltage.L1N_L12) ||
+				   ((int)previousCharger.gun_info[gun_index].inputVoltage.L2N_L23 != (int)ShmCharger->gun_info[gun_index].inputVoltage.L2N_L23) ||
+				   ((int)previousCharger.gun_info[gun_index].inputVoltage.L3N_L31 != (int)ShmCharger->gun_info[gun_index].inputVoltage.L3N_L31))
+				{
+					DEBUG_INFO("===========================================\n");
+					DEBUG_INFO("==== Normal priority polling : Case 1 =====\n");
+					DEBUG_INFO("===========================================\n");
+					DEBUG_INFO("MCU-%d get Input voltage L1: %.2f\n", gun_index, (float)ShmCharger->gun_info[gun_index].inputVoltage.L1N_L12);
+					DEBUG_INFO("MCU-%d get PresentChargingVoltage L1: %.2f\n", gun_index, (float)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingVoltage);
+
+					if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
+					{
+						DEBUG_INFO("MCU-%d get Input voltage L2: %f\n", gun_index, (float)ShmCharger->gun_info[gun_index].inputVoltage.L2N_L23);
+						DEBUG_INFO("MCU-%d get PresentChargingVoltage L2: %.2f\n", gun_index, (float)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingVoltageL2);
+						DEBUG_INFO("MCU-%d get Input voltage L3: %f\n", gun_index, (float)ShmCharger->gun_info[gun_index].inputVoltage.L3N_L31);
+						DEBUG_INFO("MCU-%d get PresentChargingVoltage L3: %.2f\n", gun_index, (float)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingVoltageL3);
+					}
+
+					previousCharger.gun_info[gun_index].inputVoltage.L1N_L12 = ShmCharger->gun_info[gun_index].inputVoltage.L1N_L12;
+					previousCharger.gun_info[gun_index].inputVoltage.L2N_L23 = ShmCharger->gun_info[gun_index].inputVoltage.L2N_L23;
+					previousCharger.gun_info[gun_index].inputVoltage.L3N_L31 = ShmCharger->gun_info[gun_index].inputVoltage.L3N_L31;
+				}
+
+				//==================================================
+				// Case 5: Query primary plug in times
+				//==================================================
+				if(previousCharger.gun_info[gun_index].gunPluginTimes.GunPluginTimes != ShmCharger->gun_info[gun_index].gunPluginTimes.GunPluginTimes)
+				{
+					DEBUG_INFO("===========================================\n");
+					DEBUG_INFO("==== Normal priority polling : Case 5 =====\n");
+					DEBUG_INFO("===========================================\n");
+					DEBUG_INFO("MCU-%d get gun plugin times : %ld\n", gun_index, (long)ShmCharger->gun_info[gun_index].gunPluginTimes.GunPluginTimes);
+
+					previousCharger.gun_info[gun_index].gunPluginTimes.GunPluginTimes = ShmCharger->gun_info[gun_index].gunPluginTimes.GunPluginTimes;
+				}
+
+				//==================================================
+				// Case 7: Query primary temperature
+				//==================================================
+				if(previousCharger.gun_info[gun_index].temperature.point[0] != ShmCharger->gun_info[gun_index].temperature.point[0])
+				{
+					DEBUG_INFO("===========================================\n");
+					DEBUG_INFO("==== Normal priority polling : Case 7 =====\n");
+					DEBUG_INFO("===========================================\n");
+					DEBUG_INFO("MCU-%d get temperature : %d\n", gun_index, ShmCharger->gun_info[gun_index].temperature.point[0]);
+
+					previousCharger.gun_info[gun_index].temperature.point[0] = ShmCharger->gun_info[gun_index].temperature.point[0];
+				}
+
+				//==================================================
+				// Case 11: Config primary RTC time
+				//==================================================
+				if(previousCharger.gun_info[gun_index].rtc.min != ShmCharger->gun_info[gun_index].rtc.min)
+				{
+					DEBUG_INFO("===========================================\n");
+					DEBUG_INFO("==== Normal priority polling : Case 11 ====\n");
+					DEBUG_INFO("===========================================\n");
+					if(ShmCharger->gun_info[gun_index].bleConfigData.isLogin && !ShmOCPP16Data->OcppConnStatus)
+					{
+						DEBUG_INFO("Sync from MCU-%d rtc OK...%04d-%02d-%02d %02d:%02d:%02d\n", gun_index,
+																										  ShmCharger->gun_info[gun_index].rtc.year,
+																										  ShmCharger->gun_info[gun_index].rtc.month,
+																										  ShmCharger->gun_info[gun_index].rtc.day,
+																										  ShmCharger->gun_info[gun_index].rtc.hour,
+																										  ShmCharger->gun_info[gun_index].rtc.min,
+																										  ShmCharger->gun_info[gun_index].rtc.sec);
+					}
+					else
+					{
+						DEBUG_INFO("MCU-%d set rtc OK...%04d-%02d-%02d %02d:%02d:%02d\n", gun_index,
+																									ShmCharger->gun_info[gun_index].rtc.year,
+																									ShmCharger->gun_info[gun_index].rtc.month,
+																									ShmCharger->gun_info[gun_index].rtc.day,
+																									ShmCharger->gun_info[gun_index].rtc.hour,
+																									ShmCharger->gun_info[gun_index].rtc.min,
+																									ShmCharger->gun_info[gun_index].rtc.sec);
+					}
+					
+					previousCharger.gun_info[gun_index].rtc.min = ShmCharger->gun_info[gun_index].rtc.min;
+				}
+
+				//==================================================
+				// Case 15: Config led breathe timing
+				//==================================================
+				if((previousCharger.gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Authed_Fade_In != ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Authed_Fade_In) ||
+				   (previousCharger.gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Authed_Fade_Out != ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Authed_Fade_Out) ||
+				   (previousCharger.gun_info[gun_index].setBreatheLedTiming.Set_Led_Action_Chaging_Fade_In != ShmCharger->gun_info[gun_index].setBreatheLedTiming.Set_Led_Action_Chaging_Fade_In) ||
+				   (previousCharger.gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Chaging_Fade_Out != ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Chaging_Fade_Out) ||
+				   (previousCharger.gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Connected_Fade_In != ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Connected_Fade_In) ||
+				   (previousCharger.gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Connected_Fade_Out != ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Connected_Fade_Out))
+				{
+					if(ShmCharger->gun_info[gun_index].isSetBreatheLedTiming == ON)
+					{
+						DEBUG_INFO("===========================================\n");
+						DEBUG_INFO("==== Normal priority polling : Case 15 ====\n");
+						DEBUG_INFO("===========================================\n");
+						DEBUG_INFO("MCU-%d set breathe led timing : Authed Fade in [%ld].\n", gun_index, (long)ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Authed_Fade_In);
+						DEBUG_INFO("MCU-%d set breathe led timing : Authed Fade out [%ld].\n", gun_index, (long)ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Authed_Fade_Out);
+						DEBUG_INFO("MCU-%d set breathe led timing : Charging Fade in [%ld].\n", gun_index, (long)ShmCharger->gun_info[gun_index].setBreatheLedTiming.Set_Led_Action_Chaging_Fade_In);
+						DEBUG_INFO("MCU-%d set breathe led timing : Charging Fade out [%ld].\n", gun_index, (long)ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Chaging_Fade_Out);
+						DEBUG_INFO("MCU-%d set breathe led timing : Connected Fade in [%ld].\n", gun_index, (long)ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Connected_Fade_In);
+						DEBUG_INFO("MCU-%d set breathe led timing : Connected Fade out [%ld].\n", gun_index, (long)ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Connected_Fade_Out);
+					}
+
+					previousCharger.gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Authed_Fade_In = ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Authed_Fade_In;
+					previousCharger.gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Authed_Fade_Out = ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Authed_Fade_Out;
+					previousCharger.gun_info[gun_index].setBreatheLedTiming.Set_Led_Action_Chaging_Fade_In = ShmCharger->gun_info[gun_index].setBreatheLedTiming.Set_Led_Action_Chaging_Fade_In;
+					previousCharger.gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Chaging_Fade_Out = ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Chaging_Fade_Out;
+					previousCharger.gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Connected_Fade_In = ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Connected_Fade_In;
+					previousCharger.gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Connected_Fade_Out = ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Connected_Fade_Out;
+				}
+
+				//==================================================
+				// Case 17: Config led brightness
+				//==================================================
+				if((previousCharger.gun_info[gun_index].setLedBrightness.sector_1 != ShmCharger->gun_info[gun_index].setLedBrightness.sector_1) ||
+				   (previousCharger.gun_info[gun_index].setLedBrightness.sector_2 != ShmCharger->gun_info[gun_index].setLedBrightness.sector_2) ||
+				   (previousCharger.gun_info[gun_index].setLedBrightness.sector_3 != ShmCharger->gun_info[gun_index].setLedBrightness.sector_3) ||
+				   (previousCharger.gun_info[gun_index].setLedBrightness.sector_4 != ShmCharger->gun_info[gun_index].setLedBrightness.sector_4) ||
+				   (previousCharger.gun_info[gun_index].setLedBrightness.sector_5 != ShmCharger->gun_info[gun_index].setLedBrightness.sector_5) ||
+				   (previousCharger.gun_info[gun_index].setLedBrightness.sector_6 != ShmCharger->gun_info[gun_index].setLedBrightness.sector_6) ||
+				   (previousCharger.gun_info[gun_index].setLedBrightness.sector_7 != ShmCharger->gun_info[gun_index].setLedBrightness.sector_7) ||
+				   (previousCharger.gun_info[gun_index].setLedBrightness.sector_8 != ShmCharger->gun_info[gun_index].setLedBrightness.sector_8) ||
+				   (previousCharger.gun_info[gun_index].setLedBrightness.sector_9 != ShmCharger->gun_info[gun_index].setLedBrightness.sector_9) ||
+				   (previousCharger.gun_info[gun_index].setLedBrightness.sector_10 != ShmCharger->gun_info[gun_index].setLedBrightness.sector_10) ||
+				   (previousCharger.gun_info[gun_index].setLedBrightness.sector_11 != ShmCharger->gun_info[gun_index].setLedBrightness.sector_11) ||
+				   (previousCharger.gun_info[gun_index].setLedBrightness.sector_12 != ShmCharger->gun_info[gun_index].setLedBrightness.sector_12))
+				{
+					if(ShmCharger->gun_info[gun_index].isSetLedBrightness == ON)
+					{
+						DEBUG_INFO("===========================================\n");
+						DEBUG_INFO("==== Normal priority polling : Case 17 ====\n");
+						DEBUG_INFO("===========================================\n");
+						DEBUG_INFO("MCU-%d set led brightness Sector 01 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_1);
+						DEBUG_INFO("MCU-%d set led brightness Sector 02 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_2);
+						DEBUG_INFO("MCU-%d set led brightness Sector 03 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_3);
+						DEBUG_INFO("MCU-%d set led brightness Sector 04 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_4);
+						DEBUG_INFO("MCU-%d set led brightness Sector 05 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_5);
+						DEBUG_INFO("MCU-%d set led brightness Sector 06 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_6);
+						DEBUG_INFO("MCU-%d set led brightness Sector 07 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_7);
+						DEBUG_INFO("MCU-%d set led brightness Sector 08 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_8);
+						DEBUG_INFO("MCU-%d set led brightness Sector 09 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_9);
+						DEBUG_INFO("MCU-%d set led brightness Sector 10 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_10);
+						DEBUG_INFO("MCU-%d set led brightness Sector 11 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_11);
+						DEBUG_INFO("MCU-%d set led brightness Sector 12 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_12);
+					}
+
+					previousCharger.gun_info[gun_index].setLedBrightness.sector_1 = ShmCharger->gun_info[gun_index].setLedBrightness.sector_1;
+					previousCharger.gun_info[gun_index].setLedBrightness.sector_2 = ShmCharger->gun_info[gun_index].setLedBrightness.sector_2;
+					previousCharger.gun_info[gun_index].setLedBrightness.sector_3 = ShmCharger->gun_info[gun_index].setLedBrightness.sector_3;
+					previousCharger.gun_info[gun_index].setLedBrightness.sector_4 = ShmCharger->gun_info[gun_index].setLedBrightness.sector_4;
+					previousCharger.gun_info[gun_index].setLedBrightness.sector_5 = ShmCharger->gun_info[gun_index].setLedBrightness.sector_5;
+					previousCharger.gun_info[gun_index].setLedBrightness.sector_6 = ShmCharger->gun_info[gun_index].setLedBrightness.sector_6;
+					previousCharger.gun_info[gun_index].setLedBrightness.sector_7 = ShmCharger->gun_info[gun_index].setLedBrightness.sector_7;
+					previousCharger.gun_info[gun_index].setLedBrightness.sector_8 = ShmCharger->gun_info[gun_index].setLedBrightness.sector_8;
+					previousCharger.gun_info[gun_index].setLedBrightness.sector_9 = ShmCharger->gun_info[gun_index].setLedBrightness.sector_9;
+					previousCharger.gun_info[gun_index].setLedBrightness.sector_10 = ShmCharger->gun_info[gun_index].setLedBrightness.sector_10;
+					previousCharger.gun_info[gun_index].setLedBrightness.sector_11 = ShmCharger->gun_info[gun_index].setLedBrightness.sector_11;
+					previousCharger.gun_info[gun_index].setLedBrightness.sector_12 = ShmCharger->gun_info[gun_index].setLedBrightness.sector_12;
+				}
+			}
+			usleep(100000);
+		}
+
+		exit(0);
+	}
+
 	for(;;)
 	{
 		for(int gun_index=0;gun_index<AC_QUANTITY;gun_index++)
@@ -2161,7 +2570,7 @@ int main(void)
 				//===============================
 				if(ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty == ON)
 				{
-					DEBUG_WARN("Case 8 : Config primary set CP PWN duty...%d\n", ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty);
+					//DEBUG_WARN("Case 8 : Config primary set CP PWN duty...%d\n", ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty);
 					if(Config_AC_MaxCurrent_And_CpPwmDuty(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1), &ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty))
 					{
 						failCount[gun_index] = 0;
@@ -2241,227 +2650,6 @@ int main(void)
 					else
 						failCount[gun_index] = FAIL_SPEC_COMM;
 				}
-
-				//==========================================================
-				// High priority polling log print out
-				//==========================================================
-				if((current_timestamp() - tsPrintLog[PRIORITY_HIGH]) > (ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest?3000:6000))
-				{
-					tsPrintLog[PRIORITY_HIGH] = current_timestamp();
-
-					//===============================
-					// Config primary MCU LED
-					//===============================
-					if((previousCharger.gun_info[gun_index].primaryMcuLed.mode != ShmCharger->gun_info[gun_index].primaryMcuLed.mode) ||
-					   (previousCharger.gun_info[gun_index].primaryMcuLed.alarm_code != ShmCharger->gun_info[gun_index].primaryMcuLed.alarm_code))
-					{
-						DEBUG_INFO("*******************************************\n");
-						DEBUG_INFO("***** High priority polling : Case 1 ******\n");
-						DEBUG_INFO("*******************************************\n");
-						DEBUG_INFO("MCU-%d set Led mode : %d\n",gun_index, ShmCharger->gun_info[gun_index].primaryMcuLed.mode);
-						DEBUG_INFO("MCU-%d set Alarm code : %x\n",gun_index, ShmCharger->gun_info[gun_index].primaryMcuLed.alarm_code);
-
-						previousCharger.gun_info[gun_index].primaryMcuLed.mode = ShmCharger->gun_info[gun_index].primaryMcuLed.mode;
-						previousCharger.gun_info[gun_index].primaryMcuLed.alarm_code = ShmCharger->gun_info[gun_index].primaryMcuLed.alarm_code;
-					}
-
-					//===============================
-					// Config primary Legacy request
-					//===============================
-					if(previousCharger.gun_info[gun_index].legacyRequest.isLegacyRequest != ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest)
-					{
-						DEBUG_INFO("*******************************************\n");
-						DEBUG_INFO("***** High priority polling : Case 2 ******\n");
-						DEBUG_INFO("*******************************************\n");
-						DEBUG_INFO("MCU-%d set relay request : %d\n", gun_index, ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest);
-
-						previousCharger.gun_info[gun_index].legacyRequest.isLegacyRequest = ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest;
-					}
-
-					//===============================
-					// Query primary MCU status
-					//===============================
-					if((previousCharger.gun_info[gun_index].primaryMcuState.cp_state != ShmCharger->gun_info[gun_index].primaryMcuState.cp_state) ||
-					   (previousCharger.gun_info[gun_index].primaryMcuState.current_limit != ShmCharger->gun_info[gun_index].primaryMcuState.current_limit) ||
-					   (previousCharger.gun_info[gun_index].primaryMcuState.relay_state != ShmCharger->gun_info[gun_index].primaryMcuState.relay_state) ||
-					   (previousCharger.gun_info[gun_index].primaryMcuState.socket_e.isSocketEMode != ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEMode) ||
-					   (previousCharger.gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn != ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn))
-					{
-						DEBUG_INFO("*******************************************\n");
-						DEBUG_INFO("***** High priority polling : Case 3 ******\n");
-						DEBUG_INFO("*******************************************\n");
-						DEBUG_INFO("MCU-%d get Pilot State : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.cp_state);
-						DEBUG_INFO("MCU-%d get Pilot Duty : %.2f\n", gun_index, (float)ShmCharger->gun_info[gun_index].primaryMcuState.current_limit);
-						DEBUG_INFO("MCU-%d get Pilot Voltage Positive : %.2f\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.cp_voltage_positive);
-						DEBUG_INFO("MCU-%d get Pilot Voltage Negative : %.2f\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.cp_voltage_negtive);
-
-						if(ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn == ON)
-							DEBUG_INFO("Relay on mode : CHARGING_MODE_SOCKETE. \n");
-						else
-							DEBUG_INFO("Relay on mode : CHARGING_MODE_BS / CHARGING_MODE_HLC. \n");
-
-						DEBUG_INFO("MCU-%d get Relay State : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.relay_state);
-						DEBUG_INFO("MCU-%d get Rating Current : %.2f\n", gun_index, (float)ShmCharger->gun_info[gun_index].primaryMcuState.rating_current);
-						DEBUG_INFO("MCU-%d get Rotary switch : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.rotatory_switch);
-						DEBUG_INFO("MCU-%d get is on Socket-E mode : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEMode);
-						DEBUG_INFO("MCU-%d get Socket-E detect pin : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn);
-						DEBUG_INFO("MCU-%d get Locker State : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.locker_state);
-						DEBUG_INFO("MCU-%d get Shutter State : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.shutter_state);
-						DEBUG_INFO("MCU-%d get Meter State : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.meter_state);
-						DEBUG_INFO("MCU-%d get PP State : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.pp_state);
-
-						//===============================
-						// Query primary MCU power consumption
-						//===============================
-						DEBUG_INFO("*******************************************\n");
-						DEBUG_INFO("***** High priority polling : Case 10 *****\n");
-						DEBUG_INFO("*******************************************\n");
-						DEBUG_INFO("MCU-%d get total power consumption : %f kWh\n",gun_index, ((float)ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption/10000.0));
-						DEBUG_INFO("MCU-%d get L1N_L12 power consumption : %f kWh\n",gun_index, ((float)ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption/10000.0));
-						if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
-						{
-							DEBUG_INFO("MCU-%d get L2N_L23 power consumption : %f kWh\n",gun_index, ((float)ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption/10000.0));
-							DEBUG_INFO("MCU-%d get L3N_L31 power consumption : %f kWh\n",gun_index, ((float)ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption/10000.0));
-						}
-
-						previousCharger.gun_info[gun_index].primaryMcuState.cp_state = ShmCharger->gun_info[gun_index].primaryMcuState.cp_state;
-						previousCharger.gun_info[gun_index].primaryMcuState.current_limit = ShmCharger->gun_info[gun_index].primaryMcuState.current_limit;
-						previousCharger.gun_info[gun_index].primaryMcuState.relay_state = ShmCharger->gun_info[gun_index].primaryMcuState.relay_state;
-						previousCharger.gun_info[gun_index].primaryMcuState.socket_e.isSocketEMode = ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEMode;
-						previousCharger.gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn = ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn;
-					}
-
-					//===============================
-					// Query primary MCU Alarm code
-					//===============================
-					if((previousCharger.gun_info[gun_index].primaryMcuAlarm.InputAlarmCode != ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode))
-					{
-						if((ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode>0))
-						{
-							DEBUG_INFO("*******************************************\n");
-							DEBUG_INFO("***** High priority polling : Case 4 ******\n");
-							DEBUG_INFO("*******************************************\n");
-							DEBUG_INFO("MCU-%d get OVP_L1 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OVP_L1);
-							DEBUG_INFO("MCU-%d get UVP_L1 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.UVP_L1);
-							DEBUG_INFO("MCU-%d get OCP_L1 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OCP_L1);
-							if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
-							{
-								DEBUG_INFO("MCU-%d get OVP_L2 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OVP_L2);
-								DEBUG_INFO("MCU-%d get UVP_L2 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.UVP_L2);
-								DEBUG_INFO("MCU-%d get OCP_L2 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OCP_L2);
-								DEBUG_INFO("MCU-%d get OVP_L3 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OVP_L3);
-								DEBUG_INFO("MCU-%d get UVP_L3 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.UVP_L3);
-								DEBUG_INFO("MCU-%d get OCP_L3 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OCP_L3);
-							}
-							DEBUG_INFO("MCU-%d get OTP : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OTP);
-							DEBUG_INFO("MCU-%d get gmi_fault : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.gmi_fault);
-							DEBUG_INFO("MCU-%d get cp_fault : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.cp_fault);
-							DEBUG_INFO("MCU-%d get ac_leak : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.ac_leak);
-							DEBUG_INFO("MCU-%d get dc_leak : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.dc_leak);
-							DEBUG_INFO("MCU-%d get mcu_selftest_fail : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.mcu_selftest_fail);
-							DEBUG_INFO("MCU-%d get handshaking_timeout : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.handshaking_timeout);
-							DEBUG_INFO("MCU-%d get emergency_stop : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.emergency_stop);
-							DEBUG_INFO("MCU-%d get relay_welding : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.relay_welding);
-							DEBUG_INFO("MCU-%d get leak_module_fail : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.leak_module_fail);
-							DEBUG_INFO("MCU-%d get shutter_fault : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.shutter_fault);
-							DEBUG_INFO("MCU-%d get locker_fault : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.locker_fault);
-							DEBUG_INFO("MCU-%d get power_drop : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.power_drop);
-							DEBUG_INFO("MCU-%d get rotate_switch_fault : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.rotate_switch_fault);
-							DEBUG_INFO("MCU-%d get short_circuit_L1 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.short_circuit_L1);
-							if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
-							{
-								DEBUG_INFO("MCU-%d get short_circuit_L2 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.short_circuit_L2);
-								DEBUG_INFO("MCU-%d get short_circuit_L3 : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.short_circuit_L3);
-							}
-							DEBUG_INFO("MCU-%d get relay_drive_fault : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.relay_drive_fault);
-							DEBUG_INFO("MCU-%d get meter_comm_timeout : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.meter_comm_timeout);
-							DEBUG_INFO("MCU-%d get meter_ic_comm_timeout : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.meter_ic_comm_timeout);
-							DEBUG_INFO("MCU-%d get pilot_negative_error : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.pilot_negative_error);
-							DEBUG_INFO("MCU-%d get InputAlarmCode : %x\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode);
-						}
-
-						DEBUG_INFO("===========================================\n");
-						DEBUG_INFO("==== Normal priority polling : Case 1 =====\n");
-						DEBUG_INFO("===========================================\n");
-						DEBUG_INFO("MCU-%d get Input voltage L1: %.2f\n", gun_index, (float)ShmCharger->gun_info[gun_index].inputVoltage.L1N_L12);
-						DEBUG_INFO("MCU-%d get PresentChargingVoltage L1: %.2f\n", gun_index, (float)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingVoltage);
-						if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
-						{
-							DEBUG_INFO("MCU-%d get Input voltage L2: %f\n", gun_index, (float)ShmCharger->gun_info[gun_index].inputVoltage.L2N_L23);
-							DEBUG_INFO("MCU-%d get PresentChargingVoltage L2: %.2f\n", gun_index, (float)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingVoltageL2);
-							DEBUG_INFO("MCU-%d get Input voltage L3: %f\n", gun_index, (float)ShmCharger->gun_info[gun_index].inputVoltage.L3N_L31);
-							DEBUG_INFO("MCU-%d get PresentChargingVoltage L3: %.2f\n", gun_index, (float)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingVoltageL3);
-						}
-
-						previousCharger.gun_info[gun_index].primaryMcuAlarm.InputAlarmCode = ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode;
-					}
-
-					//===============================
-					// Query primary Out put current config
-					//===============================
-					/*
-					if((previousCharger.gun_info[gun_index].outputCurrent.L1N_L12[0] != ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0]) ||
-					   (previousCharger.gun_info[gun_index].outputCurrent.L2N_L23[0] != ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0]) ||
-					   (previousCharger.gun_info[gun_index].outputCurrent.L3N_L31[0] != ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0]))
-					{
-						DEBUG_INFO("===========================================\n");
-						DEBUG_INFO("===== High priority polling : Case 11 =====\n");
-						DEBUG_INFO("===========================================\n");
-						DEBUG_INFO("MCU-%d get output current L1: %f\n", gun_index, (float)ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0]);
-						if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
-						{
-							DEBUG_INFO("MCU-%d get output current L2: %f\n", gun_index, (float)ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0]);
-							DEBUG_INFO("MCU-%d get output current L3: %f\n", gun_index, (float)ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0]);
-						}
-
-						previousCharger.gun_info[gun_index].outputCurrent.L1N_L12[0] = ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0];
-						previousCharger.gun_info[gun_index].outputCurrent.L2N_L23[0] = ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0];
-						previousCharger.gun_info[gun_index].outputCurrent.L3N_L31[0] = ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0];
-					}
-					*/
-
-					//===============================
-					// Query primary MCU BLE config
-					//===============================
-					/*
-					if((previousCharger.gun_info[gun_index].bleConfigData.isLogin != ShmCharger->gun_info[gun_index].bleConfigData.isLogin) ||
-					   (previousCharger.gun_info[gun_index].bleConfigData.isRequestStart != ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart) ||
-					   (previousCharger.gun_info[gun_index].bleConfigData.isRequestStop != ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop))
-					{
-						if(ShmCharger->gun_info[gun_index].bleConfigData.isLogin == ON)
-						{
-							DEBUG_INFO("*******************************************\n");
-							DEBUG_INFO("***** High priority polling : Case 5 ******\n");
-							DEBUG_INFO("*******************************************\n");
-							DEBUG_INFO("MCU-%d get isUserLogin : %d\n", gun_index, ShmCharger->gun_info[gun_index].bleConfigData.isLogin);
-							DEBUG_INFO("MCU-%d get isRequestStartCharger : %d\n", gun_index, ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart);
-							DEBUG_INFO("MCU-%d get isRequestStopCharger : %d\n", gun_index, ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop);
-						}
-
-						previousCharger.gun_info[gun_index].bleConfigData.isLogin = ShmCharger->gun_info[gun_index].bleConfigData.isLogin;
-						previousCharger.gun_info[gun_index].bleConfigData.isRequestStart = ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart;
-						previousCharger.gun_info[gun_index].bleConfigData.isRequestStop = ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop;
-					}
-					*/
-
-					//===============================
-					// Query primary MCU ble login id
-					//===============================
-					/*
-					if((strcmp((char *)&previousCharger.gun_info[gun_index].bleLoginCentralId.id,(char *)&ShmCharger->gun_info[gun_index].bleLoginCentralId.id) != 0))
-					{
-						if(strcmp((char *)&ShmCharger->gun_info[gun_index].bleLoginCentralId.id,"") != 0)
-						{
-							DEBUG_INFO("*******************************************\n");
-							DEBUG_INFO("***** High priority polling : Case 6 ******\n");
-							DEBUG_INFO("*******************************************\n");
-							DEBUG_INFO("MCU-%d get ble central id : %s\n", gun_index, ShmCharger->gun_info[gun_index].bleLoginCentralId.id);
-						}
-
-						memcpy(&previousCharger.gun_info[gun_index].bleLoginCentralId.id, ShmCharger->gun_info[gun_index].bleLoginCentralId.id, ARRAY_SIZE(ShmCharger->gun_info[gun_index].bleLoginCentralId.id));
-					}
-					*/
-				}
 			}
 			else
 			{
@@ -2857,177 +3045,6 @@ int main(void)
 						stepIndex = 0;
 						break;
 				}
-
-				//==========================================================
-				// Low priority polling log print out
-				//==========================================================
-				if((current_timestamp() - tsPrintLog[PRIORITY_LOW]) > (ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest?3000:6000))
-				{
-					tsPrintLog[PRIORITY_LOW] = current_timestamp();
-
-					switch(logIndex)
-					{
-						case 1:
-							if((previousCharger.gun_info[gun_index].outputCurrent.L1N_L12[0] != ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0]) ||
-							   (previousCharger.gun_info[gun_index].outputCurrent.L2N_L23[0] != ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0]) ||
-							   (previousCharger.gun_info[gun_index].outputCurrent.L3N_L31[0] != ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0]))
-							{
-								DEBUG_INFO("*******************************************\n");
-								DEBUG_INFO("************* Output Current **************\n");
-								DEBUG_INFO("*******************************************\n");
-								DEBUG_INFO("MCU-%d get output current L1: %f\n", gun_index, (float)ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0]);
-								if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
-								{
-									DEBUG_INFO("MCU-%d get output current L2: %f\n", gun_index, (float)ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0]);
-									DEBUG_INFO("MCU-%d get output current L3: %f\n", gun_index, (float)ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0]);
-								}
-
-								DEBUG_INFO("*******************************************\n");
-								DEBUG_INFO("************ Power Consumption ************\n");
-								DEBUG_INFO("*******************************************\n");
-								DEBUG_INFO("MCU-%d get total power consumption : %f kWh\n",gun_index, ((float)ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption/10000.0));
-								DEBUG_INFO("MCU-%d get L1N_L12 power consumption : %f kWh\n",gun_index, ((float)ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption/10000.0));
-								if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
-								{
-									DEBUG_INFO("MCU-%d get L2N_L23 power consumption : %f kWh\n",gun_index, ((float)ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption/10000.0));
-									DEBUG_INFO("MCU-%d get L3N_L31 power consumption : %f kWh\n",gun_index, ((float)ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption/10000.0));
-								}
-
-								previousCharger.gun_info[gun_index].outputCurrent.L1N_L12[0] = ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0];
-								previousCharger.gun_info[gun_index].outputCurrent.L2N_L23[0] = ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0];
-								previousCharger.gun_info[gun_index].outputCurrent.L3N_L31[0] = ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0];
-							}
-
-							break;
-						case 2:
-							if(previousCharger.gun_info[gun_index].gunPluginTimes.GunPluginTimes != ShmCharger->gun_info[gun_index].gunPluginTimes.GunPluginTimes)
-							{
-								DEBUG_INFO("===========================================\n");
-								DEBUG_INFO("==== Normal priority polling : Case 5 =====\n");
-								DEBUG_INFO("===========================================\n");
-								DEBUG_INFO("MCU-%d get gun plugin times : %ld\n", gun_index, (long)ShmCharger->gun_info[gun_index].gunPluginTimes.GunPluginTimes);
-
-								previousCharger.gun_info[gun_index].gunPluginTimes.GunPluginTimes = ShmCharger->gun_info[gun_index].gunPluginTimes.GunPluginTimes;
-							}
-
-							break;
-						case 3:
-							if(previousCharger.gun_info[gun_index].temperature.point[0] != ShmCharger->gun_info[gun_index].temperature.point[0])
-							{
-								DEBUG_INFO("===========================================\n");
-								DEBUG_INFO("==== Normal priority polling : Case 7 =====\n");
-								DEBUG_INFO("===========================================\n");
-								DEBUG_INFO("MCU-%d get temperature : %d\n", gun_index, ShmCharger->gun_info[gun_index].temperature.point[0]);
-
-								previousCharger.gun_info[gun_index].temperature.point[0] = ShmCharger->gun_info[gun_index].temperature.point[0];
-							}
-
-							break;
-						case 4:
-							if(previousCharger.gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current != ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current)
-							{
-								DEBUG_INFO("===========================================\n");
-								DEBUG_INFO("==== Normal priority polling : Case 9 =====\n");
-								DEBUG_INFO("===========================================\n");
-								DEBUG_INFO("MCU-%d set cp pwn duty : %d\n",gun_index, ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current);
-
-								previousCharger.gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current;
-							}
-
-							break;
-						case 5:
-							DEBUG_INFO("===========================================\n");
-							DEBUG_INFO("==== Normal priority polling : Case 11 ====\n");
-							DEBUG_INFO("===========================================\n");
-							if(ShmCharger->gun_info[gun_index].bleConfigData.isLogin && !ShmOCPP16Data->OcppConnStatus)
-							{
-								DEBUG_INFO("Sync from MCU-%d rtc OK...%04d-%02d-%02d %02d:%02d:%02d\n", gun_index,
-																												  ShmCharger->gun_info[gun_index].rtc.year,
-																												  ShmCharger->gun_info[gun_index].rtc.month,
-																												  ShmCharger->gun_info[gun_index].rtc.day,
-																												  ShmCharger->gun_info[gun_index].rtc.hour,
-																												  ShmCharger->gun_info[gun_index].rtc.min,
-																												  ShmCharger->gun_info[gun_index].rtc.sec);
-							}
-							else
-							{
-								DEBUG_INFO("MCU-%d set rtc OK...%04d-%02d-%02d %02d:%02d:%02d\n", gun_index,
-																											ShmCharger->gun_info[gun_index].rtc.year,
-																											ShmCharger->gun_info[gun_index].rtc.month,
-																											ShmCharger->gun_info[gun_index].rtc.day,
-																											ShmCharger->gun_info[gun_index].rtc.hour,
-																											ShmCharger->gun_info[gun_index].rtc.min,
-																											ShmCharger->gun_info[gun_index].rtc.sec);
-							}
-							break;
-						case 6:
-							break;
-						case 7:
-							if(ShmCharger->gun_info[gun_index].isSetBreatheLedTiming == ON)
-							{
-								DEBUG_INFO("===========================================\n");
-								DEBUG_INFO("==== Normal priority polling : Case 15 ====\n");
-								DEBUG_INFO("===========================================\n");
-								DEBUG_INFO("MCU-%d set breathe led timing : Authed Fade in [%ld].\n", gun_index, (long)ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Authed_Fade_In);
-								DEBUG_INFO("MCU-%d set breathe led timing : Authed Fade out [%ld].\n", gun_index, (long)ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Authed_Fade_Out);
-								DEBUG_INFO("MCU-%d set breathe led timing : Charging Fade in [%ld].\n", gun_index, (long)ShmCharger->gun_info[gun_index].setBreatheLedTiming.Set_Led_Action_Chaging_Fade_In);
-								DEBUG_INFO("MCU-%d set breathe led timing : Charging Fade out [%ld].\n", gun_index, (long)ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Chaging_Fade_Out);
-								DEBUG_INFO("MCU-%d set breathe led timing : Connected Fade in [%ld].\n", gun_index, (long)ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Connected_Fade_In);
-								DEBUG_INFO("MCU-%d set breathe led timing : Connected Fade out [%ld].\n", gun_index, (long)ShmCharger->gun_info[gun_index].setBreatheLedTiming.set_Led_Action_Connected_Fade_Out);
-							}
-							break;
-						case 8:
-							if(ShmCharger->gun_info[gun_index].isSetLedBrightness == ON)
-							{
-								DEBUG_INFO("===========================================\n");
-								DEBUG_INFO("==== Normal priority polling : Case 17 ====\n");
-								DEBUG_INFO("===========================================\n");
-								DEBUG_INFO("MCU-%d set led brightness Sector 01 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_1);
-								DEBUG_INFO("MCU-%d set led brightness Sector 02 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_2);
-								DEBUG_INFO("MCU-%d set led brightness Sector 03 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_3);
-								DEBUG_INFO("MCU-%d set led brightness Sector 04 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_4);
-								DEBUG_INFO("MCU-%d set led brightness Sector 05 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_5);
-								DEBUG_INFO("MCU-%d set led brightness Sector 06 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_6);
-								DEBUG_INFO("MCU-%d set led brightness Sector 07 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_7);
-								DEBUG_INFO("MCU-%d set led brightness Sector 08 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_8);
-								DEBUG_INFO("MCU-%d set led brightness Sector 09 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_9);
-								DEBUG_INFO("MCU-%d set led brightness Sector 10 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_10);
-								DEBUG_INFO("MCU-%d set led brightness Sector 11 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_11);
-								DEBUG_INFO("MCU-%d set led brightness Sector 12 : [%x].\n", gun_index, ShmCharger->gun_info[gun_index].setLedBrightness.sector_12);
-							}
-							break;
-						default:
-							/*
-							if((previousCharger.gun_info[gun_index].inputVoltage.L1N_L12 != ShmCharger->gun_info[gun_index].inputVoltage.L1N_L12) ||
-							   (previousCharger.gun_info[gun_index].inputVoltage.L2N_L23 != ShmCharger->gun_info[gun_index].inputVoltage.L2N_L23) ||
-							   (previousCharger.gun_info[gun_index].inputVoltage.L3N_L31 != ShmCharger->gun_info[gun_index].inputVoltage.L3N_L31))
-							{
-								DEBUG_INFO("===========================================\n");
-								DEBUG_INFO("==== Normal priority polling : Case 1 =====\n");
-								DEBUG_INFO("===========================================\n");
-								DEBUG_INFO("MCU-%d get Input voltage L1: %.2f\n", gun_index, (float)ShmCharger->gun_info[gun_index].inputVoltage.L1N_L12);
-								DEBUG_INFO("MCU-%d get PresentChargingVoltage L1: %.2f\n", gun_index, (float)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingVoltage);
-
-								if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
-								{
-									DEBUG_INFO("MCU-%d get Input voltage L2: %f\n", gun_index, (float)ShmCharger->gun_info[gun_index].inputVoltage.L2N_L23);
-									DEBUG_INFO("MCU-%d get PresentChargingVoltage L2: %.2f\n", gun_index, (float)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingVoltageL2);
-									DEBUG_INFO("MCU-%d get Input voltage L3: %f\n", gun_index, (float)ShmCharger->gun_info[gun_index].inputVoltage.L3N_L31);
-									DEBUG_INFO("MCU-%d get PresentChargingVoltage L3: %.2f\n", gun_index, (float)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingVoltageL3);
-								}
-
-								previousCharger.gun_info[gun_index].inputVoltage.L1N_L12 = ShmCharger->gun_info[gun_index].inputVoltage.L1N_L12;
-								previousCharger.gun_info[gun_index].inputVoltage.L2N_L23 = ShmCharger->gun_info[gun_index].inputVoltage.L2N_L23;
-								previousCharger.gun_info[gun_index].inputVoltage.L3N_L31 = ShmCharger->gun_info[gun_index].inputVoltage.L3N_L31;
-							}
-							*/
-
-							logIndex = 0;
-							break;
-					}
-
-					logIndex++;
-				}
 			}
 			stepIndex++;
 

+ 120 - 63
EVSE/Projects/AW-CCS/Apps/main.c

@@ -34,7 +34,7 @@
 #define TIMEOUT_SPEC_POWERSAVING_METER			120
 #define TIMEOUT_SPEC_POWERSAVING_LED_STATUS		120
 #define TIMEOUT_SPEC_CEHCK_POWER_CONSUMPTION	15
-#define TIMEOUT_SPEC_RESET_WIFI_MODULE			180
+#define TIMEOUT_SPEC_RESET_WIFI_MODULE			300
 
 //==========================
 // GPIO constant define
@@ -44,7 +44,7 @@
 #define GPIO_OUT_RST_QCA				115
 #define GPIO_OUT_RST_ETH				56
 #define GPIO_IN_WAKEUP					63
-#define GPIO_OUT_RST_PWR				59
+#define GPIO_OUT_RST_4G_WIFI			59
 
 #define MtdBlockSize 					0x300000
 
@@ -64,6 +64,7 @@ int GetCardSerialNumber();
 void setLedMotion(unsigned char gun_index,unsigned char led_mode);
 void setRequest(unsigned char gun_index,unsigned char isOn);
 void setSpeaker(unsigned char isOn, unsigned char speaker_mode);
+void gpio_set_value(unsigned int gpio, unsigned int value);
 
 //==========================
 // Declare RFID module type
@@ -459,6 +460,31 @@ int getEth0MacAddress()
 	return result;
 }
 
+int isUap0up(void)
+{
+	int result = FAIL;
+
+	FILE *fp;
+	char cmd[256];
+	char buf[512];
+
+	strcpy(cmd, "ifconfig uap0");;
+	fp = popen(cmd, "r");
+	if(fp != NULL)
+	{
+		while(fgets(buf, sizeof(buf), fp) != NULL)
+		{
+			if(strstr(buf, "uap0") > 0)
+			{
+				result = PASS;
+			}
+		}
+	}
+	pclose(fp);
+
+	return result;
+}
+
 //======================================================
 // OCPP routine
 //======================================================
@@ -2422,6 +2448,11 @@ void InitEthernet()
 	char tmpbuf[256];
 	unsigned int natInterface = 0;
 
+	// Detele bridge interface
+	system("/sbin/ifconfig uap0 down");
+	system("/sbin/ifconfig br0 down");
+	system("/usr/sbin/brctl delbr br0");
+
 	//Init Eth0 for internet
 	memset(tmpbuf,0,256);
 	sprintf(tmpbuf,"/sbin/ifconfig eth0 %s netmask %s up &",
@@ -2631,52 +2662,28 @@ void InitEthernet()
 				}
 			}
 
-			// Reset wifi function
-			if((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 1))
-			{
-				if((!ShmSysConfigAndInfo->SysInfo.OcppConnStatus) &&
-				   (ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi == ON) &&
-				   (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApDisconnectViaWiFi == ON))
-				{
-					if((getDiffSecNow(startTime[0][TMR_IDX_RESET_WIFI]) > TIMEOUT_SPEC_RESET_WIFI_MODULE))
-					{
-						DEBUG_INFO("Wifi [Station] mode: Reset wifi power. \n");
-						DEBUG_INFO("The wifi interface may not be found. \n");
+			// Check is need to reset WIFI/4G module power
+			if(!ShmSysConfigAndInfo->SysInfo.OcppConnStatus &&
 
-						system("echo 1 > /sys/class/gpio/gpio59/value");
-						sleep(3);
-						system("echo 0 > /sys/class/gpio/gpio59/value");
+			   ((system("pidof -s Module_Wifi > /dev/null") != 0) ||
+				(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 0) ||
+				((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 1) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi == ON)) ||
+				((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApDisconnectViaWiFi == ON))) &&
 
-						refreshStartTimer(&startTime[0][TMR_IDX_RESET_WIFI]);
-					}
-					else
-					{}
-				}
-				else
-				{
-					refreshStartTimer(&startTime[0][TMR_IDX_RESET_WIFI]);
-				}
-			}
-			else if((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2))
+			   ((system("pidof -s Module_4g > /dev/null") != 0) ||
+				(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == 0) ||
+				((ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == 1) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApnDisconnectVia4Gi == ON))))
 			{
-				if((ShmStatusCodeData->InfoCode.InfoEvents.bits.ApDisconnectViaWiFi == ON))
+				if(getDiffSecNow(startTime[0][TMR_IDX_RESET_WIFI]) > TIMEOUT_SPEC_RESET_WIFI_MODULE)
 				{
-					if((getDiffSecNow(startTime[0][TMR_IDX_RESET_WIFI]) > TIMEOUT_SPEC_RESET_WIFI_MODULE))
+					if((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode != 0) || (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled != 0))
 					{
-						DEBUG_INFO("Wifi [Access Point] mode: reset wifi power. \n");
-						DEBUG_INFO("The wifi interface may not be found. \n");
-
-						system("echo 1 > /sys/class/gpio/gpio59/value");
+						DEBUG_WARN("WIFI/4G module reset.\n");
+						gpio_set_value(GPIO_OUT_RST_4G_WIFI, ON);
 						sleep(3);
-						system("echo 0 > /sys/class/gpio/gpio59/value");
-
-						refreshStartTimer(&startTime[0][TMR_IDX_RESET_WIFI]);
+						gpio_set_value(GPIO_OUT_RST_4G_WIFI, OFF);
 					}
-					else
-					{}
-				}
-				else
-				{
+
 					refreshStartTimer(&startTime[0][TMR_IDX_RESET_WIFI]);
 				}
 			}
@@ -2685,6 +2692,25 @@ void InitEthernet()
 				refreshStartTimer(&startTime[0][TMR_IDX_RESET_WIFI]);
 			}
 
+			// Bridge ethernet to uap0 to get dynamic ip address
+			if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing &&
+			  (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2) &&
+			  (isUap0up() == PASS) &&
+			  (access("/sys/class/net/br0/address", F_OK) == -1))
+			{
+				sleep(10);
+				system("/usr/sbin/brctl addbr br0");
+				system("/usr/sbin/brctl addif br0 eth0");
+				system("/usr/sbin/brctl addif br0 uap0");
+				system("/sbin/ifconfig br0 192.168.10.200 up");
+				system("/bin/sed -i '/interface/d' /etc/udhcpd.conf");
+				system("/bin/echo 'interface	br0' >> /etc/udhcpd.conf");
+				system("kill udhcpd");
+				system("/usr/sbin/udhcpd /etc/udhcpd.conf");
+
+				DEBUG_INFO("Bridge uap0 & eth0 for local power sharing by ethernet.\n");
+			}
+
 			sleep(5);
 		}
 	}
@@ -4055,7 +4081,7 @@ void checkTask()
 		system("/root/Module_EventLogging &");
 	}
 
-	if((strcmp((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") != 0) && !ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing)
+	if((strcmp((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") != 0))
 	{
 		if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 		{
@@ -4093,7 +4119,7 @@ void checkTask()
 		}
 	}
 
-	if((strcmp((char *)&ShmSysConfigAndInfo->SysConfig.MaintainServerURL,"") != 0) && !ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing)
+	if((strcmp((char *)&ShmSysConfigAndInfo->SysConfig.MaintainServerURL,"") != 0))
 	{
 		if(system("pidof -s OcppBackendPH > /dev/null") != 0)
 		{
@@ -4482,6 +4508,20 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
 		}
 	}
 
+	// Charging session target current check if OCPP disconnect and power sharing server connected
+	if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing > 0)
+	{
+		if(ShmSysConfigAndInfo->SysInfo.localSharingInfo.isConnectedSharingServer)
+		   ShmCharger->gun_info[gun_index].targetCurrent = ShmSysConfigAndInfo->SysInfo.localSharingInfo.AvailableShargingCurrent[gun_index]>ShmCharger->gun_info[gun_index].primaryMcuState.rating_current?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmSysConfigAndInfo->SysInfo.localSharingInfo.AvailableShargingCurrent[gun_index];
+		else
+		{
+			if(ShmCharger->gun_info[gun_index].targetCurrent != 0)
+				DEBUG_WARN("Disconnect from power sharing server, target current set to 0.\n");
+
+			ShmCharger->gun_info[gun_index].targetCurrent = 0;
+		}
+	}
+
 	switch(system_mode)
 	{
 		case SYS_MODE_IDLE:
@@ -5220,6 +5260,23 @@ int main(void)
 			}
 		}
 
+		//==============================================
+		// Check Local Power Sharing Communication
+		//==============================================
+		if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing > 0)
+		{
+			if(ShmSysConfigAndInfo->SysInfo.localSharingInfo.isConnectedSharingServer)
+			{
+				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError == ON)
+					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError = OFF;
+			}
+			else
+			{
+				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError == OFF)
+					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError = ON;
+			}
+		}
+
 		//==============================================
 		// Connector loop
 		//==============================================
@@ -5532,14 +5589,11 @@ int main(void)
 						ShmCharger->gun_info[gun_index].isSleepOn = NO;
 
 						// If Web Server OPCC URL is empty kill Module_OcppBackend
-						if((strcmp((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") == 0) || ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing)
+						if((strcmp((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") == 0))
 						{
 							if(strcmp((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") == 0)
 								DEBUG_INFO("URL is empty kill Module_OcppBackend...\n");
 
-							if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing)
-								DEBUG_INFO("Local power sharing enable kill Module_OcppBackend...\n");
-
 							system ("pkill OcppBackend");
 						}
 
@@ -5590,6 +5644,7 @@ int main(void)
 						ShmCharger->gun_info[gun_index].resultAuthorization = DEFAULT_RFID;
 						//if(ShmCharger->isCcsEnable)system("pkill Module_CCS");
 						DB_Check_Record_Buf(localDb, gun_index);
+						ShmCharger->gun_info[gun_index].isEmergencyStopReport = OFF;
 
 						// Default previousData every time
 						previousData[gun_index].primaryMcuCp_Pwn_Duty = 0;
@@ -6311,20 +6366,6 @@ int main(void)
 						// Checking profile id > 0 and current time is between charging profile validFrom & validTo
 						checkChargingProfileLimit(gun_index, ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus);
 
-						// Charging session target current check if OCPP disconnect and power sharing server connected
-						if(!ocpp_get_connection_status() && ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing)
-						{
-							if(ShmSysConfigAndInfo->SysInfo.localSharingInfo.isConnectedSharingServer)
-								ShmCharger->gun_info[gun_index].targetCurrent = ShmSysConfigAndInfo->SysInfo.localSharingInfo.AvailableShargingCurrent;
-							else
-							{
-								if(ShmCharger->gun_info[gun_index].targetCurrent != 0)
-									DEBUG_WARN("Disconnect from power sharing server, target current set to 0.\n");
-
-								ShmCharger->gun_info[gun_index].targetCurrent = 0;
-							}
-						}
-
 						// Charging session local limit condition check
 						if(ocpp_get_connection_status())
 						{
@@ -6687,10 +6728,26 @@ int main(void)
 					else
 					{}
 
+					/*
+					 * 	TODO:
+					 * 	1. Customize emergency stop and report stop transaction then return to idle mode if error recover.
+					 * 	2. Customer: Bambang
+					 */
+					if(((ShmSysConfigAndInfo->SysConfig.ModelName[12] == 'B') && (ShmSysConfigAndInfo->SysConfig.ModelName[13] == 'B')) &&
+					   (ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode == ALARM_EMERGENCY_STOP))
+					{
+						if(((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_TERMINATING)) &&
+							!ShmCharger->gun_info[gun_index].isEmergencyStopReport)
+						{
+							checkStopReason(gun_index);
+							ShmCharger->gun_info[gun_index].isEmergencyStopReport = ON;
+						}
+					}
+
 					if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode == 0) && !ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CCSboardStestFail)
 					{
-						if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_CHARGING) ||
-						   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_TERMINATING))
+						if(((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_TERMINATING)) &&
+						   (!ShmCharger->gun_info[gun_index].isEmergencyStopReport))
 						{
 							setChargerMode(gun_index, ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus);
 						}

+ 17 - 16
EVSE/Projects/AW-CCS/Apps/main.h

@@ -745,22 +745,23 @@ typedef struct GUN_INFO
 	MeterIcCorrection								meterIcCorrectionStatus;
 	uint8_t											isGunUnpluggedBefore;
 
-	uint16_t										isAuthPassEnd:1;
-	uint16_t										rfidReq:1;
-	uint16_t										isGunPlugged:1;
-	uint16_t										isSetBreatheLedTiming:1;
-	uint16_t										isSetLedBrightness:1;
-	uint16_t										isUnlockerConnetor:1;
-	uint16_t										isOperactive:1;
-	uint16_t										isCCSWaitChangeDuty:1;
-	uint16_t										isCCSStartTransation:1;
-	uint16_t										isEvReady2StateE:1;
-	uint16_t										isDoEvReadyOnce:1;
-	uint16_t										isChargerStopByCondition:1;
-	uint16_t										isMeterOn:1;
-	uint16_t										isSleepOn:1;
-	uint16_t										isCheckPowerConsumption:1;
-	uint16_t										isHandshakeTimerRefresh:1;
+	uint32_t										isAuthPassEnd:1;
+	uint32_t										rfidReq:1;
+	uint32_t										isGunPlugged:1;
+	uint32_t										isSetBreatheLedTiming:1;
+	uint32_t										isSetLedBrightness:1;
+	uint32_t										isUnlockerConnetor:1;
+	uint32_t										isOperactive:1;
+	uint32_t										isCCSWaitChangeDuty:1;
+	uint32_t										isCCSStartTransation:1;
+	uint32_t										isEvReady2StateE:1;
+	uint32_t										isDoEvReadyOnce:1;
+	uint32_t										isChargerStopByCondition:1;
+	uint32_t										isMeterOn:1;
+	uint32_t										isSleepOn:1;
+	uint32_t										isCheckPowerConsumption:1;
+	uint32_t										isHandshakeTimerRefresh:1;
+	uint32_t										isEmergencyStopReport:1;
 }Gun_Info;
 
 struct Charger

+ 2 - 6
EVSE/Projects/AW-Regular/Apps/Module_InternalComm.c

@@ -1825,8 +1825,6 @@ int main(void)
 				//===============================
 				if((previous_gun_info[gun_index].primaryMcuState.cp_state != ShmCharger->gun_info[gun_index].primaryMcuState.cp_state) ||
 				   (previous_gun_info[gun_index].primaryMcuState.current_limit != ShmCharger->gun_info[gun_index].primaryMcuState.current_limit) ||
-				   (previous_gun_info[gun_index].primaryMcuState.cp_voltage_positive != ShmCharger->gun_info[gun_index].primaryMcuState.cp_voltage_positive) ||
-				   (previous_gun_info[gun_index].primaryMcuState.cp_voltage_negtive != ShmCharger->gun_info[gun_index].primaryMcuState.cp_voltage_negtive) ||
 				   (previous_gun_info[gun_index].primaryMcuState.relay_state != ShmCharger->gun_info[gun_index].primaryMcuState.relay_state) ||
 				   (previous_gun_info[gun_index].primaryMcuState.rating_current != ShmCharger->gun_info[gun_index].primaryMcuState.rating_current) ||
 				   (previous_gun_info[gun_index].primaryMcuState.rotatory_switch != ShmCharger->gun_info[gun_index].primaryMcuState.rotatory_switch))
@@ -1851,8 +1849,6 @@ int main(void)
 
 					previous_gun_info[gun_index].primaryMcuState.cp_state = ShmCharger->gun_info[gun_index].primaryMcuState.cp_state;
 				    previous_gun_info[gun_index].primaryMcuState.current_limit = ShmCharger->gun_info[gun_index].primaryMcuState.current_limit;
-				    previous_gun_info[gun_index].primaryMcuState.cp_voltage_positive = ShmCharger->gun_info[gun_index].primaryMcuState.cp_voltage_positive;
-				    previous_gun_info[gun_index].primaryMcuState.cp_voltage_negtive = ShmCharger->gun_info[gun_index].primaryMcuState.cp_voltage_negtive;
 				    previous_gun_info[gun_index].primaryMcuState.relay_state = ShmCharger->gun_info[gun_index].primaryMcuState.relay_state;
 				    previous_gun_info[gun_index].primaryMcuState.rating_current = ShmCharger->gun_info[gun_index].primaryMcuState.rating_current;
 				    previous_gun_info[gun_index].primaryMcuState.rotatory_switch = ShmCharger->gun_info[gun_index].primaryMcuState.rotatory_switch;
@@ -1893,7 +1889,7 @@ int main(void)
 				//===============================
 				// Query present output current
 				//===============================
-				if(previous_gun_info[gun_index].outputCurrent.L1N_L12[0] != ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0])
+				if((int)previous_gun_info[gun_index].outputCurrent.L1N_L12[0] != (int)ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0])
 				{
 					DEBUG_INFO("**************************************************\n");
 					DEBUG_INFO("********* High priority polling : Case 5 *********\n");
@@ -1947,7 +1943,7 @@ int main(void)
 				//==========================================================
 				// Low priority polling log print out
 				//==========================================================
-				if(previous_gun_info[gun_index].inputVoltage.L1N_L12 != ShmCharger->gun_info[gun_index].inputVoltage.L1N_L12)
+				if((int)previous_gun_info[gun_index].inputVoltage.L1N_L12 != (int)ShmCharger->gun_info[gun_index].inputVoltage.L1N_L12)
 				{
 					DEBUG_INFO("==================================================\n");
 					DEBUG_INFO("======== Normal priority polling : Case 1 ========\n");

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

@@ -2213,10 +2213,14 @@ void InitEthernet()
 			{
 				if(DiffTimebWithNow(startTime[0][TMR_IDX_RESET_4G_WIFI_POWER]) > TIMEOUT_SPEC_RESET_4G_WIFI_POWER)
 				{
-					DEBUG_WARN("WIFI/4G module reset.\n");
-					system("echo 1 > /sys/class/gpio/gpio110/value");
-					sleep(3);
-					system("echo 0 > /sys/class/gpio/gpio110/value");
+					if((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode != 0) || (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled != 0))
+					{
+						DEBUG_WARN("WIFI/4G module reset.\n");
+						system("echo 1 > /sys/class/gpio/gpio110/value");
+						sleep(3);
+						system("echo 0 > /sys/class/gpio/gpio110/value");
+					}
+
 					ftime(&startTime[0][TMR_IDX_RESET_4G_WIFI_POWER]);
 				}
 			}
@@ -2468,7 +2472,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, "V0.70.00.0000.00");
+	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "V0.71.00.0000.00");
 
 	// Get AC connector type from model name
 	for(uint8_t idx=0;idx<3;idx++)

+ 1 - 0
EVSE/Projects/AX80/Apps/CCS/CsuComm.c

@@ -2859,6 +2859,7 @@ int CsuCommAC_SHM_Rx_Update()
    ShmDispenser->gun_info.acCcsInfo.PresentMsgFlowStatus=Check_V2G_Flow_Status();
    ShmDispenser->gun_info.acCcsInfo.EVChargeProgress = ShmCcsData->V2GMessage_ISO15118_2014.PowerDeliveryRequest.ChargeProgress;
    ShmDispenser->gun_info.acCcsInfo.CpSetPWMDuty=ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].CpDuty;
+   memcpy(ShmDispenser->gun_info.acCcsInfo.EVCCID, EVCOMM_SYS_INFO.EVCCID, sizeof(ShmDispenser->gun_info.acCcsInfo.EVCCID));
     //----------[1] Permission --------
    // ShmInternalComm->ChargingPermission_new = (unsigned char) CSUCOMMAC_SHM.ChargingPermission;
     ShmInternalComm->ChargingPermission_new=ShmDispenser->gun_info.acCcsInfo.ChargingPermission;

+ 370 - 268
EVSE/Projects/AX80/Apps/Module_AlarmDetect.c

@@ -58,12 +58,19 @@ struct{
 	unsigned short int	GMI;
 	unsigned short int	Short[3];
 	unsigned short int	Leakage;
-	unsigned short int	HandShakingTimeout;
 	unsigned short int	EmrgencyBTN;
 	unsigned short int	Relay_Welding;
 	unsigned short int	Relay_DrivingFault;
 	unsigned short int	CP_LevelFail;
 	unsigned short int	MCU_SelfTestFail;
+	unsigned short int  GetEvCCIDTimeout;
+	unsigned short int	Rotary_Switch;
+	unsigned short int  leak_module_fail;
+	unsigned short int  locker_fault;
+	unsigned short int  power_drop;
+	unsigned short int  meter_comm_timeout;
+	unsigned short int  meter_ic_comm_timeout;
+	unsigned short int  pilot_negative_error;
 }Alarm_Counter[3];
 
 void trim(char *s);
@@ -344,13 +351,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].OV[0] = 0;
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == ON)
+				if(Alarm_Counter[gun_index].OV[0] > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_OVER_VOLTAGE;
-					DEBUG_INFO("ALARM_L1_OVER_VOLTAGE : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_OVER_VOLTAGE;
+						DEBUG_INFO("ALARM_L1_OVER_VOLTAGE : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].OV[0] = 0;
 			}
 
 			if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
@@ -373,13 +383,16 @@ int main(void)
 				}
 				else
 				{
-					Alarm_Counter[gun_index].OV[1] = 0;
-					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == ON)
+					if(Alarm_Counter[gun_index].OV[1] > FILTER_SPEC)
 					{
-						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = OFF;
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_OVER_VOLTAGE;
-						DEBUG_INFO("ALARM_L2_OVER_VOLTAGE : recover \n");
+						if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == ON)
+						{
+							ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = OFF;
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_OVER_VOLTAGE;
+							DEBUG_INFO("ALARM_L2_OVER_VOLTAGE : recover \n");
+						}
 					}
+					Alarm_Counter[gun_index].OV[1] = 0;
 				}
 
 				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OVP_L3 == ON)
@@ -400,13 +413,16 @@ int main(void)
 				}
 				else
 				{
-					Alarm_Counter[gun_index].OV[2] = 0;
-					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == ON)
+					if(Alarm_Counter[gun_index].OV[2] > FILTER_SPEC)
 					{
-						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = OFF;
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_OVER_VOLTAGE;
-						DEBUG_INFO("ALARM_L3_OVER_VOLTAGE : recover \n");
+						if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == ON)
+						{
+							ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = OFF;
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_OVER_VOLTAGE;
+							DEBUG_INFO("ALARM_L3_OVER_VOLTAGE : recover \n");
+						}
 					}
+					Alarm_Counter[gun_index].OV[2] = 0;
 				}
 			}
 
@@ -431,13 +447,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].UV[0] = 0;
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == ON)
+				if(Alarm_Counter[gun_index].UV[0] > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_UNDER_VOLTAGE;
-					DEBUG_INFO("ALARM_L1_UNDER_VOLTAGE : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_UNDER_VOLTAGE;
+						DEBUG_INFO("ALARM_L1_UNDER_VOLTAGE : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].UV[0] = 0;
 			}
 
 			if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
@@ -460,13 +479,16 @@ int main(void)
 				}
 				else
 				{
-					Alarm_Counter[gun_index].UV[1] = 0;
-					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == ON)
+					if(Alarm_Counter[gun_index].UV[1] > FILTER_SPEC)
 					{
-						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = OFF;
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_UNDER_VOLTAGE;
-						DEBUG_INFO("ALARM_L2_UNDER_VOLTAGE : recover \n");
+						if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == ON)
+						{
+							ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = OFF;
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_UNDER_VOLTAGE;
+							DEBUG_INFO("ALARM_L2_UNDER_VOLTAGE : recover \n");
+						}
 					}
+					Alarm_Counter[gun_index].UV[1] = 0;
 				}
 
 				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.UVP_L3 == ON)
@@ -487,15 +509,17 @@ int main(void)
 				}
 				else
 				{
-					Alarm_Counter[gun_index].UV[2] = 0;
-					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == ON)
+					if(Alarm_Counter[gun_index].UV[2] > FILTER_SPEC)
 					{
-						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = OFF;
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_UNDER_VOLTAGE;
-						DEBUG_INFO("ALARM_L3_UNDER_VOLTAGE : recover \n");
+						if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == ON)
+						{
+							ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = OFF;
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_UNDER_VOLTAGE;
+							DEBUG_INFO("ALARM_L3_UNDER_VOLTAGE : recover \n");
+						}
 					}
+					Alarm_Counter[gun_index].UV[2] = 0;
 				}
-							
 			}
 
 			//=====================================
@@ -523,13 +547,16 @@ int main(void)
 					((ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC) ? (getDiffSecNow(startTime[ALARM_TMR_IDX_OCP_L1]) >= 60) : TRUE) &&
 			        (ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0] <= (ShmCharger->gun_info[gun_index].targetCurrent<=20?(ShmCharger->gun_info[gun_index].targetCurrent):((int)((ShmCharger->gun_info[gun_index].targetCurrent*((ShmSysConfigAndInfo->SysConfig.ModelName[3]=='E') || (ShmSysConfigAndInfo->SysConfig.ModelName[3]=='T') || (ShmSysConfigAndInfo->SysConfig.ModelName[3]=='Z')?1.25:1.1))-2)))))
 			{
-				Alarm_Counter[gun_index].OC[0] = 0;
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP == ON)
+				if(Alarm_Counter[gun_index].OC[0] > 500)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_OVER_CURRENT;
-					DEBUG_INFO("ALARM_L1_OVER_CURRENT : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_OVER_CURRENT;
+						DEBUG_INFO("ALARM_L1_OVER_CURRENT : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].OC[0] = 0;
 			}
 
 			if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
@@ -556,13 +583,16 @@ int main(void)
 						((ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC) ? (getDiffSecNow(startTime[ALARM_TMR_IDX_OCP_L2]) >= 60) : TRUE) &&
 						(ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0] <= (ShmCharger->gun_info[gun_index].targetCurrent<=20?(ShmCharger->gun_info[gun_index].targetCurrent):((int)((ShmCharger->gun_info[gun_index].targetCurrent*((ShmSysConfigAndInfo->SysConfig.ModelName[3]=='E') || (ShmSysConfigAndInfo->SysConfig.ModelName[3]=='T') || (ShmSysConfigAndInfo->SysConfig.ModelName[3]=='Z')?1.25:1.1))-2)))))
 				{
-					Alarm_Counter[gun_index].OC[1] = 0;
-					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL2 == ON)
+					if(Alarm_Counter[gun_index].OC[1] > 500)
 					{
-						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL2 = OFF;
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_OVER_CURRENT;
-						DEBUG_INFO("ALARM_L2_OVER_CURRENT : recover \n");
+						if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL2 == ON)
+						{
+							ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL2 = OFF;
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_OVER_CURRENT;
+							DEBUG_INFO("ALARM_L2_OVER_CURRENT : recover \n");
+						}
 					}
+					Alarm_Counter[gun_index].OC[1] = 0;
 				}
 
 				if((ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OCP_L3 == ON) ||
@@ -587,12 +617,16 @@ int main(void)
 						((ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC) ? (getDiffSecNow(startTime[ALARM_TMR_IDX_OCP_L3]) >= 60) : TRUE) &&
 						(ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0] <= (ShmCharger->gun_info[gun_index].targetCurrent<=20?(ShmCharger->gun_info[gun_index].targetCurrent):((int)((ShmCharger->gun_info[gun_index].targetCurrent*((ShmSysConfigAndInfo->SysConfig.ModelName[3]=='E') || (ShmSysConfigAndInfo->SysConfig.ModelName[3]=='T') || (ShmSysConfigAndInfo->SysConfig.ModelName[3]=='Z')?1.25:1.1))-2)))))
 				{
-					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL3 == ON)
+					if(Alarm_Counter[gun_index].OC[2] > 500)
 					{
-						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL3 = OFF;
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_OVER_CURRENT;
-						DEBUG_INFO("ALARM_L3_OVER_CURRENT : recover \n");
+						if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL3 == ON)
+						{
+							ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL3 = OFF;
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_OVER_CURRENT;
+							DEBUG_INFO("ALARM_L3_OVER_CURRENT : recover \n");
+						}
 					}
+					Alarm_Counter[gun_index].OC[2] = 0;
 				}
 			}
 
@@ -617,13 +651,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].OT_AMB = 0;
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAmbientOTP == ON)
+				if(Alarm_Counter[gun_index].OT_AMB > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAmbientOTP = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_OVER_TEMPERATURE;
-					DEBUG_INFO("ALARM_OVER_TEMPERATURE : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAmbientOTP == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAmbientOTP = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_OVER_TEMPERATURE;
+						DEBUG_INFO("ALARM_OVER_TEMPERATURE : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].OT_AMB = 0;
 			}
 
 			//=====================================
@@ -647,13 +684,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].GMI = 0;
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcGroundfaultFail == ON)
+				if(Alarm_Counter[gun_index].GMI > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcGroundfaultFail = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_GROUND_FAIL;
-					DEBUG_INFO("ALARM_GROUND_FAIL : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcGroundfaultFail == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcGroundfaultFail = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_GROUND_FAIL;
+						DEBUG_INFO("ALARM_GROUND_FAIL : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].GMI = 0;
 			}
 
 			//=====================================
@@ -677,13 +717,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].CP_LevelFail= 0;
-				if(ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault == ON)
+				if(Alarm_Counter[gun_index].CP_LevelFail > FILTER_SPEC)
 				{
-					ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CP_ERROR;
-					DEBUG_INFO("ALARM_CP_ERROR : recover \n");
+					if(ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault == ON)
+					{
+						ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CP_ERROR;
+						DEBUG_INFO("ALARM_CP_ERROR : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].CP_LevelFail= 0;
 			}
 
 			//=====================================
@@ -718,23 +761,26 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].Leakage = 0;
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip == ON)
+				if(Alarm_Counter[gun_index].Leakage > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip = OFF;
-					if(ShmCharger->gun_info[gun_index].otherAlarmCode.isACLeakage == ON)
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip == ON)
 					{
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CURRENT_LEAK_AC;
-						ShmCharger->gun_info[gun_index].otherAlarmCode.isACLeakage = OFF;
-						DEBUG_INFO("ALARM_CURRENT_LEAK_AC : recover \n");
-					}
-					else if(ShmCharger->gun_info[gun_index].otherAlarmCode.isDcLeakage == ON)
-					{
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CURRENT_LEAK_DC;
-						ShmCharger->gun_info[gun_index].otherAlarmCode.isDcLeakage = OFF;
-						DEBUG_INFO("ALARM_CURRENT_LEAK_DC : recover \n");
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip = OFF;
+						if(ShmCharger->gun_info[gun_index].otherAlarmCode.isACLeakage == ON)
+						{
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CURRENT_LEAK_AC;
+							ShmCharger->gun_info[gun_index].otherAlarmCode.isACLeakage = OFF;
+							DEBUG_INFO("ALARM_CURRENT_LEAK_AC : recover \n");
+						}
+						else if(ShmCharger->gun_info[gun_index].otherAlarmCode.isDcLeakage == ON)
+						{
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CURRENT_LEAK_DC;
+							ShmCharger->gun_info[gun_index].otherAlarmCode.isDcLeakage = OFF;
+							DEBUG_INFO("ALARM_CURRENT_LEAK_DC : recover \n");
+						}
 					}
 				}
+				Alarm_Counter[gun_index].Leakage = 0;
 			}
 
 			//=====================================
@@ -758,36 +804,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].MCU_SelfTestFail = 0;
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.McuSelftestFail == ON)
-				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.McuSelftestFail = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_MCU_TESTFAIL;
-					DEBUG_INFO("ALARM_MCU_TESTFAIL : recover \n");
-				}
-			}
-
-			//=====================================
-			// Hand shaking timeout detection
-			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.handshaking_timeout == ON)
-			{
-				if(ShmCharger->gun_info[gun_index].otherAlarmCode.isHandshakingTimeOut == OFF)
-				{
-					ShmCharger->gun_info[gun_index].otherAlarmCode.isHandshakingTimeOut  = ON;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_HANDSHAKE_TIMEOUT;
-					DEBUG_INFO("ALARM_HANDSHAKE_TIMEOUT : alarm \n");
-				}
-
-			}
-			else
-			{
-				if(ShmCharger->gun_info[gun_index].otherAlarmCode.isHandshakingTimeOut == ON)
+				if(Alarm_Counter[gun_index].MCU_SelfTestFail > FILTER_SPEC)
 				{
-					ShmCharger->gun_info[gun_index].otherAlarmCode.isHandshakingTimeOut  = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_HANDSHAKE_TIMEOUT;
-					DEBUG_INFO("ALARM_HANDSHAKE_TIMEOUT : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.McuSelftestFail == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.McuSelftestFail = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_MCU_TESTFAIL;
+						DEBUG_INFO("ALARM_MCU_TESTFAIL : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].MCU_SelfTestFail = 0;
 			}
 
 			//=====================================
@@ -811,13 +837,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].EmrgencyBTN = 0;
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip == ON)
+				if(Alarm_Counter[gun_index].EmrgencyBTN > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_EMERGENCY_STOP;
-					DEBUG_INFO("ALARM_EMERGENCY_STOP : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_EMERGENCY_STOP;
+						DEBUG_INFO("ALARM_EMERGENCY_STOP : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].EmrgencyBTN = 0;
 			}
 
 			//=====================================
@@ -841,13 +870,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].Relay_Welding = 0;
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayWelding == ON)
+				if(Alarm_Counter[gun_index].Relay_Welding > FILTER_SPEC)
 				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayWelding = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_RELAY_WELDING;
-					DEBUG_INFO("ALARM_RELAY_STATUS : recover \n");
+					if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayWelding == ON)
+					{
+						ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayWelding = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_RELAY_WELDING;
+						DEBUG_INFO("ALARM_RELAY_STATUS : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].Relay_Welding = 0;
 			}
 
 			//=====================================
@@ -871,13 +903,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].Relay_DrivingFault = 0;
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayDrivingFault == ON)
+				if(Alarm_Counter[gun_index].Relay_DrivingFault > FILTER_SPEC)
 				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayDrivingFault = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_RELAY_DRIVE_FAULT;
-					DEBUG_INFO("ALARM_RELAY_DRIVE_FAULT : recover \n");
+					if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayDrivingFault == ON)
+					{
+						ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayDrivingFault = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_RELAY_DRIVE_FAULT;
+						DEBUG_INFO("ALARM_RELAY_DRIVE_FAULT : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].Relay_DrivingFault = 0;
 			}
 
 			//=====================================
@@ -901,13 +936,16 @@ int main(void)
 			}
 			else
 			{
-				Alarm_Counter[gun_index].Short[0] = 0;
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort == ON)
+				if(Alarm_Counter[gun_index].Short[0] > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_CIRCUIT_SHORT;
-					DEBUG_INFO("ALARM_L1_CIRCUIT_SHORT : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_CIRCUIT_SHORT;
+						DEBUG_INFO("ALARM_L1_CIRCUIT_SHORT : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].Short[0] = 0;
 			}
 			
 			if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
@@ -930,13 +968,16 @@ int main(void)
 				}
 				else
 				{
-					Alarm_Counter[gun_index].Short[1] = 0;
-					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL2 == ON)
+					if(Alarm_Counter[gun_index].Short[1] > FILTER_SPEC)
 					{
-						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL2 = OFF;
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_CIRCUIT_SHORT;
-						DEBUG_INFO("ALARM_L2_CIRCUIT_SHORT : recover \n");
+						if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL2 == ON)
+						{
+							ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL2 = OFF;
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_CIRCUIT_SHORT;
+							DEBUG_INFO("ALARM_L2_CIRCUIT_SHORT : recover \n");
+						}
 					}
+					Alarm_Counter[gun_index].Short[1] = 0;
 				}
 
 				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.short_circuit_L3 == ON)
@@ -957,13 +998,16 @@ int main(void)
 				}
 				else
 				{
-					Alarm_Counter[gun_index].Short[2] = 0;
-					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL3 == ON)
+					if(Alarm_Counter[gun_index].Short[2] > FILTER_SPEC)
 					{
-						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL3 = OFF;
-						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_CIRCUIT_SHORT;
-						DEBUG_INFO("ALARM_L3_CIRCUIT_SHORT : recover \n");
+						if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL3 == ON)
+						{
+							ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL3 = OFF;
+							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_CIRCUIT_SHORT;
+							DEBUG_INFO("ALARM_L3_CIRCUIT_SHORT : recover \n");
+						}
 					}
+					Alarm_Counter[gun_index].Short[2] = 0;
 				}
 			}
 
@@ -972,21 +1016,32 @@ int main(void)
 			//=====================================
 			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.rotate_switch_fault == ON)
 			{
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault == OFF)
+				if(Alarm_Counter[gun_index].Rotary_Switch > FILTER_SPEC)
 				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault = ON;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_ROTATORY_SWITCH_FAULT;
-					DEBUG_INFO("ALARM_ROTATORY_SWITCH_FAULT : alarm \n");
+					if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault == OFF)
+					{
+						ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault = ON;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_ROTATORY_SWITCH_FAULT;
+						DEBUG_INFO("ALARM_ROTATORY_SWITCH_FAULT : alarm \n");
+					}
+				}
+				else
+				{
+					Alarm_Counter[gun_index].Rotary_Switch += 1;
 				}
 			}
 			else
 			{
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault == ON)
+				if(Alarm_Counter[gun_index].Rotary_Switch > FILTER_SPEC)
 				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_ROTATORY_SWITCH_FAULT;
-					DEBUG_INFO("ALARM_ROTATORY_SWITCH_FAULT : recover \n");
+					if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault == ON)
+					{
+						ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_ROTATORY_SWITCH_FAULT;
+						DEBUG_INFO("ALARM_ROTATORY_SWITCH_FAULT : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].Rotary_Switch = 0;
 			}
 
 			//=====================================
@@ -994,43 +1049,32 @@ int main(void)
 			//=====================================
 			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.leak_module_fail == ON)
 			{
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail == OFF)
+				if(Alarm_Counter[gun_index].leak_module_fail > FILTER_SPEC)
 				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail = ON;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_LEAK_MODULE_FAIL;
-					DEBUG_INFO("ALARM_LEAK_MODULE_FAIL : alarm \n");
-				}
-			}
-			else
-			{
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail == ON)
-				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_LEAK_MODULE_FAIL;
-					DEBUG_INFO("ALARM_LEAK_MODULE_FAIL : recover \n");
+					if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail == OFF)
+					{
+						ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail = ON;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_LEAK_MODULE_FAIL;
+						DEBUG_INFO("ALARM_LEAK_MODULE_FAIL : alarm \n");
+					}
 				}
-			}
-
-			//=====================================
-			// Shutter detection
-			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.shutter_fault == ON)
-			{
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.ShutterFault == OFF)
+				else
 				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.ShutterFault = ON;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_SHUTTER_FAULT;
-					DEBUG_INFO("ALARM_SHUTTER_FAULT : alarm \n");
+					Alarm_Counter[gun_index].leak_module_fail += 1;
 				}
 			}
 			else
 			{
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.ShutterFault == ON)
+				if(Alarm_Counter[gun_index].leak_module_fail > FILTER_SPEC)
 				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.ShutterFault = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_SHUTTER_FAULT;
-					DEBUG_INFO("ALARM_SHUTTER_FAULT : recover \n");
+					if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail == ON)
+					{
+						ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_LEAK_MODULE_FAIL;
+						DEBUG_INFO("ALARM_LEAK_MODULE_FAIL : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].leak_module_fail = 0;
 			}
 
 			//=====================================
@@ -1038,21 +1082,32 @@ int main(void)
 			//=====================================
 			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.locker_fault == ON)
 			{
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail == OFF)
+				if(Alarm_Counter[gun_index].locker_fault > FILTER_SPEC)
+				{
+					if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail == OFF)
+					{
+						ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail = ON;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_LOCKER_FAULT;
+						DEBUG_INFO("ALARM_LOCKER_FAULT : alarm \n");
+					}
+				}
+				else
 				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail = ON;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_LOCKER_FAULT;
-					DEBUG_INFO("ALARM_LOCKER_FAULT : alarm \n");
+					Alarm_Counter[gun_index].locker_fault += 1;
 				}
 			}
 			else
 			{
-				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail == ON)
+				if(Alarm_Counter[gun_index].locker_fault > FILTER_SPEC)
 				{
-					ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_LOCKER_FAULT;
-					DEBUG_INFO("ALARM_LOCKER_FAULT : recover \n");
+					if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail == ON)
+					{
+						ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_LOCKER_FAULT;
+						DEBUG_INFO("ALARM_LOCKER_FAULT : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].locker_fault = 0;
 			}
 
 			//=====================================
@@ -1060,21 +1115,32 @@ int main(void)
 			//=====================================
 			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.power_drop == ON)
 			{
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop == OFF)
+				if(Alarm_Counter[gun_index].power_drop > FILTER_SPEC)
+				{
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop == OFF)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop = ON;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_POWER_DROP;
+						DEBUG_INFO("ALARM_POWER_DROP : alarm \n");
+					}
+				}
+				else
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop = ON;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_POWER_DROP;
-					DEBUG_INFO("ALARM_POWER_DROP : alarm \n");
+					Alarm_Counter[gun_index].power_drop += 1;
 				}
 			}
 			else
 			{
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop == ON)
+				if(Alarm_Counter[gun_index].power_drop > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_POWER_DROP;
-					DEBUG_INFO("ALARM_POWER_DROP : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_POWER_DROP;
+						DEBUG_INFO("ALARM_POWER_DROP : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].power_drop = 0;
 			}
 
 			//=====================================
@@ -1082,21 +1148,32 @@ int main(void)
 			//=====================================
 			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.meter_comm_timeout == ON)
 			{
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout == OFF)
+				if(Alarm_Counter[gun_index].meter_comm_timeout > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout = ON;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_METER_TIMEOUT;
-					DEBUG_INFO("ALARM_METER_TIMEOUT : alarm \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout == OFF)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout = ON;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_METER_TIMEOUT;
+						DEBUG_INFO("ALARM_METER_TIMEOUT : alarm \n");
+					}
+				}
+				else
+				{
+					Alarm_Counter[gun_index].meter_comm_timeout += 1;
 				}
 			}
 			else
 			{
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout == ON)
+				if(Alarm_Counter[gun_index].meter_comm_timeout > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_METER_TIMEOUT;
-					DEBUG_INFO("ALARM_METER_TIMEOUT : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_METER_TIMEOUT;
+						DEBUG_INFO("ALARM_METER_TIMEOUT : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].meter_comm_timeout = 0;
 			}
 
 			//=====================================
@@ -1104,21 +1181,32 @@ int main(void)
 			//=====================================
 			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.meter_ic_comm_timeout == ON)
 			{
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout == OFF)
+				if(Alarm_Counter[gun_index].meter_ic_comm_timeout > FILTER_SPEC)
+				{
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout == OFF)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout = ON;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_METER_IC_TIMEOUT;
+						DEBUG_INFO("ALARM_METER_IC_TIMEOUT : alarm \n");
+					}
+				}
+				else
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout = ON;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_METER_IC_TIMEOUT;
-					DEBUG_INFO("ALARM_METER_IC_TIMEOUT : alarm \n");
+					Alarm_Counter[gun_index].meter_ic_comm_timeout += 1;
 				}
 			}
 			else
 			{
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout == ON)
+				if(Alarm_Counter[gun_index].meter_ic_comm_timeout > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_METER_IC_TIMEOUT;
-					DEBUG_INFO("ALARM_METER_IC_TIMEOUT : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_METER_IC_TIMEOUT;
+						DEBUG_INFO("ALARM_METER_IC_TIMEOUT : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].meter_ic_comm_timeout = 0;
 			}
 
 			//=====================================
@@ -1126,21 +1214,32 @@ int main(void)
 			//=====================================
 			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.pilot_negative_error == ON)
 			{
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError == OFF)
+				if(Alarm_Counter[gun_index].pilot_negative_error > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError = ON;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_CP_NEG_ERROR;
-					DEBUG_INFO("ALARM_PILOT_NEGATIVE_ERROR : alarm \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError == OFF)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError = ON;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_CP_NEG_ERROR;
+						DEBUG_INFO("ALARM_PILOT_NEGATIVE_ERROR : alarm \n");
+					}
+				}
+				else
+				{
+					Alarm_Counter[gun_index].pilot_negative_error += 1;
 				}
 			}
 			else
 			{
-				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError == ON)
+				if(Alarm_Counter[gun_index].pilot_negative_error > FILTER_SPEC)
 				{
-					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError = OFF;
-					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CP_NEG_ERROR;
-					DEBUG_INFO("ALARM_PILOT_NEGATIVE_ERROR : recover \n");
+					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError == ON)
+					{
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CP_NEG_ERROR;
+						DEBUG_INFO("ALARM_PILOT_NEGATIVE_ERROR : recover \n");
+					}
 				}
+				Alarm_Counter[gun_index].pilot_negative_error = 0;
 			}
 
 			//=====================================
@@ -1172,6 +1271,39 @@ int main(void)
 				isCheckQca7000[gun_index] = TRUE;
 			}
 
+			//=====================================
+			// EVCCID get timeout
+			//=====================================
+			if(ShmCharger->gun_info[gun_index].isGetEvCCIDTimeout == ON)
+			{
+				if(Alarm_Counter[gun_index].GetEvCCIDTimeout > FILTER_SPEC)
+				{
+					if(ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail== OFF)
+					{
+						ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail = ON;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_GET_EVCCID_TIMEOUT;
+						DEBUG_INFO("ALARM_GET_EVCCID_TIMEOUT : alarm \n");
+					}
+				}
+				else
+				{
+					Alarm_Counter[gun_index].GetEvCCIDTimeout++;
+				}
+			}
+			else
+			{
+				if(Alarm_Counter[gun_index].GetEvCCIDTimeout > FILTER_SPEC)
+				{
+					if(ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail == ON)
+					{
+						ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail = OFF;
+						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_GET_EVCCID_TIMEOUT;
+						DEBUG_INFO("ALARM_GET_EVCCID_TIMEOUT : recover \n");
+					}
+				}
+				Alarm_Counter[gun_index].GetEvCCIDTimeout = 0;
+			}
+
 			//=====================================
 			// OCPP error code message
 			//=====================================
@@ -1250,12 +1382,6 @@ int main(void)
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012257");
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "McuTestFail");
 				}
-				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_HANDSHAKE_TIMEOUT)
-				{
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "HandshakeTimeout");
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "HandshakeTimeout");
-				}
 				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_EMERGENCY_STOP)
 				{
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
@@ -1274,12 +1400,6 @@ int main(void)
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011004");
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "LeakageModuleFail");
 				}
-				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_SHUTTER_FAULT)
-				{
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011034");
-					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "ShutterFault");
-				}
 				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LOCKER_FAULT)
 				{
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "ConnectorLockFailure");
@@ -1347,6 +1467,12 @@ int main(void)
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012284");
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "QCA Self test Failed");
 				}
+				else if(ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail)
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "023701");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "CCS EV communication Fail");
+				}
 				else
 				{
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "NoError");
@@ -1719,30 +1845,6 @@ int main(void)
 						previousAlarmCode[gun_index] &= ~ALARM_MCU_TESTFAIL;
 				}
 
-				if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_HANDSHAKE_TIMEOUT) != (previousAlarmCode[gun_index] & ALARM_HANDSHAKE_TIMEOUT))
-				{
-					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
-					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_HANDSHAKE_TIMEOUT)?"true":"false"));
-					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_HANDSHAKE_TIMEOUT)?OFF:ON);
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
-
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "HandshakeTimeout");
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "HandshakeTimeout");
-
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Operation");
-					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
-
-					idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
-
-					if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_HANDSHAKE_TIMEOUT)
-						previousAlarmCode[gun_index] |= ALARM_HANDSHAKE_TIMEOUT;
-					else
-						previousAlarmCode[gun_index] &= ~ALARM_HANDSHAKE_TIMEOUT;
-				}
-
 				if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_EMERGENCY_STOP) != (previousAlarmCode[gun_index] & ALARM_EMERGENCY_STOP))
 				{
 					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
@@ -1815,30 +1917,6 @@ int main(void)
 						previousAlarmCode[gun_index] &= ~ALARM_LEAK_MODULE_FAIL;
 				}
 
-				if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_SHUTTER_FAULT) != (previousAlarmCode[gun_index] & ALARM_SHUTTER_FAULT))
-				{
-					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
-					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_SHUTTER_FAULT)?"true":"false"));
-					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_SHUTTER_FAULT)?OFF:ON);
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
-
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "011034");
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "Shutter fault");
-
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Shutter");
-					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
-					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
-
-					idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
-
-					if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_SHUTTER_FAULT)
-						previousAlarmCode[gun_index] |= ALARM_SHUTTER_FAULT;
-					else
-						previousAlarmCode[gun_index] &= ~ALARM_SHUTTER_FAULT;
-				}
-
 				if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LOCKER_FAULT) != (previousAlarmCode[gun_index] & ALARM_LOCKER_FAULT))
 				{
 					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
@@ -2117,6 +2195,30 @@ int main(void)
 						previousAlarmCode[gun_index] &= ~ALARM_QCA_FLASH_FAIL;
 				}
 
+				if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_GET_EVCCID_TIMEOUT) != (previousAlarmCode[gun_index] & ALARM_GET_EVCCID_TIMEOUT))
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
+					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_GET_EVCCID_TIMEOUT)?"true":"false"));
+					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_GET_EVCCID_TIMEOUT)?OFF:ON);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "023701");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "CCS EV communication Fail");
+
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "PCBA");
+					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
+
+					idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
+
+					if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_GET_EVCCID_TIMEOUT)
+						previousAlarmCode[gun_index] |= ALARM_GET_EVCCID_TIMEOUT;
+					else
+						previousAlarmCode[gun_index] &= ~ALARM_GET_EVCCID_TIMEOUT;
+				}
+
 				if(idxEvent > 0)
 					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
 			}

+ 18 - 0
EVSE/Projects/AX80/Apps/Module_ConfigTools.c

@@ -286,6 +286,7 @@ int main(void)
 			printf("\n  modelname: EVSE model name.");
 			printf("\n  serialnumber: EVSE serial number.");
 			printf("\n  authentication: Authentication function.");
+			printf("\n  authbyevccid: Authorize by EVCCID.");
 			printf("\n  rfidendian: RFID read endian.");
 			printf("\n **************************************************");
 			printf("\n  Please input operation item: ");
@@ -350,6 +351,23 @@ int main(void)
 				else
 					DEBUG_INFO("Authentication: Enable\n");
 			}
+			else if(strcmp(cmd, "authbyevccid") == 0)
+			{
+                                memset(cmd, 0x00, ARRAY_SIZE(cmd));
+                                printf("\n ***** authbyevccid *******************************");
+                                printf("\n  Current mode: %d", ShmSysConfigAndInfo->SysConfig.isAuthrizeByEVCCID);
+                                printf("\n  0: Disable.");
+                                printf("\n  1: Enable.");
+                                printf("\n **************************************************");
+                                printf("\n  Please input authorize by EVCCID configuration value: ");
+                                scanf("%s", &cmd[0]);
+
+                                ShmSysConfigAndInfo->SysConfig.isAuthrizeByEVCCID = ((0<=atoi(cmd))&&(atoi(cmd)<=1)?atoi(cmd):0);
+                                if(!ShmSysConfigAndInfo->SysConfig.isAuthrizeByEVCCID)
+                                        DEBUG_INFO("Authotize by EVCCID: Disable\n");
+                                else
+                                        DEBUG_INFO("Authorize by EVCCID: Enable\n");
+			}
 			else if(strcmp(cmd, "rfidendian") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));

+ 132 - 3
EVSE/Projects/AX80/Apps/main.c

@@ -5289,6 +5289,7 @@ int main(void)
 				{
 					if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)
 					{
+						ShmCharger->gun_info[gun_index].isGetEvCCIDTimeout = OFF;
 						refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_STATE_B]);
 					}
 
@@ -5447,7 +5448,10 @@ int main(void)
 				if(ShmSysConfigAndInfo->SysInfo.AcChargingData[0].SystemStatus != SYS_MODE_BOOTING)
 				{
 					// Alarm event check
-					if((ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode>0) || ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CCSboardStestFail || ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP)
+					if((ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode>0) ||
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CCSboardStestFail ||
+						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP ||
+						ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail)
 					{
 						if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus != SYS_MODE_ALARM)
 						{
@@ -5489,6 +5493,23 @@ int main(void)
 				//==========================================
 				checkUnlocker(gun_index);
 
+				//==========================================
+				// Check Local Power Sharing Communication
+				//==========================================
+				if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing > 0)
+				{
+					 if(ShmSysConfigAndInfo->SysInfo.localSharingInfo.isConnectedSharingServer)
+					 {
+						 if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError == ON)
+							 ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError = OFF;
+					 }
+					 else
+					 {
+						 if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError == OFF)
+							 ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError = ON;
+					 }
+				}
+
 				//==========================================
 				// Connector process
 				//==========================================
@@ -5611,6 +5632,7 @@ int main(void)
 							ShmCharger->gun_info[gun_index].rfidReq = OFF;
 							ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart = OFF;
 							ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop = OFF;
+							ShmCharger->gun_info[gun_index].isGetEvCCID = OFF;
 							ocpp_set_remotestart(gun_index, OFF);
 							ocpp_set_remotestop(gun_index, OFF);
 
@@ -5667,13 +5689,76 @@ int main(void)
 							}
 						}
 
+						/*
+						 *	TODO:
+						 *	1. Try to get EVCCID if plug first
+						 */
+						if((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_ENABLE) &&
+						    ShmSysConfigAndInfo->SysConfig.isAuthrizeByEVCCID &&
+						    ShmCharger->isCcsEnable &&
+						   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B) &&
+						    !ShmCharger->gun_info[gun_index].isGetEvCCIDTimeout)
+						{
+							if(!getRequest(gun_index))
+							{
+								DEBUG_INFO("Try to get EVCCID.\n");
+								refreshStartTimer(&startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]);
+								setRequest(gun_index, ON);
+							}
+
+							if(getDiffSecNow(startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]) > TIMEOUT_SPEC_BS_HLC_HANDSHAKE)
+							{
+								ShmCharger->gun_info[gun_index].isGetEvCCIDTimeout = ON;
+								DEBUG_WARN("Try to get EVCCID timeout.\n");
+							}
+
+							if(ShmCharger->gun_info[gun_index].ccsHandshakeState == HANDSHAKE_CCS)
+							{
+								if((19 <= ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus) && (ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus < 254))
+								{
+									if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
+									{
+										sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%s%02X%02X%02X%02X%02X%02X", ShmOCPP16Data->ConfigurationTable.CoreProfile[EVCCID_PREFIX].ItemData,
+																															ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[0],
+																															ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[1],
+																															ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[2],
+																															ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[3],
+																															ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[4],
+																															ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[5]);
+									}
+									else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
+									{
+										sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X", ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[0],
+																														  ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[1],
+																														  ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[2],
+																														  ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[3],
+																														  ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[4],
+																														  ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[5]);
+									}
+
+									//sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "F5902677");
+									ShmCharger->gun_info[gun_index].isGetEvCCID = ON;
+
+									DEBUG_INFO("Got EVCCID: %s\n", ShmSysConfigAndInfo->SysConfig.UserId);
+								}
+							}
+						}
+						else
+						{
+							if(getRequest(gun_index))
+							{
+								setRequest(gun_index, OFF);
+							}
+						}
+
 						if(((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B)) ||
 						   ((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C)) ||
 						   ((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) && (ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn == ON)) ||
 						   (ShmCharger->gun_info[gun_index].rfidReq == ON) ||
 						   (ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart == ON) ||
 						   (ocpp_get_remotestart(gun_index) == ON) ||
-						   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].schedule.isTriggerStart == ON))
+						   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].schedule.isTriggerStart == ON) ||
+						   (ShmCharger->gun_info[gun_index].isGetEvCCID == ON))
 						{
 							if((ShmCharger->gun_info[gun_index].rfidReq == ON))
 							{
@@ -5697,6 +5782,13 @@ int main(void)
 								setSpeaker(ON, SPEAKER_SHORT);
 								DEBUG_INFO("Start Method : BLE...\n");
 							}
+							else if(ShmCharger->gun_info[gun_index].isGetEvCCID == ON)
+							{
+								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod = START_METHOD_EVCCID;
+								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartIdType = IdTokenType_MacAddress;
+								setSpeaker(ON, SPEAKER_SHORT);
+								DEBUG_INFO("Start Method : EVCCID...\n");
+							}
 							else
 							{
 								ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod = START_METHOD_FREE;
@@ -5711,6 +5803,7 @@ int main(void)
 							ocpp_set_remotestart(gun_index, OFF);
 							ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart = OFF;
 							ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].schedule.isTriggerStart = OFF;
+							ShmCharger->gun_info[gun_index].isGetEvCCID = OFF;
 
 							// Get target current
 							ocpp_set_profile_req(gun_index, ON);
@@ -5732,6 +5825,11 @@ int main(void)
 								DEBUG_INFO("Remote start request authorize.\n");
 								ocpp_set_auth_req(ON, "ISO14443");
 							}
+							else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_EVCCID))
+							{
+								DEBUG_INFO("EVCCID request authorize.\n");
+								ocpp_set_auth_req(ON, "MacAddress");
+							}
 						}
 
 						if(getDiffSecNow(startTime[gun_index][TMR_IDX_AUTH]) > TIMEOUT_SPEC_AUTH)
@@ -5778,6 +5876,34 @@ int main(void)
 										setChargerMode(gun_index, SYS_MODE_PREPARING);
 									}
 									break;
+								case START_METHOD_EVCCID:
+									if(ocpp_get_auth_conf() ||
+									   (!ocpp_get_connection_status() && ((ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE) || (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_NOCHARGE))) ||
+									   (!ocpp_get_connection_status() && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_LOCALLIST) && (getDiffSecNow(startTime[0][TMR_IDX_AUTH]) > 2)))
+									{
+										if(ocpp_get_auth_result(gun_index) ||
+										  (!ocpp_get_connection_status() && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE)) ||
+										  (!ocpp_get_connection_status() && (isValidLocalWhiteCard() == PASS) && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_LOCALLIST)))
+										{
+											memcpy((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
+
+											DEBUG_INFO("Authorize pass.\n");
+											setSpeaker(ON, SPEAKER_SHORT);
+											setLedMotion(gun_index, LED_ACTION_RFID_PASS);
+											setChargerMode(gun_index, SYS_MODE_PREPARING);
+										}
+										else
+										{
+											DEBUG_INFO("Authorize fail.\n");
+											setSpeaker(ON, SPEAKER_INTERVAL_3COUNT);
+											setLedMotion(gun_index, LED_ACTION_RFID_FAIL);
+											sleep(3);
+											setChargerMode(gun_index, SYS_MODE_IDLE);
+										}
+
+										ocpp_set_auth_conf(OFF);
+									}
+									break;
 								case START_METHOD_RFID:
 								case START_METHOD_BLE:
 								case START_METHOD_FREE:
@@ -6352,7 +6478,10 @@ int main(void)
 							}
 						}
 
-						if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode == 0) && !ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CCSboardStestFail && !ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP)
+						if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode == 0) &&
+						   !ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CCSboardStestFail &&
+						   !ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP &&
+						   !ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail)
 						{
 							if(((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_TERMINATING)) &&
 								!ShmCharger->gun_info[gun_index].isEmergencyStopReport)

+ 8 - 4
EVSE/Projects/AX80/Apps/main.h

@@ -54,18 +54,18 @@
 #define ALARM_CURRENT_LEAK_DC                   0x00000080
 
 #define ALARM_MCU_TESTFAIL						0x00000100
-#define ALARM_HANDSHAKE_TIMEOUT                 0x00000200
+#define ALARM_GET_EVCCID_TIMEOUT                0x00000200
 #define ALARM_EMERGENCY_STOP                    0x00000400
 #define ALARM_RELAY_WELDING                     0x00000800
 #define ALARM_LEAK_MODULE_FAIL                  0x00001000
-#define ALARM_SHUTTER_FAULT                     0x00002000
+#define ALARM_RESERVE_1 	                    0x00002000
 #define ALARM_LOCKER_FAULT                      0x00004000
 #define ALARM_POWER_DROP                        0x00008000
   
 #define ALARM_L1_CIRCUIT_SHORT                  0x00010000
 #define ALARM_ROTATORY_SWITCH_FAULT             0x00020000
 #define ALARM_RELAY_DRIVE_FAULT                 0x00040000
-#define ALARM_BLE_MODULE_BROKEN                 0x00080000
+#define ALARM_RESERVE_2			                0x00080000
 #define ALARM_L2_OVER_VOLTAGE                   0x00100000
 #define ALARM_L3_OVER_VOLTAGE                   0x00200000
 #define ALARM_L2_UNDER_VOLTAGE                  0x00400000
@@ -80,6 +80,7 @@
 #define ALARM_CP_NEG_ERROR 						0x40000000
 #define ALARM_QCA_FLASH_FAIL					0x80000000
 
+
 //=================================
 //CCS related define
 //=================================
@@ -172,7 +173,8 @@ enum START_METHOD
 	START_METHOD_FREE=0,
 	START_METHOD_RFID,
 	START_METHOD_BACKEND,
-	START_METHOD_BLE
+	START_METHOD_BLE,
+	START_METHOD_EVCCID
 };
 
 enum HANDSHAKE_STATE
@@ -796,6 +798,8 @@ typedef struct GUN_INFO
 	uint32_t										isUpgradePASS:1;
 	uint32_t										isGunUnpluggedBefore:1;
 	uint32_t										isEmergencyStopReport:1;
+	uint32_t										isGetEvCCID:1;
+	uint32_t										isGetEvCCIDTimeout:1;
 }Gun_Info;
 
 struct Charger

+ 33 - 21
EVSE/Projects/DD360Tcci/Apps/CSU/RFID.c

@@ -332,11 +332,12 @@ void WritePayResult(int result ,uint8_t gunIndex)
     else
         ShmDcCommonData->TransactionInfo[gunIndex].DeductResult = _DEDUCT_COMPLETE_FAIL;
 
-    log_info("Gun[%d] TransactionId:%d DeductResult:%d IsDonateInvoice:%d Amount:%f",
+    log_info("Gun[%d] TransactionId:%d DeductResult:%d IsDonateInvoice:%d Amount:%f VemData:%s",
         gunIndex, ShmDcCommonData->TransactionInfo[gunIndex].TransactionId,
         ShmDcCommonData->TransactionInfo[gunIndex].DeductResult,
         ShmDcCommonData->TransactionInfo[gunIndex].IsDonateInvoice,
-        ShmDcCommonData->TransactionInfo[gunIndex].Amount);
+        ShmDcCommonData->TransactionInfo[gunIndex].Amount,
+        ShmDcCommonData->TransactionInfo[gunIndex].pCreditCard.VemData);
 }
 void storePayResult(uint8_t gunIndex)
 {
@@ -354,7 +355,7 @@ void PreAuthCompleteToCardReader(int fd,uint8_t gunIndex)
         ShmDcCommonData->TransactionInfo[gunIndex].Amount = 1;
     }
     storePayResult(gunIndex);
-    log_info("Start Auth Complete");
+
 	result = CreditCardPreAuthComplete(fd,(int)ShmDcCommonData->TransactionInfo[gunIndex].Amount, &pSysConfig->ModelName[0],
 											&ShmDcCommonData->TransactionInfo[gunIndex].pCreditCard.VemData[0],
 											&ShmDcCommonData->TransactionInfo[gunIndex].pCreditCard);
@@ -416,10 +417,12 @@ void ReDeductProcess(int fd)
         log_info("Rededuct Total Number:%d", rededuct_num);
         for (j = 0; j < rededuct_num; j++) {
             sleep(10);
+            /*
             if (pSysInfo->SystemPage != _PAGE_IDLE && !ShmDcCommonData->Exe_ReDeduct) {
                 ShmDcCommonData->RoutineReduct = FALSE;
                 break;
             }
+            */
             log_info("Start Rededuct item [%d]",j);
             if (deductInfo[j].isIntoCharge == FALSE ||
                 (deductInfo[j].Energy == 0 && deductInfo[j].Amount == 0)) {
@@ -436,7 +439,7 @@ void ReDeductProcess(int fd)
             } else {
                 // 度數大於零
                 if (deductInfo[j].Amount == 0 && deductInfo[j].Energy > 0) {
-                    deductInfo[j].Amount = deductInfo[j].Energy * ShmDcCommonData->ChargingRate;
+                    deductInfo[j].Amount = ceil(deductInfo[j].Energy * ShmDcCommonData->ChargingRate);
                     if (deductInfo[j].Amount < 1)
                         deductInfo[j].Amount = 1;
                     log_info("Error Close Charging recount amount:%.1f",deductInfo[j].Amount);
@@ -497,6 +500,7 @@ void CreateRfidFork(void)
     int donate = 0;
     rfidRecPid = fork();
     int j = 0;
+    int sel_gun = 0;
     if (rfidRecPid == 0) {
         //char localTime[128] = {0};
         struct timeb SeqEndTime;
@@ -540,7 +544,7 @@ void CreateRfidFork(void)
             is_idle = TRUE;
 			for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
 				pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
-				if (pDcChargingInfo->SystemStatus != S_IDLE && pDcChargingInfo->SystemStatus != S_FAULT ) {
+				if (pDcChargingInfo->SystemStatus != S_IDLE && pDcChargingInfo->SystemStatus != S_FAULT) {
 					is_idle = FALSE;
 				}
                 if (ShmDcCommonData->StopCharge[gunIndex] == TRUE && pDcChargingInfo->Replug_flag == TRUE) {
@@ -597,10 +601,11 @@ void CreateRfidFork(void)
                 CreditCardCancelPreAuth(fd,pSysInfo->CurGunSelected);
             // 預授權
             } else if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_PREAUTH /* && ShmDcCommonData->GetCardNo[pSysInfo->CurGunSelected]*/) {
-                donate = (int)ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].IsDonateInvoice;
-                memset(&ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected], 0x00, sizeof(RecordTransactionInfo));
-                ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].IsDonateInvoice = (unsigned char)donate;
-        		result = CreditCardPreAuth(fd, PREAUTHMONEY,&pSysConfig->ModelName[0], &ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].pCreditCard);
+                sel_gun = pSysInfo->CurGunSelected;
+                donate = (int)ShmDcCommonData->TransactionInfo[sel_gun].IsDonateInvoice;
+                memset(&ShmDcCommonData->TransactionInfo[sel_gun], 0x00, sizeof(RecordTransactionInfo));
+                ShmDcCommonData->TransactionInfo[sel_gun].IsDonateInvoice = (unsigned char)donate;
+        		result = CreditCardPreAuth(fd, PREAUTHMONEY,&pSysConfig->ModelName[0], &ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard);
                 if (!ShmDcCommonData->TradeCancel)
                     StopSystemTimeoutDet();
                 if (ShmDcCommonData->TradeCancel == FALSE && result > 0) {
@@ -610,34 +615,40 @@ void CreateRfidFork(void)
 
                 ShmDcCommonData->PreAuth_Result = result;
 				//result = 1;
-				if (result > 0 && strcmp(ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].pCreditCard.CardNo,"") != 0 ) {
+				if (result > 0 && strcmp(ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard.CardNo,"") != 0 ) {
 
-					ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = TRUE;
-                    strncpy((char*)pSysConfig->UserId, (char *)ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].pCreditCard.CardNo, 20);
+					ShmDcCommonData->AuthPass_flag[sel_gun] = TRUE;
+                    strncpy((char*)pSysConfig->UserId, (char *)ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard.CardNo, 20);
                     log_info("Authorize card:%s", pSysConfig->UserId);
-                    ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].DeductResult = _DEDUCT_PREAUTH;
-                    ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].IsUpload = FALSE;
-                    InsertDeductInfo(ShmDcCommonData->ConnectorID[pSysInfo->CurGunSelected], &ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected]);
+                    ShmDcCommonData->TransactionInfo[sel_gun].DeductResult = _DEDUCT_PREAUTH;
+                    ShmDcCommonData->TransactionInfo[sel_gun].IsUpload = FALSE;
+                    ShmDcCommonData->TransactionInfo[sel_gun].ConnectorID = ShmDcCommonData->ConnectorID[sel_gun];
+                    InsertDeductInfo(ShmDcCommonData->ConnectorID[sel_gun], &ShmDcCommonData->TransactionInfo[sel_gun]);
 					log_info("PreAuth OK");
 				} else if (result < 0) {
                     if (ShmDcCommonData->TradeCancel == FALSE)
 					    pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
-					ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = FALSE;
-					memset(&ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].pCreditCard, 0, sizeof(TransInfo));
+					ShmDcCommonData->AuthPass_flag[sel_gun] = FALSE;
+					memset(&ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard, 0, sizeof(TransInfo));
 					log_info("PreAuth Fail");
+                    sleep(7);
 				}
 				ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE;
             }
 
-            // 每日晚上11點進行補扣款
-            if (tm->tm_min %5 == 0 && tm->tm_sec == 0) {
+            // 每30分鐘檢查補扣款
+            if (tm->tm_min %30 == 0 && tm->tm_sec == 0) {
                 ShmDcCommonData->RoutineReduct = FALSE;
             }
 
             if ((is_idle == TRUE &&
                 pSysInfo->SystemPage == _PAGE_IDLE &&
                 ShmDcCommonData->RoutineReduct == FALSE) || ShmDcCommonData->Exe_ReDeduct) {
+                ShmDcCommonData->CreditCardUpload = TRUE;
+                pSysInfo->SystemPage = _PAGE_PAYING;
                 ReDeductProcess(fd);
+                pSysInfo->SystemPage = _PAGE_IDLE;
+                ShmDcCommonData->CreditCardUpload = FALSE;
                 ShmDcCommonData->Exe_ReDeduct = 0;
             }
 
@@ -650,7 +661,8 @@ void CreateRfidFork(void)
                     ShmDcCommonData->UnionSettlement = 0;
                 else
                     ShmDcCommonData->RoutineSettlement = TRUE;
-                pSysInfo->SystemPage = _PAGE_MAINTAIN;
+                ShmDcCommonData->CreditCardUpload = TRUE;
+                pSysInfo->SystemPage = _PAGE_PAYING;
                  
                 result = CreditCardUnionSettlement(fd, &pSysConfig->ModelName[0], &LocalTransactionInfo.pCreditCard);
                 if (result > 0) {
@@ -660,10 +672,10 @@ void CreateRfidFork(void)
                     log_info("CreditCardUnionSettlement FAIL");
                 sleep(90);
                 pSysInfo->SystemPage = _PAGE_IDLE;
+                ShmDcCommonData->CreditCardUpload = FALSE;
             }
             if (tm->tm_hour == 16 && tm->tm_min == 0) {
                 ShmDcCommonData->RoutineSettlement = FALSE;
-                ShmDcCommonData->RoutineReduct = FALSE;
             }
             /*
             // 刷卡判斷

+ 22 - 24
EVSE/Projects/DD360Tcci/Apps/CSU/main.c

@@ -60,6 +60,7 @@ static struct FanModuleData *ShmFanModuleData = NULL;
 static struct RelayModuleData *ShmRelayModuleData = NULL;
 static struct LedModuleData *ShmLedModuleData = NULL;
 static struct OCPP16Data *ShmOCPP16Data = NULL;
+static struct OCPP20Data* ShmOCPP20Data = NULL;
 static DcCommonInfo *ShmDcCommonData = NULL;
 
 static struct ChargingInfoData *pDcChargingInfo = NULL;
@@ -81,8 +82,8 @@ uint8_t bd0_2_status = 0;
 uint8_t bd1_1_status = 0;
 uint8_t bd1_2_status = 0;
 
-char *fwVersion = "V2.10.00.0000.00"; // Phihong version
-char* DebugVersion = "v2.10.00";      // Software debug version
+char *fwVersion = "V2.11.00.0000.00"; // Phihong version
+char* DebugVersion = "v2.11.00";      // Software debug version
 //sqlite3 *localDb;
 bool isDb_ready;
 
@@ -1357,7 +1358,10 @@ uint8_t isPrechargeStatus_chademo(uint8_t gunIndex)
 {
     uint8_t result = 0x00;
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
-
+    if (ShmDcCommonData->pGunInfo[gunIndex].EVStatus != ShmCHAdeMOData->ev[pDcChargingInfo->type_index].PresentMsgFlowStatus) {
+        log_info("Gun%d Chademo board status = %d ", gunIndex, ShmCHAdeMOData->ev[pDcChargingInfo->type_index].PresentMsgFlowStatus);
+        ShmDcCommonData->pGunInfo[gunIndex].EVStatus = ShmCHAdeMOData->ev[pDcChargingInfo->type_index].PresentMsgFlowStatus;
+    }
     result = ShmCHAdeMOData->ev[pDcChargingInfo->type_index].PresentMsgFlowStatus;
 
     return result;
@@ -1388,7 +1392,10 @@ uint8_t isPrechargeStatus_gb(uint8_t gunIndex)
 {
     uint8_t result = 0x00;
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
-
+    if (ShmDcCommonData->pGunInfo[gunIndex].EVStatus != ShmGBTData->ev[pDcChargingInfo->type_index].PresentMsgFlowStatus) {
+        log_info("Gun%d GB Board status = %d ", gunIndex, ShmGBTData->ev[pDcChargingInfo->type_index].PresentMsgFlowStatus);
+        ShmDcCommonData->pGunInfo[gunIndex].EVStatus = ShmGBTData->ev[pDcChargingInfo->type_index].PresentMsgFlowStatus;
+    }
     result = ShmGBTData->ev[pDcChargingInfo->type_index].PresentMsgFlowStatus;
 
     return result;
@@ -1410,6 +1417,10 @@ uint8_t isPrechargeStatus_ccs(uint8_t gunIndex)
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
 
     if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121) {
+        if (ShmDcCommonData->pGunInfo[gunIndex].EVStatus != ShmCcsData->V2GMessage_DIN70121[pDcChargingInfo->type_index].PresentMsgFlowStatus) {
+            log_info("Gun%d CCS board status = %d ", gunIndex, ShmCcsData->V2GMessage_DIN70121[pDcChargingInfo->type_index].PresentMsgFlowStatus);
+            ShmDcCommonData->pGunInfo[gunIndex].EVStatus = ShmCcsData->V2GMessage_DIN70121[pDcChargingInfo->type_index].PresentMsgFlowStatus;
+        }
         result = ShmCcsData->V2GMessage_DIN70121[pDcChargingInfo->type_index].PresentMsgFlowStatus;
     }
 
@@ -3562,7 +3573,7 @@ static void ReviewCriticalAlarm(void)
        ) {
         if (((ShmSelectGunInfo->EthDevStatus.Backend == 0 ||
             ShmSelectGunInfo->EthDevStatus.Backend == 2) &&
-            ShmDcCommonData->DebugFlag == TRUE) || 
+            ShmDcCommonData->passbackend == TRUE) ||
             pSysConfig->AuthorisationMode) {
             pSysWarning->Level = WARN_LV_NL;
             return;
@@ -3966,22 +3977,21 @@ void showversion()
     log_info("\tRelay Board FW Rev = %s", pSysInfo->RelayModuleFwRev);
     log_info("\tFan Board FW Rev = %s", pSysInfo->FanModuleFwRev);
     log_info("\tPrimary FW Rev = %s", pSysInfo->CsuPrimFwRev);
-    log_info("\tLCM HW Rev = %s", pSysInfo->LcmHwRev);
     log_info("\tLED FW Rev = %s", pSysInfo->LedModuleFwRev);
 
     for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
         pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
         if (pDcChargingInfo->Type == _Type_Chademo) {
             log_info("\tCHAdeMO[%d] FW Rev = %s",
-                                     pDcChargingInfo->type_index,
+                                     index,
                                      ShmCHAdeMOData->evse[pDcChargingInfo->type_index].version);
         } else if (pDcChargingInfo->Type == _Type_GB) {
             log_info("\tGBT[%d] FW Rev = %s",
-                                     pDcChargingInfo->type_index,
+                                     index,
                                      ShmGBTData->evse[pDcChargingInfo->type_index].version);
         } else if (pDcChargingInfo->Type == _Type_CCS_2) {
             log_info("\tCCS[%d] FW Rev = %s",
-                                         pDcChargingInfo->type_index,
+                                         index,
                                          ShmCcsData->V2GMessage_DIN70121[pDcChargingInfo->type_index].version);
         }
     }
@@ -4018,6 +4028,7 @@ int main(void)
     ShmRelayModuleData = (struct RelayModuleData *)GetShmRelayModuleData();
     ShmLedModuleData = (struct LedModuleData *)GetShmLedModuleData();
     ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data();
+    ShmOCPP20Data = (struct OCPP20Data*)GetShmOCPP20Data();
     ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
     ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
 	
@@ -4389,7 +4400,7 @@ CheckStatus:
 
                 if (ShmPsuData->SystemPresentPsuQuantity > 0 &&
                         ShmPsuData->SystemAvailablePower > 10 &&
-                        GetTimeoutValue(pDcChargingInfo->TimeoutTimer) >= 5000000) {
+                        GetTimeoutValue(pDcChargingInfo->TimeoutTimer) >= 1000000) {
                     setChargerMode(gunIndex, MODE_PREPARE_FOR_EV);
                 }
 
@@ -4469,18 +4480,6 @@ CheckStatus:
                             pDcChargingInfo->PrechargeStatus != PRECHARGE_READY)
                         //if (pDcChargingInfo->PrechargeStatus != PRECHARGE_PRERELAY_PASS)
                     {
-                        //log_info("Send precharge ready 1..........%x, status = %d ",
-                        //         gunIndex,
-                        //         isPrechargeStatus_ccs(gunIndex));
-                        if (isPrechargeStatus_ccs(gunIndex) == 39) {
-                            log_info("Conn %x, Precharge ready, CCS status = PreChargeResponse (%d) ",
-                                     gunIndex,
-                                     isPrechargeStatus_ccs(gunIndex));
-                        } else if (isPrechargeStatus_ccs(gunIndex) == 40) {
-                            log_info("Conn %x, Precharge ready, CCS status = PowerDeliveryRequest start (%d) ",
-                                     gunIndex,
-                                     isPrechargeStatus_ccs(gunIndex));
-                        }
 
                         pDcChargingInfo->PrechargeStatus = PRECHARGE_READY;
                     }
@@ -4705,7 +4704,6 @@ CheckStatus:
                     pSysInfo->SystemPage = _PAGE_EXIT;
                     break;
                 }
-                
 
                 if (pDcChargingInfo->ConnectorPlugIn == NO &&
                     pSysInfo->SystemPage != _PAGE_PAYING && pSysInfo->SystemPage != _PAGE_SENSING) {
@@ -4719,7 +4717,7 @@ CheckStatus:
                 if (pSysInfo->CurGunSelected == gunIndex && pSysInfo->SystemPage != _PAGE_PAYING ) {
                 	if (pDcChargingInfo->Replug_flag == TRUE)
                 		pSysInfo->SystemPage = _PAGE_PLUGOUT;
-                	else{
+                	else {
                 		if (ShmDcCommonData->PayPass_flag[pSysInfo->CurGunSelected] == TRUE)
 							pSysInfo->SystemPage = _PAGE_COMPLETE;
 						else

+ 1 - 1
EVSE/Projects/DD360Tcci/Apps/CSU/main.h

@@ -50,7 +50,7 @@
 #define TCC_LINEREGISTER_TIMEOUT				(60)
 #define TCC_DONATECOMFIRM_TIMEOUT				(180)
 #define TCC_SELECTPAY_TIMEOUT					(180)
-#define TCC_FINALCOST_TIMEOUT					(30)
+#define TCC_FINALCOST_TIMEOUT					(60)
 #define TCC_SCANCARD_TIMEOUT					(30)
 #define TCC_TRADECANCEL_TIMEOUT                 (60)
 #define TCC_EXITPAGE_TIMEOUT                    (10)

+ 41 - 1
EVSE/Projects/DD360Tcci/Apps/Config.h

@@ -383,7 +383,8 @@ typedef union {
     struct {
         uint8_t ChillerOTP: 1;            //chiller Temperature OVP
         uint8_t ChillerTempSensorFail: 1; //Chiller temperature sensor failure
-        uint8_t Reserved: 6;
+        uint8_t ChillerTubeOTP : 1;
+        uint8_t Reserved: 5;
     } StatusBit;
 } ChillerTempErr;
 
@@ -399,6 +400,38 @@ typedef struct StPcPsuOutput { //from power cabinet PSU output
     uint16_t Current;
 } PcPsuOutput;
 
+typedef struct StPowerConsumptionInfo {
+    float Gun1_Consumption;
+    float Gun2_Consumption;
+    float Gun3_Consumption;
+    float Gun4_Consumption;
+} PowerConsumptionValue;
+
+typedef struct StPowConsumValue {
+    uint32_t Gun1_Consumption;
+    uint32_t Gun2_Consumption;
+    uint32_t Gun3_Consumption;
+    uint32_t Gun4_Consumption;
+} PowConsumValue;
+
+typedef struct StGunInfo {
+    int ConnectorID;
+    char ReceiptInfo[255];
+    int finalcost_flag;
+    time_t EVLoseTimer;
+    uint8_t EVLoseFlag;
+    char ReservationID[32];
+    uint8_t ReservationStatus;
+    char UserPriceString[255];
+    float PowerConsumption;
+    time_t RecordEnergyTime;
+    char ChargeStartTime[32];
+    char ChargeStopTime[32];
+    char ChargeDuration[32];
+    uint8_t withChiller;      //是否有水冷機
+    int EVStatus;          // ev小板狀態
+} GunInfo;
+
 typedef struct Psu_VersionInfo{
 	uint8_t n_PSU;
 	uint8_t DCVersion[32];
@@ -508,6 +541,13 @@ typedef struct StDcCommonInfo {
     time_t EVDisconnectTime[2];
     int EVDisconnectFlag[2];
     int is_plugout[2];
+    GunInfo pGunInfo[2];
+    uint8_t AuthroizeType; // 0: Central   1: eMAID    2: ISO14443 3: ISO15693 4: KeyCode  5: Local    6: MacAddress   7: NoAuthorization
+    char QRCodeString[255];
+    char DefaultPriceString[255];
+    PowerConsumptionValue pConsumption;
+    uint8_t CreditCardUpload;
+    uint8_t passbackend;
 } DcCommonInfo;
 
 #endif /* CONFIG_H_ */

+ 13 - 11
EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.c

@@ -1273,6 +1273,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
         }
 
         ShmSelectGunInfo->WaitDoCommPermission[plugNum] = pCsuResult->Data.Data[0];
+
         return pCsuResult->Data.Data[0];
         break;
 
@@ -2166,7 +2167,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
 					pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(plugNum);
 					ShmDcCommonData->TransactionInfo[plugNum].Amount = pDcChargingInfo->ChargingFee;
 					ShmDcCommonData->finalcost_flag[plugNum] = TRUE;
-					log_info("Gun %d get final cost %f", plugNum, pDcChargingInfo->ChargingFee);
+					log_info("Gun %d get final cost %f", plugNum, ShmDcCommonData->TransactionInfo[plugNum].Amount);
                 }
             }
             curReg = REG_PLUG_IN_STATE;
@@ -2448,7 +2449,7 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
                 DiffTimeb(gRegTimeUp[plugNum][REG_DEDUCT_INFO], AuthNowTime) < 0
                 ) {
                 reupload_num = DB_GetMultiReUploadDeduct(&reupload_gunIndex[0], &reuploadInfo[0]);
-                if (reupload_num >= 1) {
+                if (reupload_num >= 1 && reuploadInfo[0].ConnectorID != 0) {
 
                     if (writeDeductInfo(fd, reuploadInfo[0].ConnectorID, reupload_gunIndex[0], &reuploadInfo[0]) == PASS) {
                         log_info("Reupload Success");
@@ -2737,18 +2738,19 @@ void CreditCardProcess(int fd,int plugNum,int gunID, RecordTransactionInfo *pInf
     if (pInfo->IsUpload == TRUE || (strcmp(pInfo->pCreditCard.VemData,"") == 0) ||
         pSysInfo->SystemPage == _PAGE_SENSING)
         return;
+    if (ShmDcCommonData->TransactionInfo[plugNum].ConnectorID != 0) {
+        if (writeDeductInfo(fd, gunID, plugNum, &ShmDcCommonData->TransactionInfo[plugNum]) == PASS) {
+            ShmDcCommonData->TransactionInfo[plugNum].IsUpload = YES;
+            UpdateDeductInfoStatus(plugNum, &ShmDcCommonData->TransactionInfo[plugNum]);
 
-    if (writeDeductInfo(fd, gunID, plugNum, &ShmDcCommonData->TransactionInfo[plugNum]) == PASS) {
-        ShmDcCommonData->TransactionInfo[plugNum].IsUpload = YES;
-        UpdateDeductInfoStatus(plugNum, &ShmDcCommonData->TransactionInfo[plugNum]);
+            if (ShmDcCommonData->TransactionInfo[plugNum].DeductResult == _DEDUCT_CANCEL) {
+                memset(&ShmDcCommonData->TransactionInfo[plugNum].pCreditCard, 0x00, sizeof(TransInfo));
+            }
 
-        if (ShmDcCommonData->TransactionInfo[plugNum].DeductResult == _DEDUCT_CANCEL) {
-            memset(&ShmDcCommonData->TransactionInfo[plugNum].pCreditCard, 0x00, sizeof(TransInfo));
+            log_info("writeDeductInfo finish");
+        } else {
+            log_info("Write Deduct fail");
         }
-
-        log_info("writeDeductInfo finish");
-    } else {
-        log_info("Write Deduct fail");
     }
 }
 int main(int argc, char *argv[])

+ 3 - 0
EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.h

@@ -139,6 +139,9 @@
 #define MISC_CMD_STATION_INFO_REQ               (0x0109)
 #define MISC_CMD_FINAL_COST_REQ                 (0x010A)
 #define MISC_CMD_LINE_STATUS_REQ                (0x010B)
+#define MISC_CMD_DEFAULT_PRICE_REQ              (0x010C)
+#define MISC_CMD_USER_PRICE_REQ                 (0x010D)
+#define MISC_CMD_RECEIPT_REQ                    (0x010E)
 
 #define ST_UPDATE_FIRMWARE                      (0x01)
 #define ST_NO_UPDATE_FIRMWARE                   (0x02)

+ 5 - 1
EVSE/Projects/DD360Tcci/Apps/ModuleEvComm/Module_EvRxComm.c

@@ -330,10 +330,14 @@ void CANReceiver(int fd)
                 // 檢查是否有收到EV小板訊號
                 if ((time((time_t*)NULL) - ShmDcCommonData->EVDisconnectTime[_index]) > 3 &&
                     !ShmDcCommonData->EVDisconnectFlag[_index] &&
-                    pDcChargingInfo->SystemStatus != S_UPDATE) {
+                    pDcChargingInfo->SystemStatus != S_UPDATE && !ShmDcCommonData->DebugFlag) {
                     ShmDcCommonData->EVDisconnectTime[_index] = time((time_t*)NULL);
                     ShmDcCommonData->EVDisconnectFlag[_index] = TRUE;
                     log_info("Not Get EV Board %d data in 3 sec.", _index);
+                    system("/sbin/ip link set can0 down");
+                    sleep(1);
+                    system("/sbin/ip link set can0 type can bitrate 500000 restart-ms 100");
+                    system("/sbin/ip link set can0 up");
                 }
                 CheckEvConnect(_index);
             }

+ 3 - 5
EVSE/Projects/DD360Tcci/Apps/ModuleEvComm/Module_EvTxComm.c

@@ -405,8 +405,8 @@ static void SetPresentChargingOutputCap(void)
              LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] >= cur2 + 5)
        ) {
         //log_info("----------------------------------------------------- ");
-        log_info("To EV (Real) Power_1 = %.1f, Cur_1 = %.1f, Power_2 = %.1f, Cur_2 = %.1f",
-                 pow1 / 10, cur1 / 10, pow2 / 10, cur2 / 10);
+        log_info("To EV PW_1 = %.1f, Cur_1 = %.1f, Vol_1 = %.1f, PW_2 = %.1f, Cur_2 = %.1f, Vol_2 = %.1f",
+                 pow1 / 10, cur1 / 10, chargingData_1->FireChargingVoltage, pow2 / 10, cur2 / 10, chargingData_2->FireChargingVoltage);
         //log_info("----------------------------------------------------- ");
 
         LogInfo[0][EV_LOG_OUTPUT_CAP_POW] = pow1;
@@ -546,11 +546,9 @@ static void SetPresentChargingOutputPower(void)
             (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] >= cur2 + CHK_CUR_RANGE) ||
             (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] <= cur2 - CHK_CUR_RANGE)
        ) {
-        log_info("G1->Out Vol(%s)=%.1f,Out Cur=%.1f - G2->Out Vol(%s) = %.1f, Out Cur = %.1f",
-                 isPsuVol1 == true ? "P" : "R",
+        log_info("G1-> Vol=%.1f, Cur=%.1f - G2-> Vol = %.1f, Cur = %.1f",
                  vol1 / 10,
                  cur1 / 10,
-                 isPsuVol2 == true ? "P" : "R",
                  vol2 / 10,
                  cur2 / 10);
 

+ 1 - 1
EVSE/Projects/DD360Tcci/Apps/ModuleInternalComm/FanBoard.c

@@ -25,7 +25,7 @@ static int Uart5Fd = 0;
 static struct timeval gFanBoardRunTimer;
 
 static uint16_t _setFanSpeed = 0;
-static uint16_t fanSpeedSmoothValue = 500;
+static uint16_t fanSpeedSmoothValue = 1000;
 
 //------------------------------------------------------------------------------
 static void SetFanModuleSpeed(void)

+ 13 - 35
EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.c

@@ -1018,9 +1018,6 @@ void ChangeChargingRateValue(int rate)
     uint8_t value[10];
 
     memset(cmd, 0x00, sizeof(cmd));
-    if (rate == 0) {
-        log_info("Doesn't get Charge Fee");
-    } 
     
     sprintf((char *) value, "%d",rate);
     string2ByteArray(value, cmd);
@@ -1265,6 +1262,7 @@ void ProcessPageInfo()
         } else if (pDcChargingInfo->Type == _Type_Chademo) {
             ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CHAdeMo_Off);
         }
+        ChangeQrCode_Error();
         /*
         if (ShmDcCommonData->ClearServiceQR == FALSE) {
             ShmDcCommonData->ClearServiceQR = TRUE;
@@ -1304,24 +1302,7 @@ void ProcessPageInfo()
             	break;
             case _PAGE_AUTHORIZE:
                 StartSystemTimeoutDet(Timeout_ScanCard);
-                /*
-                int card_result = CreditCardPreAuth(CardReadFd, PREAUTHMONEY,"TCC Test", &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]);
-				if (card_result > 0 ) {
-					strcpy((char *)pSysConfig->UserId, (char *)ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo);
-				} else if (card_result < 0) {
-					pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
-				}*/
-            	//ChangeDisplay2Value(_Icon_Precharge,0);
-            	//ChangeDisplay2Value(_Icon_Precharge,1);
-                /*
-            	if (ShmDcCommonData->GetCardNo[pSysInfo->CurGunSelected] == TRUE &&
-            			ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] != TRUE) {
-            		//ShmDcCommonData->PreAuth_Config = _CREDITCARD_PREAUTH;
-            		//ShmDcCommonData->PreAuth_Result = 0;
-            		//sleep(3);
-            		pSysInfo->SystemPage = _PAGE_SENSING;
-            	}
-                */
+
 		        ChangeChargingRateValue((int)ShmDcCommonData->ChargingRate);
                 ShowAuthorizeCountDown();
             	_Text_Running_Count = 1;
@@ -1396,28 +1377,25 @@ void ProcessPageInfo()
                 break;
 
             case _PAGE_PLUGOUT:
-            	/*
-                if (pSysConfig->isQRCode) {
-                    if (pSysConfig->QRCodeMadeMode == NO) {
-                        //uint8_t len = strlen((char *)pSysConfig->SystemId);
-                        ChangeQrCode_Idle((char *)pSysConfig->SystemId);
-                    } else {
-                        //uint8_t len = strlen((char *)pSysConfig->QRCodeContent);
-                        ChangeQrCode_Idle((char *)pSysConfig->QRCodeContent);
-                    }
-                    //ChangeQrCode_Idle((char *)pSysConfig->SystemId);
-                }*/
+
             	break;
             case _PAGE_PAYING:
                 ChangeDisplay2Value(_Icon_Ani_Dot, 1);
+                if (ShmDcCommonData->CreditCardUpload) {
+                    ChangeDisplay2Value(_Icon_Uploading, _TCC_Uploading);
+                    ChangeDisplay2Value(_Icon_Paying, _ICON_Empty);
+                } else {
+                    ChangeDisplay2Value(_Icon_Uploading, _ICON_Empty);
+                    ChangeDisplay2Value(_Icon_Paying, _TCC_Paying);
+                }
             	break;
             case _PAGE_EXIT:
                 
                 break;
-                /*
+                
             case _PAGE_MAINTAIN:
                 ChangeQrCode_Error();
-                break;*/
+                break;
             }
         }
     }
@@ -1610,7 +1588,7 @@ void DefautLayOut()
 	ChangeDisplay2Value(_Icon_MobilePay,0);
 	ChangeDisplay2Value(_Icon_CardPay,0);
 	ChangeDisplay2Value(0x5000,1);
-    ChangeDisplay2Value(_QRCode_Service, 1);
+    //ChangeDisplay2Value(_QRCode_Service, 1);
 	ShowSelectGun();
 }
 /*

+ 2 - 0
EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.h

@@ -104,6 +104,7 @@
 #define _Icon_ScanCntDownDigits 0x1068
 #define _Icon_AuthCntDownTen    0x106A
 #define _Icon_AuthCntDownDigits 0x106C
+#define _Icon_Uploading         0x1070
 
 #define _String_Date			0x3000
 #define _String_Tempture		0x3010
@@ -367,6 +368,7 @@ enum _TCC_ICON_LIST_ {
 	_TCC_TradeCancelFrame,
 	_TCC_SecondSense,
 	_TCC_CntDownNumber0,
+	_TCC_Uploading = 323,
 };
 
 

+ 16 - 6
EVSE/Projects/DD360Tcci/Apps/ReadCmdline.c

@@ -526,6 +526,15 @@ void writeChillerStatus(char* v1)
     else
         printf("Please open Debug mode\n");
 }
+void writePassBackend()
+{
+    ShmDcCommonData->passbackend = !ShmDcCommonData->passbackend;
+    if (ShmDcCommonData->passbackend)
+        printf("Pass Backend on\n");
+    else
+        printf("Pass Backend off\n");
+
+}
 void SetFanSpeed(char *v1)
 {
     int speed = atoi(v1);
@@ -737,6 +746,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
     }
 
     //kill ev task
+    ShmDcCommonData->DebugFlag = TRUE;
     system("killall Module_EvComm");
 
     printf("Warming!!!!\nPlease pay attention chiller on or off !!!!\n");
@@ -754,9 +764,9 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
         case S_IDLE:
             if (PreviousSystemStatus[curGun] != pDcChargingInfo->SystemStatus) {
                 PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
-#if defined DD360Audi
+
                 setConfirmSelGun(curGun);
-#endif //defined DD360Audi
+
                 pSysInfo->SystemPage = _PAGE_SENSING;
                 strcpy((char *)pSysConfig->UserId, "AutoStartCharging");
                 pDcChargingInfo->ConnectorPlugIn = 1;
@@ -967,6 +977,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
             ShmDcCommonData->chillerCtrl = FALSE;
 
             if (stopChg == pSysConfig->TotalConnectorCount) {
+                ShmDcCommonData->DebugFlag = FALSE;
                 system("/root/Module_EvComm &");
                 sleep(3);
 
@@ -1271,6 +1282,7 @@ int main(void)
                      "       rededuct                          : Credit Card rededuct\n"
                      "       preauth                           : Credit Card PreAuth\n"
                      "       preauthcancel                     : Credit Card PreAuth Cancel\n"
+                     "       passbackend                       : Pass Backend disconnect\n"
                      "\r\n";
 
     if (CreateAllCsuShareMemory() == FAIL) {
@@ -1431,10 +1443,6 @@ int main(void)
                 printf ("Input cmd fail ------  strchg [vol 150-1000] [cru 2-100]\n");
                 continue;
             }
-            if (ShmDcCommonData->DebugFlag == FALSE) {
-                printf("Not open debug mode\n");
-                continue;
-            }
             // 槍狀態
             RunUnconditionalChargeIndex1(newString[1], newString[2], newString[3]);
         } else if (strcmp(newString[0], "tempW") == 0) { //測試槍頭和水冷機溫度
@@ -1459,6 +1467,8 @@ int main(void)
             ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
         } else if (strcmp(newString[0], "chiller") == 0) { //測試槍頭和水冷機溫度
             writeChillerStatus(newString[1]);
+        } else if (strcmp(newString[0], "passbackend") == 0) { //Pass Backend disconnect
+            writePassBackend();
         } else {
             printf("%s\n", usageMsg);
         }

+ 0 - 1
EVSE/Projects/DD360Tcci/Apps/SelectGun/SelectGun.h

@@ -62,7 +62,6 @@ typedef struct StPricesInfo {
     //float DefaultPrices;        //unit = 0.01 dollar, value / 100
     float Discount;
     int TransactionId;
-    uint8_t Reserved[4];
 } PricesInfo;
 
 //typedef struct StOperativeInfo {

+ 29 - 0
EVSE/Projects/DD360Tcci/Apps/ShareMemory/shmMem.c

@@ -38,6 +38,7 @@ static struct FanModuleData *ShmFanModuleData = NULL;
 static struct RelayModuleData *ShmRelayModuleData = NULL;
 static struct LedModuleData *ShmLedModuleData = NULL;
 static struct OCPP16Data *ShmOCPP16Data = NULL;
+static struct OCPP20Data* ShmOCPP20Data = NULL;
 
 static SelectGunInfo *ShmSelectGunInfo = NULL;
 static DcCommonInfo *ShmDcCommonData = NULL;
@@ -300,6 +301,15 @@ void *GetShmOCPP16Data(void)
     return ShmOCPP16Data;
 }
 
+void* GetShmOCPP20Data(void)
+{
+    if (ShmOCPP20Data == NULL) {
+        return NULL;
+    }
+
+    return ShmOCPP20Data;
+}
+
 void *GetShmSelectGunInfo(void)
 {
     if (ShmSelectGunInfo == NULL) {
@@ -602,6 +612,21 @@ int InitOCPPShmMem(void)
     return PASS;
 }
 
+int InitOCPP20ShmMem(void)
+{
+    int MeterSMId = FAIL;
+
+    if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), IPC_CREAT | 0777)) < 0) {
+        log_info("Get OCPP20 share memory error");
+        return FAIL;
+    } else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void*)-1) {
+        log_info("Create OCPP20 share memory error");
+        return FAIL;
+    }
+
+    return PASS;
+}
+
 int InitLEDShmMem(void)
 {
     int MeterSMId = FAIL;
@@ -1123,6 +1148,10 @@ int CreateAllCsuShareMemory(void)
         return ret;
     }
 
+    if ((ret = InitOCPP20ShmMem()) == FAIL) {
+        return ret;
+    }
+
     if ((ret = InitSelectGunShmMem()) == FAIL) {
         return ret;
     }

+ 1 - 0
EVSE/Projects/DD360Tcci/Apps/ShareMemory/shmMem.h

@@ -42,6 +42,7 @@ void *GetShmSysInfoData(void);
 void *GetShmSysWarningInfo(void);
 
 void *GetShmOCPP16Data(void);
+void* GetShmOCPP20Data(void);
 
 void *GetShmCHAdeMOData(void);
 void *GetShmGBTData(void);

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


BIN
EVSE/Projects/DD360Tcci/output/FactoryConfig


BIN
EVSE/Projects/DD360Tcci/output/Module_ChkSysTask


BIN
EVSE/Projects/DD360Tcci/output/Module_DoComm


BIN
EVSE/Projects/DD360Tcci/output/Module_EvComm


BIN
EVSE/Projects/DD360Tcci/output/Module_EventLogging


BIN
EVSE/Projects/DD360Tcci/output/Module_InternalComm


BIN
EVSE/Projects/DD360Tcci/output/Module_LcmControl


BIN
EVSE/Projects/DD360Tcci/output/Module_PrimaryComm


BIN
EVSE/Projects/DD360Tcci/output/Module_UpdateFW


BIN
EVSE/Projects/DD360Tcci/output/ReadCmdline


BIN
EVSE/Projects/DD360Tcci/output/main


+ 108 - 41
EVSE/Projects/DD360UCar/Apps/CSU/main.c

@@ -82,8 +82,8 @@ uint8_t bd0_2_status = 0;
 uint8_t bd1_1_status = 0;
 uint8_t bd1_2_status = 0;
 
-char *fwVersion = "V2.05.00.0000.00"; // Phihong version
-char* DebugVersion = "V2.05.01";      // Software debug version
+char *fwVersion = "V2.06.00.0000.00"; // Phihong version
+char* DebugVersion = "V2.06.00";      // Software debug version
 //sqlite3 *localDb;
 bool isDb_ready;
 
@@ -357,52 +357,106 @@ static void checkGunOTPState(uint8_t gunIndex)
 
     //水冷機溫度檢測
     if (((ShmDcCommonData->ChillerValve.MultiChillerGun & 0x80) >> 7) == YES) {
-        if (pDcChargingInfo->ChillerTemp != UNDEFINED_TEMP) {
-            if (pDcChargingInfo->ChillerTemp >= GUN_OTP_VALUE) {
-                if (((gunIndex == 0) &&
-                        ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
-                         (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0)))
-                         ||
-                    ((gunIndex == 1) &&
-                        ((strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
-                         (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0)))
-                   ) {
-                    RecordAlarmCode(gunIndex, "012323");
+        if ((ShmDcCommonData->ChillerValve.MultiChillerGun & 0x7F) == 1) {
+            // 單水冷機
+            // Chiller OTP
+            if (ShmDcCommonData->SystemTemp[0] == UNDEFINED_TEMP || ShmDcCommonData->SystemTemp[1] == UNDEFINED_TEMP) {
+                // 溫度為255時判斷Sensor fail
+                ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerOTP = NO;
+                ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTempSensorFail = YES;
+            } else {
+                //判斷OTP
+                if (ShmDcCommonData->SystemTemp[0] >= pSysInfo->OTPTemp || ShmDcCommonData->SystemTemp[1] >= pSysInfo->OTPTemp) {
                     ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerOTP = YES;
-                }
-                else
-                {
+                    RecordAlarmCode(gunIndex, "012323");
+                } else if (ShmDcCommonData->SystemTemp[0] != 0 && ShmDcCommonData->SystemTemp[0] < pSysInfo->OTPTempR &&
+                    ShmDcCommonData->SystemTemp[1] != 0 && ShmDcCommonData->SystemTemp[1] < pSysInfo->OTPTempR) {
                     ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerOTP = NO;
                 }
-            } else if (pDcChargingInfo->ChillerTemp != 0 &&
-                       pDcChargingInfo->ChillerTemp < GUN_OTP_RECOVERY) {
-                //ResetChargerAlarmCode(gunIndex, "012323");
-                ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerOTP = NO;
+                ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTempSensorFail = NO;
             }
-            ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTempSensorFail = NO;
-        } else {
-            // 沒接上 Sensor or 異常
-            //RecordAlarmCode(gunIndex, "011038");
-            //ResetChargerAlarmCode(gunIndex, "012323");
-            ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerOTP = NO;
-            if (((gunIndex == 0) &&
-                    ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
-                     (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0)))
-                     ||
-                ((gunIndex == 1) &&
-                    ((strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
-                     (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0)))
-               ) {
+            // Chiller Tube OTP
+            if (ShmDcCommonData->SystemTemp[2] == UNDEFINED_TEMP || ShmDcCommonData->SystemTemp[3] == UNDEFINED_TEMP) {
+                // 溫度為255時判斷Sensor fail
+                ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTubeOTP = NO;
                 ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTempSensorFail = YES;
-            }
-            else
-            {
+            } else {
+                //判斷OTP
+                if (ShmDcCommonData->SystemTemp[2] >= pSysInfo->OTPTemp || ShmDcCommonData->SystemTemp[3] >= pSysInfo->OTPTemp) {
+                    ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTubeOTP = YES;
+                    RecordAlarmCode(gunIndex, "012332");
+                } else if (ShmDcCommonData->SystemTemp[2] != 0 && ShmDcCommonData->SystemTemp[2] < pSysInfo->OTPTempR &&
+                    ShmDcCommonData->SystemTemp[3] != 0 && ShmDcCommonData->SystemTemp[3] < pSysInfo->OTPTempR) {
+                    ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTubeOTP = NO;
+                }
                 ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTempSensorFail = NO;
             }
+        } else {
+            // 雙水冷機
+            if (gunIndex == LEFT_GUN_NUM) {
+                if (ShmDcCommonData->SystemTemp[0] == UNDEFINED_TEMP) {
+                    // 溫度為255時判斷Sensor fail
+                    ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerOTP = NO;
+                    ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTempSensorFail = YES;
+                } else {
+                    //判斷OTP
+                    if (ShmDcCommonData->SystemTemp[0] >= pSysInfo->OTPTemp) {
+                        ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerOTP = YES;
+                        RecordAlarmCode(gunIndex, "012323");
+                    } else if (ShmDcCommonData->SystemTemp[0] != 0 && ShmDcCommonData->SystemTemp[0] < pSysInfo->OTPTempR) {
+                        ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerOTP = NO;
+                    }
+                    ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTempSensorFail = NO;
+                }
+                if (ShmDcCommonData->SystemTemp[1] == UNDEFINED_TEMP) {
+                    // 溫度為255時判斷Sensor fail
+                    ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTubeOTP = NO;
+                    ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTempSensorFail = YES;
+                } else {
+                    //判斷OTP
+                    if (ShmDcCommonData->SystemTemp[1] >= pSysInfo->OTPTemp) {
+                        ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTubeOTP = YES;
+                        RecordAlarmCode(gunIndex, "012332");
+                    } else if (ShmDcCommonData->SystemTemp[1] != 0 && ShmDcCommonData->SystemTemp[1] < pSysInfo->OTPTempR) {
+                        ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTubeOTP = NO;
+                    }
+                    ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTempSensorFail = NO;
+                }
+            } else {
+                if (ShmDcCommonData->SystemTemp[2] == UNDEFINED_TEMP) {
+                    // 溫度為255時判斷Sensor fail
+                    ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerOTP = NO;
+                    ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTempSensorFail = YES;
+                } else {
+                    //判斷OTP
+                    if (ShmDcCommonData->SystemTemp[2] >= pSysInfo->OTPTemp) {
+                        ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerOTP = YES;
+                        RecordAlarmCode(gunIndex, "012323");
+                    } else if ( ShmDcCommonData->SystemTemp[2] != 0 && ShmDcCommonData->SystemTemp[2] < pSysInfo->OTPTempR) {
+                        ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerOTP = NO;
+                    }
+                    ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTempSensorFail = NO;
+                }
+                if (ShmDcCommonData->SystemTemp[3] == UNDEFINED_TEMP) {
+                    // 溫度為255時判斷Sensor fail
+                    ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTubeOTP = NO;
+                    ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTempSensorFail = YES;
+                } else {
+                    //判斷OTP
+                    if (ShmDcCommonData->SystemTemp[3] >= pSysInfo->OTPTemp) {
+                        ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTubeOTP = YES;
+                        RecordAlarmCode(gunIndex, "012332");
+
+                        log_info("Right Gun Chiller Tube OTP");
+                    } else if (ShmDcCommonData->SystemTemp[2] != 0 && ShmDcCommonData->SystemTemp[3] < pSysInfo->OTPTempR) {
+                        ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTubeOTP = NO;
+                    }
+                    ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTempSensorFail = NO;
+                }
+            }
         }
 
-        if(pFaultCode->FaultEvents.bits.CcsLiquidChillerWaterLevelFault == YES)
-        {
+        if(pFaultCode->FaultEvents.bits.CcsLiquidChillerWaterLevelFault == YES) {
             RecordAlarmCode(gunIndex, "011037");
         }
     }
@@ -679,6 +733,12 @@ static void checkChillerAlarmState(void)
     } else {
         pFaultCode->FaultEvents.bits.ChillerTempSensorBroken = NO;
     }
+
+    if (DetectBitValue(gChillerTempErr.TempErrMsg, 2)) {
+        pAlarmCode->AlarmEvents.bits.ChillerTubeOTP = YES;
+    } else {
+        pAlarmCode->AlarmEvents.bits.ChillerTubeOTP = NO;
+    }
 }
 
 static void checkEvBoardAlarmState(uint8_t gunType)
@@ -1658,6 +1718,8 @@ void ResetChargerAlarmCode(uint8_t gunIndex, char *code)
         ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerOTP = NO;
     } else if (strcmp(code, "011038") == EQUAL) {
         ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTempSensorFail = NO;
+    } else if (strcmp(code, "012332") == EQUAL) {
+        ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTubeOTP = NO;
     }
 
     if (strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012229", 6) == EQUAL ||
@@ -1673,7 +1735,8 @@ void ResetChargerAlarmCode(uint8_t gunIndex, char *code)
             strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011019", 6) == EQUAL ||
             strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011020", 6) == EQUAL ||
             strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012323", 6) == EQUAL ||
-            strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011038", 6) == EQUAL) {
+            strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011038", 6) == EQUAL ||
+            strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012332", 6) == EQUAL) {
         strncpy((char *)pDcChargingInfo->ConnectorAlarmCode, "", 6);
     }
 }
@@ -1681,17 +1744,18 @@ void ResetChargerAlarmCode(uint8_t gunIndex, char *code)
 void RecordAlarmCode(uint8_t gunIndex, char *code)
 {
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
-
     if((pDcChargingInfo->SystemStatus > S_IDLE && pDcChargingInfo->SystemStatus < S_TERMINATING) ||
         (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 && pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1))
     {
         if (strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "", 6) == EQUAL) {
             memcpy(pDcChargingInfo->ConnectorAlarmCode, code, 6);
+
         }
 
         if (pDcChargingInfo->StopChargeFlag == NO)
         {
             pDcChargingInfo->StopChargeFlag = YES;
+
         }
     }
 }
@@ -3978,6 +4042,9 @@ int main(void)
 
     CreateWatchdog();
     int is_idle = TRUE;
+    pSysInfo->OTPTemp = GUN_OTP_VALUE;
+    pSysInfo->OTPTempR = GUN_OTP_RECOVERY;
+
     for (;;) {
 
         CheckOcppStatus();

+ 35 - 2
EVSE/Projects/DD360UCar/Apps/Config.h

@@ -397,7 +397,8 @@ typedef union {
     struct {
         uint8_t ChillerOTP: 1;            //chiller Temperature OVP
         uint8_t ChillerTempSensorFail: 1; //Chiller temperature sensor failure
-        uint8_t Reserved: 6;
+        uint8_t ChillerTubeOTP : 1;
+        uint8_t Reserved: 5;
     } StatusBit;
 } ChillerTempErr;
 
@@ -413,6 +414,30 @@ typedef struct StPcPsuOutput { //from power cabinet PSU output
     uint16_t Current;
 } PcPsuOutput;
 
+typedef struct StPowerConsumptionInfo {
+    float Gun1_Consumption;
+    float Gun2_Consumption;
+    float Gun3_Consumption;
+    float Gun4_Consumption;
+} PowerConsumptionValue;
+
+typedef struct StPowConsumValue {
+    uint32_t Gun1_Consumption;
+    uint32_t Gun2_Consumption;
+    uint32_t Gun3_Consumption;
+    uint32_t Gun4_Consumption;
+} PowConsumValue;
+
+typedef struct StGunInfo {
+    int ConnectorID;
+    char ReceiptInfo[255];
+    int finalcost_flag;
+    time_t EVLoseTimer;
+    uint8_t EVLoseFlag;
+    char ReservationID[32];
+    uint8_t ReservationStatus;
+} GunInfo;
+
 typedef struct Psu_VersionInfo{
 	uint8_t n_PSU;
 	uint8_t DCVersion[32];
@@ -505,7 +530,7 @@ typedef struct StDcCommonInfo {
     unsigned int TradeCancel;
     int reupload_deduct_status;		// 0:Not ReUpload 1:ReUpload 2:ReUpload finish
     RecordTransactionInfo TransactionInfo[2];
-    int TzOffset;
+    int TZOffset;
     int DebugFlag;
     int chillerCtrl;
     time_t EVDisconnectTime[2];
@@ -515,6 +540,14 @@ typedef struct StDcCommonInfo {
     time_t LedDisconnectTime;
     time_t FanDisconnectTime;
     int DemoCount;
+    char QRCodeString[255];
+    GunInfo pGunInfo[2];
+    char DefaultPriceString[255];
+    char UserPriceString[255];
+    PowerConsumptionValue pConsumption;
+    uint8_t AuthroizeType; // 0: Central   1: eMAID    2: ISO14443 3: ISO15693 4: KeyCode  5: Local    6: MacAddress   7: NoAuthorization
+    uint8_t showNetPackage;
+    uint8_t showCanPackage;
 } DcCommonInfo;
 
 #endif /* CONFIG_H_ */

+ 1 - 1
EVSE/Projects/DD360UCar/Apps/Define/define.c

@@ -241,7 +241,7 @@ char AlarmStatusCode[160][6]=
 "012329",   // Psu Can Communication Fault
 "012330",   // Psu Dc to Dc OTP
 "012331",   // Psu Dc to Dc OVP
-"012332",   // reserved
+"012332",   // Chiller Tube OTP
 "012333",   // reserved
 "012334",   // reserved
 "012335",   // reserved

+ 32 - 30
EVSE/Projects/DD360UCar/Apps/Define/define.h

@@ -187,6 +187,7 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
 #define ShmOcpp20ModuleKey		1012
 #define ShmRelay2BdKey			1013
 #define ShmYesCustomKey         1014
+#define ShmOcppPHModuleKey      1015
 
 #define FaultCodeLength         5
 #define AlarmCodeLength         20
@@ -327,6 +328,10 @@ enum CoreProfile {
      MaintainServer,
      StatusNotificationPeriodically,
      StatusNotificationInterval,
+     PreAuthAmount,
+     isEnableLocalPowerSharing,
+     PowerSharingServerIP,
+     EVCCID_PREFIX,
      ConfigurationVersion,
 	 _CoreProfile_CNT
 };
@@ -340,10 +345,11 @@ enum OCPP_START_ID_TYPE {
     IdTokenType_Central=0,
     IdTokenType_eMAID,
     IdTokenType_ISO14443,
+    IdTokenType_ISO15693,
     IdTokenType_KeyCode,
     IdTokenType_Local,
-    IdTokenType_NoAuthorization,
-    IdTokenType_ISO15693
+    IdTokenType_MacAddress,
+    IdTokenType_NoAuthorization
 };
 /**************************************************************************************/
 /****structure SysConfigData => shall store the data to NAND flash****************/
@@ -379,7 +385,8 @@ struct TeleConfigData
 {
 	unsigned char		TelcomModelName[64];		//default: Null
 	unsigned char		TelcomSoftwareVer[64];		//default: Null
-	unsigned char		TelcomApn[256];				//default: Null
+	unsigned char		TelcomApn[255];				//default: Null
+	unsigned char		TelcomNetworkType;			//0: Auto	1: CDMA	 2: WCDMA  3: LTE  4: TD-SCDMA  5: UMTS  6: CDMA  7: HDR  8: CDMA/HDR
 	int					TelcomRssi;					//dbm
 	unsigned char		TelcomChapPapId[256];		//default: Null
 	unsigned char		TelcomChapPapPwd[256];		//default: Null
@@ -460,7 +467,7 @@ struct TTIA
 
 struct LocalSharingInfo
 {
-    unsigned short      AvailableShargingCurrent;       // 0 ~ rating value amp,  Synchronize from local sharing server
+    unsigned short      AvailableShargingCurrent[4];    // 0 ~ rating value amp,  Synchronize from local sharing server
     unsigned char       isConnectedSharingServer:1;     // 0: Disconnected, 1: Connected
 };
 
@@ -571,7 +578,7 @@ struct SysConfigData
 	struct LED				LedInfo;					// LED configuration info
 	unsigned char			ShowInformation;
 	unsigned char           isReqFirstUpgrade;          //EVSE is request first upgrade from PH server
-	unsigned char           isEnableLocalPowerSharging; //0: Disable power sharing  1: Enable power sharing
+	unsigned char           isEnableLocalPowerSharing;  //0: Disable power sharing  1: Master   2: Slave
 	unsigned char           StopChargingByButton;       //0: Disable  1: Enable
     struct LCD_NOUSE        Legacy_LcdOveride;          // LCD override info (no use anymore)
     struct TTIA             TTIA_Info;                  // TTIA configuration struct
@@ -584,6 +591,7 @@ struct SysConfigData
     unsigned char           MaintainServerURL[512];             // ws: non-secure OCPP 1.6-J, wss: secure OCPP 1.6-J"
     unsigned char           MaintainServerSecurityProfile;      // Maintain server security profile 0~3
     unsigned char           MaintainServerSecurityPassword[41]; // Maintain server AuthorizationKey for security profile
+    unsigned char           PowerSharingServerIP[512];          // Local power sharing server ip address
 };
 
 struct ChargingInfoData
@@ -623,7 +631,7 @@ struct ChargingInfoData
 	unsigned char PilotState;//1:state A, 2:State B1, 3:State B2, 4:State C, 5:State D, 6:State E, 7:State F, 8: Pilot error
 	unsigned char PilotDuty;					// 0~100%
 	unsigned char			StartUserId[32];			// This ID is trigger start charging event user by RFID, back-end, BLE.
-	unsigned char           StartIdType;                // 0: Central   1: eMAID    2: ISO14443 3: ISO15693 4: KeyCode  5: Local    6: MaxAddress   7: NoAuthorization
+	unsigned char           StartIdType;                // 0: Central   1: eMAID    2: ISO14443 3: ISO15693 4: KeyCode  5: Local    6: MacAddress   7: NoAuthorization
 	unsigned char			StartDateTime[32];			// Charging cycle start date time
 	unsigned char			StopDateTime[32];			// Charging cycle stop date time
 	unsigned char			StartMethod;
@@ -699,7 +707,7 @@ typedef struct
     unsigned char       AuthType;                       // 0: _AuthType_None,   1: _AuthType_RFID, 2: _AuthType_RemoteStart
     unsigned char       AuthResult;                     // 0: _AuthResult_None, 1: _AuthResult_Valid,   2: _AuthResult_Invalid
     unsigned char       AuthRequest;                    // 0: no request, 1: authorize request
-    unsigned char       res;
+    unsigned char       AuthIdType;
 }AuthorizingInfoData;
 
 typedef union
@@ -718,16 +726,7 @@ typedef union
         unsigned int FirmwareUpdateRequest:1;           // firmware update request
         unsigned int FirmwareUpdateConfirm:1;           // firmware update start
         unsigned int FirmwareUpdateCompleted:1;         // firmware update completed
-        unsigned int BackendStatusRequest:1;            // 0: no request,   1: backend connection status has changed            ( cabinet -> dispenser)
-        unsigned int EthernetStatusRequest:1;           // 0: no request,   1: ethernet connection status has changed           ( cabinet -> dispenser)
-        unsigned int WiFiStatusRequest:1;               // 0: no request,   1: wifi connection status has changed               ( cabinet -> dispenser)
-        unsigned int TelcomModemStatusRequest:1;        // 0: no request,   1: 4g connection status has changed                 ( cabinet -> dispenser)
-        unsigned int BillingStatusRequest:1;            // 0: no request,   1: billing status has changed                       ( cabinet -> dispenser)
-        unsigned int StopButtonStatusRequest:1;         // 0: no request,   1: stop charging button status has changed          ( cabinet -> dispenser)
-        unsigned int AuthModeConfigRequest:1;           // 0: no request,   1: AuthMode Config has changed                      ( cabinet -> dispenser)
-        unsigned int EVCCIDConfigRequest:1;             // 0: no request,   1: EVCCID Config has changed                        ( cabinet -> dispenser)
-        unsigned int LEDIntensityRequest:1;             // 0: no request,   1: LED Intensity has changed                        ( cabinet -> dispenser)
-        unsigned int res:12;
+        unsigned int res:21;
     }bits;
 }DispenserSettingFlag;
 
@@ -744,7 +743,7 @@ struct DispenserModule
     unsigned char   RfidCardNumEndian;          //0: little endian,  1: big endian
     unsigned char   isAPP;                      //for AuthorisationMode=0; 0:false, 1:true
     unsigned char   isQRCode;                   //for AuthorisationMode=0; 0:false, 1:true
-    unsigned char   isRFID;                     //for AuthorisationMode=0; 0:false, 1:true
+    unsigned char   isRFID;                     //for AuthorisationMode=0; 0:false, 1:true; for Noodoe Credit Card +2^1:true
     unsigned char   QRCodeMadeMode;             //for isQRCode=1 ; 0: default	1:customized
     unsigned char   QRCodeContent[128];         //for QRCodeMadeMode=1
 
@@ -837,7 +836,7 @@ typedef union
         unsigned int  Disconnection:1;
         unsigned int  GfdDetection:1;                   // 0: stop,         1: start
         unsigned int  GetStartChargingSoc:1;            // 0: no effect,    1: get start soc
-        unsigned int  res:14;
+        unsigned int  res:13;
     }bits;
 }ConnectorParameter;
 
@@ -877,7 +876,9 @@ struct ConnectorInfoData
     float                   UserPrice;                      // connector user's user price, unit: 1 (dollar / kWh)
     float                   TotalCost;                      // connector user's total cost, unit: 1 dollar
     float                   AccountBalance;                 // connector user's account balance, unit: 1 dollar
-    float                   CostDiscount;                   // connector user's account balance, unit: 1 dollar
+    float                   CostDiscount;                   // connector user's Discount or couponPoint, unit: 1 point
+    float                   EnergyCost;                     // connector user's energy cost, unit: 1 dollar
+    float                   ParkingFee;                     // connector user's parking fee, unit: 1 dollar
 };
 
 typedef union
@@ -1321,7 +1322,7 @@ char AlarmStatusCode[160][6]=
     "012329",   // Psu Can Communication Fault
     "012330",   // Psu Dc to Dc OTP
     "012331",   // Psu Dc to Dc OVP
-    "012332",   // reserved
+    "012332",   // Chiller Tube OTP
     "012333",   // reserved
     "012334",   // reserved
     "012335",   // reserved
@@ -1508,7 +1509,8 @@ struct AlarmCodeData
             unsigned char PsuCanCommFault:1;                        //bit 1
             unsigned char PsuDcDcOtp:1;                             //bit 2
             unsigned char PsuDcDcOvp:1;                             //bit 3
-            unsigned char :4;                                       //reserved bit 4 ~ bit 7
+			unsigned char ChillerTubeOTP : 1;                       //bit 4
+            unsigned char :3;                                       //reserved bit 5 ~ bit 7
     //AlarmVal[17]
             unsigned char :8;                                       //reserved bit 0 ~ bit 7
             //AlarmVal[18]
@@ -2300,7 +2302,7 @@ struct PsuData
 	unsigned char           GroupCount;
 	unsigned char           Work_Step;
 	struct PsuModuleVer     PsuVersion[MAX_PSU_QUANTITY];
-	unsigned char 			PsuStopChargeFlag;
+	unsigned char           PsuStopChargeFlag;
 };
 
 /************************************************************************************/
@@ -4418,7 +4420,7 @@ struct OCPP16ConfigurationTable
 struct StrcutSetUserPrice
 {
     unsigned char   idToken[21];
-    unsigned char   price[256];
+    unsigned char   price[1024];
 };
 
 struct ChargingPrice
@@ -4462,13 +4464,13 @@ struct StrcutRunningCost
     struct IdlePrice        idlePrice;              // (optional) Price components while not charging. Optional if no idle fee is charged.
     struct NextPeriod       nextPeriod;             // (optional) Pricing for next period
     struct Triggers         triggerMeterValue;      // (optional) Triggers to request a new meter value. Optional if no idle fee charged.
-    unsigned char           description[256];       // Compatible California pricing V1.0
+    unsigned char           description[1024];      // Compatible California pricing V1.0
 };
 
 struct StrcutFinalCost
 {
     int             txId;
-    unsigned char   description[256];
+    unsigned char   description[1024];
 };
 
 struct StructCost
@@ -4617,8 +4619,8 @@ struct StructCreditDeductResult
 
 struct StructReaderStatus
 {
-	int readerStatus;
-	unsigned char creditNo[64];
+    int readerStatus;
+    unsigned char creditNo[64];
     unsigned char ReportReaderStatusReq:1;
 };
 
@@ -4630,7 +4632,7 @@ struct StructTcciCustomData
     struct StructReaderStatus ReaderStatus[CONNECTOR_QUANTITY];
     unsigned char TriggerReaderReq[3];
     unsigned char SerialNo[CONNECTOR_QUANTITY][37];
-	unsigned char VEMData[CONNECTOR_QUANTITY][65];
+    unsigned char VEMData[CONNECTOR_QUANTITY][65];
 
     unsigned char ReportCreditDeductReq:1;
     unsigned char ChargerInfoReq:1;
@@ -5144,7 +5146,7 @@ struct ChargingScheduleType
 
 struct ChargingProfileType
 {
-	unsigned short int id;											// Required. Id of ChargingProfile.
+	int id;											                // Required. Id of ChargingProfile.
 	unsigned short int stackLevel;									// Required. Value determining level in hierarchy stack of profiles. Higher values have precedence over lower values. Lowest level is 0.
 	unsigned char chargingProfilePurpose[36];						// Required. Defines the purpose of the schedule transferred by this profile
 	unsigned char chargingProfileKind[16];							// Required. Indicates the kind of schedule.

+ 435 - 126
EVSE/Projects/DD360UCar/Apps/ModuleDoComm/DoComm.c

@@ -59,7 +59,8 @@ static uint8_t DeductResultReq[2] = {0};
 static int LineStatusCode[2] = {0};
 static unsigned int LedIntensity = 0;
 static int TimeZoneOffset = 0;
-
+int RxLen;
+char Rxdata[1024];
 //------------------------------------------------------------------------------
 static void removeFaultCodeToBuf(uint8_t *Code);
 static void addFaultCodeToBuf(uint8_t *Code);
@@ -157,6 +158,23 @@ static int string2ByteArray(char *input, uint8_t *output)
     return loop + 1;
 }
 
+int string2Date(char* input, uint8_t* output)
+{
+    int loop = 0;
+    int i = 0;
+
+    while (input[loop] != '\0') {
+        loop++;
+    }
+    loop++;
+
+    while (input[loop] != '\0') {
+        output[i++] = input[loop++];
+    }
+    output[loop] = '\0';
+
+    return loop + 1;
+}
 static void unixSocketSigPipeHandle(int sig)
 {
     log_error("socket packet error %x", sig);
@@ -181,11 +199,28 @@ static void setTcpStatus(uint8_t setValue)
 //------------------------------------------------------------------------------
 //--- TCP socket function ---
 //------------------------------------------------------------------------------
-static int sendTcpSocket(int fd, uint8_t *data, uint16_t dataLen)
+static int sendTcpSocket(int fd, uint8_t* data, uint16_t dataLen)
 {
     int size = -1;
+    int i;
+    char _info[1024];
+    int len = 0;
+
+    // ReadCmdline show network package
+    if (ShmDcCommonData->showNetPackage) {
+        len = 0;
+        len += sprintf(&_info[len], "Net Tx[%d]:", dataLen);
+        for (i = 0; i < dataLen; i++) {
+            if (i == 0)
+                len += sprintf(&_info[len], "[%X]\t", data[i]);
+            else
+                len += sprintf(&_info[len], "%X ", data[i]);
+        }
+        len += sprintf(&_info[len], "\n");
+        printf("%s", _info);
+    }
 
-    size = send(fd, data, dataLen , 0);
+    size = send(fd, data, dataLen, 0);
     if ((size < 0) || (errno == EAGAIN)) {
         if (size < 0) {
             log_error("Send Socket Size = %d, EAGAIN error %d:%s", size, errno, strerror(errno));
@@ -195,15 +230,34 @@ static int sendTcpSocket(int fd, uint8_t *data, uint16_t dataLen)
     return size;
 }
 
-static int recvTcpSocket(int fd, uint8_t *data, uint16_t dataLen)
+static int recvTcpSocket(int fd, uint8_t* data, uint16_t dataLen, uint8_t ishead)
 {
     int size = -1;
-    uint8_t *pdata = (uint8_t *)data;
+    int i;
+    uint8_t* pdata = (uint8_t*)data;
 
     size = recv(fd, pdata, dataLen, MSG_WAITALL);
     if ((errno == EAGAIN) || (size < 0)) {
         log_error("Receive Socket Size = %d, EAGAIN error %d:%s", size, errno, strerror(errno));
     }
+    // ReadCmdline show network package
+    if (ShmDcCommonData->showNetPackage) {
+        if (ishead) {
+            RxLen = 0;
+            RxLen += sprintf(&Rxdata[RxLen], "Net Rx[%d]:", size);
+        }
+        for (i = 0; i < dataLen; i++) {
+            if (ishead && i == 0)
+                RxLen += sprintf(&Rxdata[RxLen], "[%X]\t", data[i]);
+            else
+                RxLen += sprintf(&Rxdata[RxLen], "%X ", data[i]);
+        }
+        if (!ishead) {
+            RxLen += sprintf(&Rxdata[RxLen], "\n");
+            printf("%s", Rxdata);
+            strcpy(Rxdata, "");
+        }
+    }
 
     return size;
 }
@@ -427,7 +481,15 @@ static void clearMiscCommand(void)
 {
     gDoCommGblData.MiscCmd = 0;
 }
-
+int timecmp(uint8_t* time1, uint8_t* time2)
+{
+    for (int i = 0; i < strlen(time1); i++) {
+        if (time1[i] != time2[i]) {
+            return FALSE;
+        }
+    }
+    return TRUE;
+}
 static int qrCodeUrlInfoHandle(uint8_t *data)
 {
     //int len = 0;
@@ -436,7 +498,8 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
     uint16_t timeLen = 0;
     struct timeb SeqEndTime;
     struct tm *tm;
-
+    char _setTime[50];
+    uint8_t cmdBuf[128];
     if ((char *)&data[0] == '\0') {
         log_error("QR code date error");
         return FAIL;
@@ -454,19 +517,21 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
                       tm->tm_min);
 
     //copy QR code string
-    if (strncmp((char *)localTime, (char *)&data[0], timeLen - 2) != 0) {
-        memset(pSysConfig->SystemId, '\0', sizeof(pSysConfig->SystemId));
-        //printf("data =  %s", data);
-        //len =
+    memset(ShmDcCommonData->QRCodeString, '\0', sizeof(ShmDcCommonData->QRCodeString));
+    //printf("data =  %s", data);
+    //len =
 
-        string2ByteArray((char *)data, (uint8_t *)pSysConfig->SystemId);
-        //printf("SystemId =  %s", pSysConfig->SystemId);
-        //log_info("SystemId:%s",pSysConfig->SystemId);
+    string2ByteArray((char *)data, (uint8_t *)ShmDcCommonData->QRCodeString);
+    string2Date((char*)data, (uint8_t*)_setTime);
+    //printf("SystemId =  %s", pSysConfig->SystemId);
+    if (!timecmp(localTime, _setTime)) {
+        log_info("Set Timer:%s", _setTime);
+        sprintf((char*)cmdBuf, "date -u -s \"%s\" >> /dev/null &", _setTime);
+        system((char*)cmdBuf);
+        system("hwclock -w -u");
+        system("hwclock -s");
     }
-    sprintf(ShmDcCommonData->PresentTime, "%04d/%02d/%02d",
-                      tm->tm_year + 1900,
-                      tm->tm_mon + 1,
-                      tm->tm_mday);
+
 
     //if ((char *)&data[len] == '\0') {
     //    log_error("power cabinet system date error");
@@ -839,7 +904,34 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
         case MISC_CMD_TIME_OFFSET:
             TimeZoneOffset = value;
             log_info("Time Zone Offset: %d", TimeZoneOffset);
-            ShmDcCommonData->TzOffset = TimeZoneOffset;
+            ShmDcCommonData->TZOffset = TimeZoneOffset;
+            /*
+            if (TimeZoneOffset == 480) {
+                system("export TZ=CST-8");
+                log_info("Set Time Zone CST 8");
+            }
+            */
+            break;
+        case MISC_CMD_DEFAULT_PRICE_REQ:
+            if (value != YES)
+            {
+                break;
+            }
+            gMoreInfoReq[plugNum].bits.DefaultPriceReq = YES;
+            break;
+        case MISC_CMD_USER_PRICE_REQ:
+            if (value != YES)
+            {
+                break;
+            }
+            gMoreInfoReq[plugNum].bits.UserPriceReq = YES;
+            break;
+        case MISC_CMD_RECEIPT_REQ:
+            if (value != YES)
+            {
+                break;
+            }
+            gMoreInfoReq[plugNum].bits.ReceiptReq = YES;
             break;
         default:
             clearMiscCommand();
@@ -917,25 +1009,38 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
     ShmSelectGunInfo->PricesInfo[plugNum].Balance    = transPricesUnit(ntohl(pAccountInfo->Balance));
     ShmSelectGunInfo->PricesInfo[plugNum].Discount   = transPricesUnit(ntohl(pAccountInfo->Discount));
     ShmSelectGunInfo->PricesInfo[plugNum].TransactionId = ntohl(pAccountInfo->Transaction);
+    ShmSelectGunInfo->PricesInfo[plugNum].EnergyCost = transPricesUnit(ntohl(pAccountInfo->EnergyCost));
+    ShmSelectGunInfo->PricesInfo[plugNum].ParkingFee = transPricesUnit(ntohl(pAccountInfo->ParkingFee));
 
     if ((pricesInfo[plugNum].UserPrices != ShmSelectGunInfo->PricesInfo[plugNum].UserPrices) ||
             (pricesInfo[plugNum].Balance != ShmSelectGunInfo->PricesInfo[plugNum].Balance) ||
 			(pricesInfo[plugNum].Discount != ShmSelectGunInfo->PricesInfo[plugNum].Discount) ||
-			(pricesInfo[plugNum].TransactionId != ShmSelectGunInfo->PricesInfo[plugNum].TransactionId)) {
+			(pricesInfo[plugNum].TransactionId != ShmSelectGunInfo->PricesInfo[plugNum].TransactionId) ||
+            (pricesInfo[plugNum].EnergyCost != ShmSelectGunInfo->PricesInfo[plugNum].EnergyCost) ||
+            (pricesInfo[plugNum].ParkingFee != ShmSelectGunInfo->PricesInfo[plugNum].ParkingFee)) {
         pricesInfo[plugNum].UserPrices = ShmSelectGunInfo->PricesInfo[plugNum].UserPrices;
         pricesInfo[plugNum].Balance = ShmSelectGunInfo->PricesInfo[plugNum].Balance;
         pricesInfo[plugNum].Discount = ShmSelectGunInfo->PricesInfo[plugNum].Discount;
         pricesInfo[plugNum].TransactionId = ShmSelectGunInfo->PricesInfo[plugNum].TransactionId;
+        pricesInfo[plugNum].ParkingFee = ShmSelectGunInfo->PricesInfo[plugNum].ParkingFee;
+        pricesInfo[plugNum].EnergyCost = ShmSelectGunInfo->PricesInfo[plugNum].EnergyCost;
+        if (ShmSelectGunInfo->PricesInfo[plugNum].TransactionId != 0) {
 
-        log_info("id = %d, transaction id = %d, user prices = %.2f, Discount = %.2f, Total cost = %.2f, Account balances = %.2f, currency = %s",
-                 plugNum,
-				 ShmSelectGunInfo->PricesInfo[plugNum].TransactionId,
-                 ShmSelectGunInfo->PricesInfo[plugNum].UserPrices,
-				 ShmSelectGunInfo->PricesInfo[plugNum].Discount,
-                 pDcChargingInfo->ChargingFee,
-                 ShmSelectGunInfo->PricesInfo[plugNum].Balance,
-                 (uint8_t *)GetCurrency(pSysConfig->BillingData.Currency)
-                );
+            //ShmDcCommonData->TransactionInfo[plugNum].TransactionId = ShmSelectGunInfo->PricesInfo[plugNum].TransactionId;
+            //UpdateDeductInfoStatus(plugNum, &ShmDcCommonData->TransactionInfo[plugNum]);
+
+            log_info("id = %d, transaction id = %d, user prices = %.2f, Discount = %.2f, Account balances = %.2f, currency = %s",
+                plugNum,
+                ShmSelectGunInfo->PricesInfo[plugNum].TransactionId,
+                ShmSelectGunInfo->PricesInfo[plugNum].UserPrices,
+                ShmSelectGunInfo->PricesInfo[plugNum].Discount,
+                ShmSelectGunInfo->PricesInfo[plugNum].Balance,
+                (uint8_t*)GetCurrency(pSysConfig->BillingData.Currency)
+            );
+            log_info("Total Cost:%.2f", pDcChargingInfo->ChargingFee);
+            log_info("Parking Fee:%.2f", ShmSelectGunInfo->PricesInfo[plugNum].ParkingFee);
+            log_info("Energy Cost:%.2f", ShmSelectGunInfo->PricesInfo[plugNum].EnergyCost);
+        }
     }
 
     return PASS;
@@ -1300,15 +1405,24 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
         {
             strcpy(&ReservationIdTag[plugNum][0], (char *)&pCsuResult->Data.Data[1]);
         }
-        if(reservationState != ReservationState[plugNum])
+        if(reservationState != ReservationState[plugNum] || 
+            (strcmp((char*)ShmDcCommonData->pGunInfo[plugNum].ReservationID, (char*)ReservationIdTag[plugNum]) != EQUAL) )
         {
             log_info("id = %d reservation is %s", pCsuResult->Head.ID, reservationState ? "trigger" : "expired");
             if(reservationState)
             {
                 log_info("id = %d reservation idTag: %s", pCsuResult->Head.ID, (char *)&ReservationIdTag[plugNum][0]);
+                pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(plugNum);
+                strcpy(&ShmDcCommonData->pGunInfo[plugNum].ReservationID[0], (char*)&pCsuResult->Data.Data[1]);
+                
+                pDcChargingInfo->SystemStatus = S_RESERVATION;
+            } else {
+                if (pDcChargingInfo->SystemStatus == S_RESERVATION && pSysInfo->WaitForPlugit == NO)
+                    pDcChargingInfo->SystemStatus = S_IDLE;
             }
         }
         ReservationState[plugNum] = reservationState;
+        ShmDcCommonData->pGunInfo[plugNum].ReservationStatus = reservationState;
         break;
 
     case REG_REMOTE_START_NO_ID:
@@ -1361,7 +1475,69 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
             return COMMAND_RESULT_NG;
         }
         break;
-
+    case REG_READ_CABINET_SYSTEMID:
+        if (pCsuResult->Data.Result == COMMAND_RESULT_NG) {
+            return COMMAND_RESULT_NG;
+        }
+        if (strcmp((char*)pSysConfig->SystemId, (char*)pCsuResult->Data.Data) != 0) {
+            strcpy((char*)pSysConfig->SystemId, (char*)pCsuResult->Data.Data);
+            log_info("System ID:%s", pSysConfig->SystemId);
+        }
+        break;
+    case REG_READ_DEFAULT_PRICE:
+        if (pCsuResult->Data.Result == COMMAND_RESULT_NG) {
+            return COMMAND_RESULT_NG;
+        }
+        gMoreInfoReq[plugNum].bits.DefaultPriceReq = NO;
+        if (strcmp((char*)ShmDcCommonData->DefaultPriceString, (char*)pCsuResult->Data.Data) != EQUAL) {
+            strcpy((char*)ShmDcCommonData->DefaultPriceString, (char*)pCsuResult->Data.Data);
+            log_info("Default Price:%s", ShmDcCommonData->DefaultPriceString);
+        }
+        break;
+    case REG_READ_USER_PRICE:
+        if (pCsuResult->Data.Result == COMMAND_RESULT_NG) {
+            return COMMAND_RESULT_NG;
+        }
+        gMoreInfoReq[plugNum].bits.UserPriceReq = NO;
+        if (strcmp((char*)ShmDcCommonData->UserPriceString, (char*)pCsuResult->Data.Data) != EQUAL) {
+            strcpy((char*)ShmDcCommonData->UserPriceString, (char*)pCsuResult->Data.Data);
+            log_info("User Price:%s", ShmDcCommonData->UserPriceString);
+        }
+        break;
+    case REG_RECEIPT_INFO:
+        if (pCsuResult->Data.Result == COMMAND_RESULT_NG) {
+            return COMMAND_RESULT_NG;
+        }
+        gMoreInfoReq[plugNum].bits.ReceiptReq = NO;
+        if (strcmp((char*)ShmDcCommonData->pGunInfo[plugNum].ReceiptInfo, (char*)pCsuResult->Data.Data) != EQUAL) {
+            strcpy((char*)ShmDcCommonData->pGunInfo[plugNum].ReceiptInfo, (char*)pCsuResult->Data.Data);
+            log_info("Gun%d Receipt:%s", plugNum, ShmDcCommonData->pGunInfo[plugNum].ReceiptInfo);
+        }
+        break;
+    case REG_POWER_CONSUMPTION_INFO:
+        if (pCsuResult->Data.Result == COMMAND_RESULT_NG) {
+            return COMMAND_RESULT_NG;
+        }
+        
+        PowConsumValue* pValue =NULL;
+        pValue = (PowConsumValue*)&pCsuResult->Data.Data[0];
+
+        pValue->Gun1_Consumption = ntohl(pValue->Gun1_Consumption);
+        pValue->Gun2_Consumption = ntohl(pValue->Gun2_Consumption);
+        pValue->Gun3_Consumption = ntohl(pValue->Gun3_Consumption);
+        pValue->Gun4_Consumption = ntohl(pValue->Gun4_Consumption);
+        memcpy((char*)&ShmDcCommonData->pConsumption.Gun1_Consumption, (char*)&pValue->Gun1_Consumption, sizeof(uint32_t));
+        memcpy((char*)&ShmDcCommonData->pConsumption.Gun2_Consumption, (char*)&pValue->Gun2_Consumption, sizeof(uint32_t));
+        memcpy((char*)&ShmDcCommonData->pConsumption.Gun3_Consumption, (char*)&pValue->Gun3_Consumption, sizeof(uint32_t));
+        memcpy((char*)&ShmDcCommonData->pConsumption.Gun4_Consumption, (char*)&pValue->Gun4_Consumption, sizeof(uint32_t));
+
+        log_info("Gun1_Consumption:%f", ShmDcCommonData->pConsumption.Gun1_Consumption);
+        log_info("Gun2_Consumption:%f", ShmDcCommonData->pConsumption.Gun2_Consumption);
+        log_info("Gun3_Consumption:%f", ShmDcCommonData->pConsumption.Gun3_Consumption);
+        log_info("Gun4_Consumption:%f", ShmDcCommonData->pConsumption.Gun4_Consumption);
+        
+        
+        break;
     default:
         break;
     }
@@ -1400,11 +1576,6 @@ static int composeSocketData(int fd,
 
     // Not Let ask cabinet version trasmit into FAIL Network
 
-    if (reg == REG_CABINET_DCM_VERSION || reg == REG_CABINET_OTHER_VERSION ||
-    		reg == REG_TOTAL_PSU_QUANTITY || reg == REG_PSU_VERSION) {
-    	gDoCommGblData.DisConnCount = 0;
-    }
-
     //send command packet
     if ((size = sendTcpSocket(fd, (uint8_t *)&csuCmdPkt, sendPktLen)) < 0) {
         log_error("TCP socket send packet fail = %d", size);
@@ -1413,14 +1584,19 @@ static int composeSocketData(int fd,
     }
 
     //receive result head
-    if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Head, sizeof(csuResult.Head))) < 0) {
+    if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Head, sizeof(csuResult.Head),1)) < 0) {
         log_error("TCP socket RX head fail = %d", size);
-        gDoCommGblData.DisConnCount++;
+        // 若收不到以下封包,不產生錯誤
+        if (reg != REG_CABINET_DCM_VERSION && reg != REG_CABINET_OTHER_VERSION &&
+            reg != REG_TOTAL_PSU_QUANTITY && reg != REG_PSU_VERSION &&
+            reg != REG_READ_CABINET_SYSTEMID) {
+            gDoCommGblData.DisConnCount++;
+        }
         return FAIL;
     }
 
     //receive result raw data
-    if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Data, csuResult.Head.DataLen)) < 0) {
+    if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Data, csuResult.Head.DataLen,0)) < 0) {
         log_error("TCP socket RX data fail = %d", size);
         gDoCommGblData.DisConnCount++;
         return FAIL;
@@ -1514,12 +1690,12 @@ static int readChargerStationInfo(int fd)
 
     return ret;
 }
-
+/*
 static int writeDeductInfo(int fd, uint8_t id,uint8_t gunIndex, RecordTransactionInfo *transactionInfo)
 {
     int ret = PASS;
-    uint8_t dataBuf[22] = {0};
-    int i;
+    uint8_t dataBuf[104] = {0};
+    //int i;
 
     memset((char *)dataBuf, 0x00, sizeof(dataBuf));
     dataBuf[0] = transactionInfo->DeductResult;
@@ -1535,28 +1711,33 @@ static int writeDeductInfo(int fd, uint8_t id,uint8_t gunIndex, RecordTransactio
     dataBuf[7] = (amount >> 16) & 0xFF;
     dataBuf[8] = (amount >> 8) & 0xFF;
     dataBuf[9] = (amount & 0xFF);
-    memcpy((char *)&dataBuf[10], transactionInfo->ApprovalNo,9);
-    /*
-    for(i=0;i<22;i++) {
-    	log_info("dataBuf[%d]:0x%x",i,dataBuf[i]);
-    }
-    */
-    log_info("Gun[%d] TransactionId:%d DeductResult:%d IsDonateInvoice:%d Amount:%f",
-    		gunIndex,transactionInfo->TransactionId,transactionInfo->DeductResult,transactionInfo->IsDonateInvoice,transactionInfo->Amount);
+    memcpy((char *)&dataBuf[10], transactionInfo->pCreditCard.ApprovalNo,9);
+    memcpy((char *)&dataBuf[19], transactionInfo->pCreditCard.VemData, 64);
+    memcpy((char*)&dataBuf[83], transactionInfo->pCreditCard.CardNo, 20);
+
+    log_info("Gun[%d] TransactionId:%d DeductResult:%d IsDonateInvoice:%d Amount:%f Approva Num:'%s' VemData:'%s' CardNo:'%s'",
+    		transactionInfo->ConnectorID,
+            transactionInfo->TransactionId,
+            transactionInfo->DeductResult,
+            transactionInfo->IsDonateInvoice,
+            transactionInfo->Amount,
+            transactionInfo->pCreditCard.ApprovalNo,
+            transactionInfo->pCreditCard.VemData,
+            transactionInfo->pCreditCard.CardNo);
     // copy deduct result to dataBuf here
 
     if ((ret = composeSocketData(fd,
                                  id,
                                  OP_WRITE_DATA,
                                  REG_DEDUCT_INFO,
-                                 22,
+                                 104,
                                  &dataBuf[0])) == FAIL) {
         return ret;
     }
 
     return ret;
 }
-
+*/
 static int writeWaitPlugItState(int fd, uint8_t id)
 {
     int ret = PASS;
@@ -1714,13 +1895,18 @@ static int writeUserID(int fd, uint8_t id, uint8_t *pUserID)
     if ((strlen((char *)pUserID) <= 0) || (pUserID == NULL)) {
         return FAIL;
     }
-
+    uint8_t data[50];
+    int datalen = strlen((char*)pUserID);
+    memcpy((uint8_t*)data, pUserID, datalen);
+    data[datalen] = '\0';
+    data[datalen+1] = ShmDcCommonData->AuthroizeType;
+    datalen += 2;
     return composeSocketData(fd,
                              id,
                              OP_WRITE_DATA,
                              REG_USER_ID,
-                             strlen((char *)pUserID),
-                             pUserID);
+                             datalen,
+                             &data[0]);
 }
 
 static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
@@ -1919,6 +2105,21 @@ static int readCabinetEachPSUVersion(int fd, uint8_t id,uint8_t n_psu)
 
     return ret;
 }
+
+static int readReceiptInfo(int fd, uint8_t id)
+{
+    int ret = PASS;
+
+    ret = composeSocketData(fd,
+        id,
+        OP_READ_DATA,
+        REG_RECEIPT_INFO,
+        0,
+        NULL);
+
+    return ret;
+}
+
 static int writeDispenserStatus(int fd, uint8_t gunID)
 {
     uint8_t warningCount = 0;
@@ -1983,7 +2184,58 @@ static int readConnectorID(int fd)
 
     return ret;
 }
+static int readSystemID(int fd)
+{
+    int ret = PASS;
+
+    ret = composeSocketData(fd,
+                            ID_REGISTER,
+                            OP_READ_DATA,
+                            REG_READ_CABINET_SYSTEMID,
+                            0,
+                            NULL);
+
+    return ret;
+}
+static int readDefaultPrice(int fd)
+{
+    int ret = PASS;
+
+    ret = composeSocketData(fd,
+                            ID_REGISTER,
+                            OP_READ_DATA,
+                            REG_READ_DEFAULT_PRICE,
+                            0,
+                            NULL);
+
+    return ret;
+}
+static int readUserPrice(int fd, uint8_t gunID)
+{
+    int ret = PASS;
+
+    ret = composeSocketData(fd,
+                            gunID,
+                            OP_READ_DATA,
+                            REG_READ_USER_PRICE,
+                            0,
+                            NULL);
+
+    return ret;
+}
+static int readConsumptionInfo(int fd)
+{
+    int ret = PASS;
+
+    ret = composeSocketData(fd,
+                            ID_REGISTER,
+                            OP_READ_DATA,
+                            REG_POWER_CONSUMPTION_INFO,
+                            0,
+                            NULL);
 
+    return ret;
+}
 static int WriteModelName(int fd)
 {
     int ret = PASS;
@@ -2182,9 +2434,9 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
                 if (readChargingCapability(fd, gunID) == PASS) {
 					gMoreInfoReq[plugNum].bits.FinalCostReq = false;
 					pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(plugNum);
-					ShmDcCommonData->finalcost[plugNum] = pDcChargingInfo->ChargingFee;
-					ShmDcCommonData->finalcost_flag[plugNum] = TRUE;
-					log_info("Gun %d get final cost %d", plugNum, pDcChargingInfo->ChargingFee);
+					//ShmDcCommonData->TransactionInfo[plugNum].Amount = pDcChargingInfo->ChargingFee;
+					ShmDcCommonData->pGunInfo[plugNum].finalcost_flag = TRUE;
+					log_info("Gun %d get final cost %f", plugNum, pDcChargingInfo->ChargingFee);
                 }
             }
             curReg = REG_PLUG_IN_STATE;
@@ -2232,9 +2484,39 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
                 writeConnectorState(fd, plugNum, gunID);
                 ftime(&gRegTimeUp[plugNum][curReg]);
             }
-            curReg = REG_QRCODE_URL_INFO;
+            curReg = REG_DISPENSER_REQUEST;
             break;
+        case REG_DISPENSER_REQUEST:
+            /*
+            gConnectorActReq[plugNum].bits.ChargingCancel = ShmDcCommonData->OperateIDLE[plugNum];
+            if (gConnectorActReq[plugNum].Value != 0)
+            {
+                if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
+                    DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
 
+                    if (writeDispenserRequest(fd, gunID, plugNum) == PASS)
+                    {
+                        gConnectorActReq[plugNum].Value = 0;
+                        log_info("Gun %d CHARGING_CANCEL OK", plugNum);
+                        ShmDcCommonData->OperateIDLE[plugNum] = 0;
+                    }
+                    ftime(&gRegTimeUp[plugNum][curReg]);
+                }
+            }
+            */
+            curReg = REG_QRCODE_URL_INFO;
+            break;
+        case REG_QRCODE_URL_INFO:
+            if (gunID == 1) {
+                if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > (LOOP_RETRY_TIME * 10) ||
+                    DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0
+                    ) {
+                    readQRcodeURLAndSystemDate(fd);
+                    ftime(&gRegTimeUp[plugNum][curReg]);
+                }
+            }
+            curReg = REG_READ_CABINET_SYSTEMID;
+            break;
         //case REG_USER_ID:
         //    writeUserID(fd, gunID, uint8_t *pUserID);
         //    break;
@@ -2278,29 +2560,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
         //case REG_PRESENT_CHARGING_INFO:
         //    break;
 
-        case REG_QRCODE_URL_INFO:
-            if (gunID == 1) {
-                if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > (LOOP_RETRY_TIME * 10) ||
-                        DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0
-                   ) {
-                    readQRcodeURLAndSystemDate(fd);
-                    ftime(&gRegTimeUp[plugNum][curReg]);
-                }
-            }
 
-            //check misc command from power cabinet
-            if (gDoCommGblData.MiscCmd != 0) {
-                if (gDoCommGblData.MiscCmd != REG_MISC_CONTROL) {
-                    log_error("misc command failed = %x", gDoCommGblData.MiscCmd);
-                }
-                curReg = gDoCommGblData.MiscCmd;
-            } else if (gMoreInfoReq[plugNum].Value != 0) {
-                curReg = REG_RESERVATION_IDTAG;
-            } else {
-                isContinue = 0;
-            }
-            //curReg = REG_SOFTWARE_UPDATE;
-            break;
 
         //case REG_WAIT_PLUG_IT_STATE:
         //    if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > (LOOP_RETRY_TIME / 10)) {
@@ -2322,56 +2582,119 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
         //case REG_PSU_VERSION:
         //    break;
 
+
+        //case REG_DISPENSER_REQUEST:
+        //    break;
+
+
+        case REG_READ_CABINET_SYSTEMID:
+            if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
+                DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
+                readSystemID(fd);
+                ftime(&gRegTimeUp[plugNum][curReg]);
+            }
+            curReg = REG_POWER_CONSUMPTION_INFO;
+            break;
+
+        case REG_POWER_CONSUMPTION_INFO:
+            if (pSysConfig->ShowInformation || ShmDcCommonData->DebugFlag) {
+                if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
+                    DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
+                    readConsumptionInfo(fd);
+                    ftime(&gRegTimeUp[plugNum][curReg]);
+                }
+            }
+            //check misc command from power cabinet
+            if (gDoCommGblData.MiscCmd != 0) {
+                if (gDoCommGblData.MiscCmd != REG_MISC_CONTROL) {
+                    log_error("misc command failed = %x", gDoCommGblData.MiscCmd);
+                }
+                curReg = gDoCommGblData.MiscCmd;
+            } else if (gMoreInfoReq[plugNum].Value != 0) {
+                curReg = REG_RESERVATION_IDTAG;
+            } else {
+                isContinue = 0;
+            }
+            break;
+
         case REG_RESERVATION_IDTAG:
-            if(gMoreInfoReq[plugNum].bits.ReservationReq)
+            if (gMoreInfoReq[plugNum].bits.ReservationReq)
             {
                 if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
-                        DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
-                    if(readReservationState(fd, gunID) == PASS)
+                    DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
+                    if (readReservationState(fd, gunID) == PASS)
                     {
                         gMoreInfoReq[plugNum].bits.ReservationReq = ReservationState[plugNum] == NO ? NO : YES;
                     }
                     ftime(&gRegTimeUp[plugNum][curReg]);
                 }
             }
-            curReg = REG_DISPENSER_REQUEST;
+            curReg = REG_REMOTE_START_NO_ID;
             break;
-
-        //case REG_DISPENSER_REQUEST:
-        //    break;
-            case REG_DISPENSER_REQUEST:
-                if (gConnectorActReq[plugNum].Value != 0)
-                {
-                    if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
-                        DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
-
-
-
-                        if (writeDispenserRequest(fd, gunID, plugNum) == PASS)
-                        {
-                            gConnectorActReq[plugNum].Value = 0;
-                            log_info("Gun %d CHARGING_CANCEL OK");
-                        }
-                        ftime(&gRegTimeUp[plugNum][curReg]);
-                    }
-                }
-                curReg = REG_REMOTE_START_NO_ID;
-                break;
         case REG_REMOTE_START_NO_ID:
-            if(gMoreInfoReq[plugNum].bits.RemoteStartNoID)
+            if (gMoreInfoReq[plugNum].bits.RemoteStartNoID)
             {
                 if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
-                        DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
-                    if(readRemoteStartNoIDState(fd) == PASS)
+                    DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
+                    if (readRemoteStartNoIDState(fd) == PASS)
                     {
                         gMoreInfoReq[plugNum].bits.RemoteStartNoID = RemoteStartNoIDState == NO ? NO : YES;
                     }
                     ftime(&gRegTimeUp[plugNum][curReg]);
                 }
             }
-            curReg = REG_REFUND_AMOUNT;
+            curReg = REG_STATION_INFO;
             break;
+        case REG_STATION_INFO:
+            if (gMoreInfoReq[plugNum].bits.StationInfoReq)
+            {
+                if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
+                    DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
 
+                    if (readChargerStationInfo(fd) == PASS)
+                    {
+                        gMoreInfoReq[plugNum].bits.StationInfoReq = NO;
+                    }
+                    ftime(&gRegTimeUp[plugNum][curReg]);
+                }
+            }
+            //isContinue = 0;
+            curReg = REG_READ_DEFAULT_PRICE;
+            break;
+
+        case REG_READ_DEFAULT_PRICE:
+            if (gMoreInfoReq[plugNum].bits.DefaultPriceReq)
+            {
+                if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
+                    DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
+                    readDefaultPrice(fd);
+                    ftime(&gRegTimeUp[plugNum][curReg]);
+                }
+            }
+            curReg = REG_READ_USER_PRICE;
+            break;
+        case REG_READ_USER_PRICE:
+            if (gMoreInfoReq[plugNum].bits.UserPriceReq)
+            {
+                if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
+                    DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
+                    readUserPrice(fd,gunID);
+                    ftime(&gRegTimeUp[plugNum][curReg]);
+                }
+            }
+            curReg = REG_RECEIPT_INFO;
+            break;
+        case REG_RECEIPT_INFO:
+            if (gMoreInfoReq[plugNum].bits.ReceiptReq)
+            {
+                if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
+                    DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
+                    readReceiptInfo(fd, gunID);
+                    ftime(&gRegTimeUp[plugNum][curReg]);
+                }
+            }
+            curReg = REG_REFUND_AMOUNT;
+            break;
         case REG_REFUND_AMOUNT:
             curReg = REG_PREPAYMENT_INFO;
             break;
@@ -2385,25 +2708,10 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
             break;
 
         case REG_CONNECTOR_QR_CODE:
-            curReg = REG_STATION_INFO;
-            break;
-
-        case REG_STATION_INFO:
-            if(gMoreInfoReq[plugNum].bits.StationInfoReq)
-            {
-                if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
-                        DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
-
-                    if(readChargerStationInfo(fd) == PASS)
-                    {
-                        gMoreInfoReq[plugNum].bits.StationInfoReq = NO;
-                    }
-                    ftime(&gRegTimeUp[plugNum][curReg]);
-                }
-            }
             isContinue = 0;
             break;
 
+
         default:
             log_error("error curReg = %x", curReg);
             gDoCommGblData.MiscCmd = 0;
@@ -2791,6 +3099,7 @@ int main(int argc, char *argv[])
 
 
         if (pSysConfig->Eth0Interface.EthDhcpClient == 0) {
+            system("pgrep -f \"udhcpc -i eth0\" | xargs kill");
             sprintf(tmpbuf,
                     "/sbin/udhcpc -i eth0 -x hostname:CSU3_%s -s /root/dhcp_script/eth0.script > /dev/null &",
                     pSysConfig->SystemId);

+ 16 - 3
EVSE/Projects/DD360UCar/Apps/ModuleDoComm/DoComm.h

@@ -16,7 +16,7 @@
 #define TFTP_PULL_CMD                           "tftp"
 #define SIGTERM_MSG                             "SegmentFault.~~~~\n"
 
-#define MAX_REGISTER_NUM                        30
+#define MAX_REGISTER_NUM                        40
 
 #define CHECK_NETWORK_FAIL_COUNT                10//10
 #define CONNECT_SERVER_FAIL_COUNT               3//5
@@ -93,6 +93,11 @@
 #define REG_CONNECTOR_QR_CODE                   0x1D
 #define REG_STATION_INFO                        0x1E
 #define REG_DEDUCT_INFO                         0x1F
+#define REG_READ_CABINET_SYSTEMID               0x20
+#define REG_READ_DEFAULT_PRICE                  0x21
+#define REG_READ_USER_PRICE                     0x22
+#define REG_RECEIPT_INFO                        0x23
+#define REG_POWER_CONSUMPTION_INFO              0x24
 
 //------------------------------------------------------------------------------
 //--- dispenser result ---
@@ -139,6 +144,9 @@
 #define MISC_CMD_STATION_INFO_REQ               (0x0109)
 #define MISC_CMD_FINAL_COST_REQ                 (0x010A)
 #define MISC_CMD_LINE_STATUS_REQ                (0x010B)
+#define MISC_CMD_DEFAULT_PRICE_REQ              (0x010C)
+#define MISC_CMD_USER_PRICE_REQ                 (0x010D)
+#define MISC_CMD_RECEIPT_REQ                    (0x010E)
 
 #define ST_UPDATE_FIRMWARE                      (0x01)
 #define ST_NO_UPDATE_FIRMWARE                   (0x02)
@@ -192,7 +200,10 @@ typedef union
         unsigned int RemoteStartNoID:1;             // 0: no effect,                1: need to request RemoteStartNoID
         unsigned int StationInfoReq:1;              // 0: no effect,                1: need to request StationInfo
         unsigned int FinalCostReq:1;                // 0: no effect,                1: need to request FinalCost
-        unsigned int res:28;
+        unsigned int DefaultPriceReq : 1;           // 0: no effect,                1: need to request Default price
+        unsigned int UserPriceReq : 1;              // 0: no effect,                1: need to request User price
+        unsigned int ReceiptReq : 1;                // 0: no effect,                1: need to request Receipt
+        unsigned int res:27;
     }bits;
 } MoreInfoReq;
 
@@ -312,7 +323,9 @@ typedef struct StAccountInfo {
     int Balance;
     int Discount;
     int Transaction;
-    uint8_t Reserved[3];
+    int EnergyCost;
+    int ParkingFee;
+    uint8_t Reserved[1];
 } AccountInfo;
 
 typedef struct stCabinetDCMVersion {

+ 14 - 1
EVSE/Projects/DD360UCar/Apps/ModuleEvComm/Ev_Comm.c

@@ -14,6 +14,7 @@
 #include "Ev_Comm.h"
 #include "Module_EvComm.h"
 #include "../ShareMemory/shmMem.h"
+#include "../Config.h"
 
 //------------------------------------------------------------------------------
 int PackageIdCmd(int cmd)
@@ -23,14 +24,26 @@ int PackageIdCmd(int cmd)
 
 void SendCmdToEvboard(int cmd, uint8_t *data, uint8_t dataLen)
 {
+    DcCommonInfo* ShmDcCommonData = (DcCommonInfo*)GetShmDcCommonData();
     int fd = GetCanFd();
     struct can_frame frame;
-
+    int len = 0;
+    char _info[1024];
+    int i;
     frame.can_id = cmd;
     frame.can_dlc = dataLen;
     memcpy(frame.data, data, sizeof(frame.data));
 
     write(fd, &frame, sizeof(struct can_frame));
+
+    if (ShmDcCommonData->showCanPackage) {
+        len += sprintf(&_info[len], "CAN Dispenser => EV Tx:\t[0x%X] ", cmd);
+        for (i = 0; i < dataLen; i++) {
+            len += sprintf(&_info[len], "%X ", data[i]);
+        }
+        len += sprintf(&_info[len], "\n");
+        printf("%s", _info);
+    }
 }
 
 //------------------------------------------------------------------------------

+ 26 - 27
EVSE/Projects/DD360UCar/Apps/ModuleEvComm/Module_EvRxComm.c

@@ -642,39 +642,38 @@ void CANReceiver(int fd)
 
                     pDcChargingInfo->ChillerTemp = maxChillerTemp;
                 }
-
-                maxConnTemp = getMaxConnectTemp(frame.data[1], frame.data[2]);
-                //if ((maxConnTemp - 3) >= pDcChargingInfo->ConnectorTemp) {
-                //    printConnTemp = YES;
-                //}
-                maxConnTemp = getAvageTemp(maxConnTemp,targetGun);
-                if(maxConnTemp > (lastConnTemp[targetGun] + 2) || maxConnTemp < (lastConnTemp[targetGun] - 2))
-                {
-                    lastConnTemp[targetGun] = maxConnTemp;
-                    printConnTemp = YES;
+                // 避免EV小板Reset產生數值為零的情況
+                if (ShmDcCommonData->ConnectorTemp[gunTypeIndex][0] != 0 && ShmDcCommonData->ConnectorTemp[gunTypeIndex][1] != 0) {
+                    maxConnTemp = getMaxConnectTemp(ShmDcCommonData->ConnectorTemp[gunTypeIndex][0], ShmDcCommonData->ConnectorTemp[gunTypeIndex][1]);
+                    //if ((maxConnTemp - 3) >= pDcChargingInfo->ConnectorTemp) {
+                    //    printConnTemp = YES;
+                    //}
+                    maxConnTemp = getAvageTemp(maxConnTemp, targetGun);
+                    if (maxConnTemp > (lastConnTemp[targetGun] + 2) || maxConnTemp < (lastConnTemp[targetGun] - 2))
+                    {
+                        lastConnTemp[targetGun] = maxConnTemp;
+                        printConnTemp = YES;
+                    }
+                    pDcChargingInfo->ConnectorTemp = maxConnTemp;
                 }
-
-                pDcChargingInfo->ConnectorTemp = maxConnTemp;
-
                 //紀錄槍頭和水冷機溫度, 在系統狀態變化或溫度大於150
                 if ((ShmDcCommonData->SystemModeChange[targetGun] == YES) ||
-                        (printConnTemp == YES) ||
-                        (printChillerTemp == YES) //&&
-                        //(((pDcChargingInfo->ConnectorTemp >= GUN_OTP_VALUE) &&
-                        //  (pDcChargingInfo->ConnectorTemp != UNDEFINED_TEMP)) ||
-                        // ((pDcChargingInfo->ChillerTemp >= GUN_OTP_VALUE) &&
-                        //  (pDcChargingInfo->ChillerTemp != UNDEFINED_TEMP)))
-                   ) {
+                    (printConnTemp == YES) ||
+                    (printChillerTemp == YES) //&&
+                    //(((pDcChargingInfo->ConnectorTemp >= GUN_OTP_VALUE) &&
+                    //  (pDcChargingInfo->ConnectorTemp != UNDEFINED_TEMP)) ||
+                    // ((pDcChargingInfo->ChillerTemp >= GUN_OTP_VALUE) &&
+                    //  (pDcChargingInfo->ChillerTemp != UNDEFINED_TEMP)))
+                    ) {
                     ShmDcCommonData->SystemModeChange[targetGun] = NO;
                     log_info("Gun%d max head temp = %d, chiller1 = [%d,%d], chiller2 = [%d,%d]",
-                             targetGun,
-                             maxConnTemp,
-                             chiilerTemp.Temp[0],
-                             chiilerTemp.Temp[1],
-                             chiilerTemp.Temp[2],
-                             chiilerTemp.Temp[3]);
+                        targetGun,
+                        pDcChargingInfo->ConnectorTemp,
+                        chiilerTemp.Temp[0],
+                        chiilerTemp.Temp[1],
+                        chiilerTemp.Temp[2],
+                        chiilerTemp.Temp[3]);
                 }
-
                 if (((ShmDcCommonData->ChillerValve.MultiChillerGun & 0x80) >> 7) == YES) {
                     //沒有水冷槍
                     break;

+ 2 - 1
EVSE/Projects/DD360UCar/Apps/ModuleEvComm/Module_EvTxComm.c

@@ -600,7 +600,8 @@ static void checkConnectorOVPState(uint8_t gunIndex)
         break;
     }
 
-    if (ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerOTP == YES) {
+    if (ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerOTP == YES ||
+        ShmDcCommonData->ChillerTempErr[gunIndex].StatusBit.ChillerTubeOTP == YES) {
         isOTP = true;
     }
 

+ 6 - 4
EVSE/Projects/DD360UCar/Apps/ModuleLcmCtrl/Module_LcmControl.c

@@ -533,8 +533,10 @@ void ShowViewChargingPower(uint8_t gunIndex,float power)
 }
 void ShowConnectId()
 {
-    ChangeDisplay2Value(_LeftGun_ConnectorId, _ICON_CONNECTOR_1);
-    ChangeDisplay2Value(_RightGun_ConnectorId, _ICON_CONNECTOR_1);
+    int id = atoi(pSysConfig->SystemId);
+    if (id == 0)
+        id = 1;
+    ChangeDisplay2Value(_Text_SystemID, id);
     
     if (ShmDcCommonData->ConnectorId[0] <= 2) {
         ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_A);
@@ -788,7 +790,7 @@ void ShowSummaryPage()
     GetHrFormTimeString(pDcChargingInfo->StopDateTime,end_hr);
     GetMinFormTimeString(pDcChargingInfo->StopDateTime,end_min);
 
-    t_hr = atoi(start_hr) + (ShmDcCommonData->TzOffset / 60);
+    t_hr = atoi(start_hr) + (ShmDcCommonData->TZOffset / 60);
     if (t_hr >= 24)
         t_hr -= 24;
     if (!ShmDcCommonData->isIntoCharge[pSysInfo->CurGunSelected]) {
@@ -797,7 +799,7 @@ void ShowSummaryPage()
     }
     ChangeDisplay2Value(_Summary_Start_time_hr, t_hr);
     ChangeDisplay2Value(_Summary_Start_time_min, atoi(start_min));
-    t_hr = atoi(end_hr) + (ShmDcCommonData->TzOffset / 60);
+    t_hr = atoi(end_hr) + (ShmDcCommonData->TZOffset / 60);
     if (t_hr >= 24)
         t_hr -= 24;
     if (!ShmDcCommonData->isIntoCharge[pSysInfo->CurGunSelected]) {

+ 1 - 0
EVSE/Projects/DD360UCar/Apps/ModuleLcmCtrl/Module_LcmControl.h

@@ -144,6 +144,7 @@
 #define _Text_Warming2              0x1120
 #define _Text_Warming3              0x1130
 #define _Text_Warming4              0x1140
+#define _Text_SystemID              0x1150
 
 int DemoPage[22] = {
     1, // All Idle

+ 71 - 0
EVSE/Projects/DD360UCar/Apps/ReadCmdline.c

@@ -1219,6 +1219,71 @@ static void writeGunAndChillerTemp(void)
         usleep(sleepTime);
     }//while
 }
+void showNetworkPage(char* v1)
+{
+    ShmDcCommonData->showNetPackage = atoi(newString[1]);
+    if (ShmDcCommonData->showNetPackage)
+        printf("Show Network Package on\n");
+    else
+        printf("Show Network Package off\n");
+}
+void showCANBUSPage(char* v1)
+{
+    ShmDcCommonData->showCanPackage = atoi(newString[1]);
+    if (ShmDcCommonData->showCanPackage)
+        printf("Show CAN Bus Package on\n");
+    else
+        printf("Show CAN Bus Package off\n");
+}
+static void writeOTPTemp(void)
+{
+    uint8_t _GunIndex = 0;
+    int isContinue = 1;
+    uint32_t sleepTime = 500000;
+    char* usageMsg = "Usage:\n"
+        "       OTP  <temp_recovery>  <temp>, ex: OTP 140 150\n"
+        "       exit | c | C\n"
+        "       help | ? | h\n"
+        "\r\n";
+
+    while (isContinue) {
+        if (readCmdKey(CMD_KEY_WAIT) == NO) {
+            sleep(sleepTime);
+            continue;
+        }
+
+        if (helpCmd() == YES) {
+            printf("%s\n", usageMsg);
+            continue;
+        } else if (exitCmd() == YES) {
+            sleep(1);
+            return;
+        }
+        if (strcmp(newString[0], "OTP") != 0) {
+            printf("argc 1 is error parameter\r\n");
+            continue;
+        }
+
+        if (atoi(newString[1]) > 255 ||
+            atoi(newString[1]) == -1) {
+            printf("Recovey temperature value overflow\r\n");
+            continue;
+        }
+
+        if (atoi(newString[2]) > 255 ||
+            atoi(newString[2]) == -1) {
+            printf("Recovey temperature value overflow\r\n");
+            continue;
+        }
+
+        pSysInfo->OTPTempR = atoi(newString[1]);
+        pSysInfo->OTPTemp = atoi(newString[2]);
+
+        printf("OTP Recovery Temp set:%d\n", pSysInfo->OTPTempR);
+        printf("OTP Temp set:%d\n", pSysInfo->OTPTemp);
+        usleep(sleepTime);
+    }//while
+}
 
 int main(void)
 {
@@ -1420,6 +1485,12 @@ int main(void)
         	ShmPrimaryMcuData->InputDet.bits.Button2 = BTN_PRESS;
         	sleep(1);
         	ShmPrimaryMcuData->InputDet.bits.Button2 = BTN_RELEASE;
+        } else if (strcmp(newString[0], "OTP") == 0) { //測試槍頭和水冷機溫度
+            writeOTPTemp();
+        } else if (strcmp(newString[0], "netdump") == 0) { //印出網路封包
+            showNetworkPage(newString[1]);
+        } else if (strcmp(newString[0], "candump") == 0) { //印出網路封包
+            showCANBUSPage(newString[1]);
         } else {
             printf("%s\n", usageMsg);
         }

+ 2 - 1
EVSE/Projects/DD360UCar/Apps/SelectGun/SelectGun.h

@@ -63,7 +63,8 @@ typedef struct StPricesInfo {
     //float DefaultPrices;        //unit = 0.01 dollar, value / 100
     float Discount;
     int TransactionId;
-    uint8_t Reserved[4];
+    float EnergyCost;
+    float ParkingFee;
 } PricesInfo;
 
 //typedef struct StOperativeInfo {

+ 29 - 0
EVSE/Projects/DD360UCar/Apps/ShareMemory/shmMem.c

@@ -38,6 +38,7 @@ static struct FanModuleData *ShmFanModuleData = NULL;
 static struct RelayModuleData *ShmRelayModuleData = NULL;
 static struct LedModuleData *ShmLedModuleData = NULL;
 static struct OCPP16Data *ShmOCPP16Data = NULL;
+static struct OCPP20Data* ShmOCPP20Data = NULL;
 
 static SelectGunInfo *ShmSelectGunInfo = NULL;
 static DcCommonInfo *ShmDcCommonData = NULL;
@@ -300,6 +301,15 @@ void *GetShmOCPP16Data(void)
     return ShmOCPP16Data;
 }
 
+void* GetShmOCPP20Data(void)
+{
+    if (ShmOCPP20Data == NULL) {
+        return NULL;
+    }
+
+    return ShmOCPP20Data;
+}
+
 void *GetShmSelectGunInfo(void)
 {
     if (ShmSelectGunInfo == NULL) {
@@ -602,6 +612,21 @@ int InitOCPPShmMem(void)
     return PASS;
 }
 
+int InitOCPP20ShmMem(void)
+{
+    int MeterSMId = FAIL;
+
+    if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), IPC_CREAT | 0777)) < 0) {
+        log_info("Get OCPP20 share memory error");
+        return FAIL;
+    } else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void*)-1) {
+        log_info("Create OCPP20 share memory error");
+        return FAIL;
+    }
+
+    return PASS;
+}
+
 int InitLEDShmMem(void)
 {
     int MeterSMId = FAIL;
@@ -1123,6 +1148,10 @@ int CreateAllCsuShareMemory(void)
         return ret;
     }
 
+    if ((ret = InitOCPP20ShmMem()) == FAIL) {
+        return ret;
+    }
+
     if ((ret = InitSelectGunShmMem()) == FAIL) {
         return ret;
     }

+ 1 - 0
EVSE/Projects/DD360UCar/Apps/ShareMemory/shmMem.h

@@ -42,6 +42,7 @@ void *GetShmSysInfoData(void);
 void *GetShmSysWarningInfo(void);
 
 void *GetShmOCPP16Data(void);
+void* GetShmOCPP20Data(void);
 
 void *GetShmCHAdeMOData(void);
 void *GetShmGBTData(void);

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


BIN
EVSE/Projects/DD360UCar/output/FactoryConfig


BIN
EVSE/Projects/DD360UCar/output/Module_ChkSysTask


BIN
EVSE/Projects/DD360UCar/output/Module_DoComm


BIN
EVSE/Projects/DD360UCar/output/Module_EvComm


BIN
EVSE/Projects/DD360UCar/output/Module_EventLogging


BIN
EVSE/Projects/DD360UCar/output/Module_InternalComm


BIN
EVSE/Projects/DD360UCar/output/Module_LcmControl


BIN
EVSE/Projects/DD360UCar/output/Module_PrimaryComm


BIN
EVSE/Projects/DD360UCar/output/Module_UpdateFW


BIN
EVSE/Projects/DD360UCar/output/ReadCmdline


BIN
EVSE/Projects/DD360UCar/output/main


BIN
EVSE/Projects/DD360UCar/output/simulation


+ 2 - 2
EVSE/Projects/Noodoe/Apps/Module_ConfigTools.c

@@ -517,14 +517,14 @@ int main(void)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
 				printf("\n ***** localloadbalance ***************************");
-				printf("\n  Current local loading balance: %d", ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharging);
+				printf("\n  Current local loading balance: %d", ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing);
 				printf("\n  0: Disable.");
 				printf("\n  1: Enable.");
 				printf("\n **************************************************");
 				printf("\n  Please input local load balance mode: ");
 				scanf("%s", &cmd[0]);
 
-				ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharging = ((0<=atoi(cmd))&&(atoi(cmd)<=1)?atoi(cmd):0);
+				ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing = ((0<=atoi(cmd))&&(atoi(cmd)<=1)?atoi(cmd):0);
 				if(ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian)
 					DEBUG_INFO("Local loading balance: Enable\n");
 				else

+ 22 - 19
EVSE/Projects/Noodoe/Apps/main.c

@@ -1880,26 +1880,29 @@ void InitEthernet()
 				if(cnt_pingDNS_Fail >= 3)
 				{
 					ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet=ON;
-					if((ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient==0))
+					if(!ShmSysConfigAndInfo->SysInfo.OcppConnStatus)
 					{
-						system("pgrep -f \"udhcpc -i eth0\" | xargs kill");
-						sprintf(tmpbuf, "/sbin/udhcpc -i eth0 -x hostname:CSU3_%s -s /root/dhcp_script/eth0.script > /dev/null &", ShmSysConfigAndInfo->SysConfig.SystemId);
-						system(tmpbuf);
-					}
-					else
-					{
-						system("pgrep -f \"udhcpc -i eth0\" | xargs kill");
-						memset(tmpbuf,0,256);
-						sprintf(tmpbuf,"/sbin/ifconfig eth0 %s netmask %s up &",
-								ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,
-								ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress);
-						system(tmpbuf);
-						memset(tmpbuf,0,256);
-						sprintf(tmpbuf,"route add default gw %s eth0 &",
-						ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress);
-						system(tmpbuf);
+						if((ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient==0))
+						{
+							system("pgrep -f \"udhcpc -i eth0\" | xargs kill");
+							sprintf(tmpbuf, "/sbin/udhcpc -i eth0 -x hostname:CSU3_%s -s /root/dhcp_script/eth0.script > /dev/null &", ShmSysConfigAndInfo->SysConfig.SystemId);
+							system(tmpbuf);
+						}
+						else
+						{
+							system("pgrep -f \"udhcpc -i eth0\" | xargs kill");
+							memset(tmpbuf,0,256);
+							sprintf(tmpbuf,"/sbin/ifconfig eth0 %s netmask %s up &",
+									ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,
+									ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress);
+							system(tmpbuf);
+							memset(tmpbuf,0,256);
+							sprintf(tmpbuf,"route add default gw %s eth0 &",
+							ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress);
+							system(tmpbuf);
+						}
+						cnt_pingDNS_Fail = 0;
 					}
-					cnt_pingDNS_Fail = 0;
 				}
 				else
 				{
@@ -2206,7 +2209,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, "V0.54.00.0000.00");
+	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "V0.55.00.0000.00");
 
 	// Get AC connector type from model name
 	for(uint8_t idx=0;idx<3;idx++)

+ 37 - 2
EVSE/Projects/define.h

@@ -592,6 +592,7 @@ struct SysConfigData
     unsigned char           MaintainServerSecurityProfile;      // Maintain server security profile 0~3
     unsigned char           MaintainServerSecurityPassword[41]; // Maintain server AuthorizationKey for security profile
     unsigned char           PowerSharingServerIP[512];          // Local power sharing server ip address
+    unsigned int            PowerSharingCapacityPower;          // Local power sharing capacity power
 };
 
 struct ChargingInfoData
@@ -879,6 +880,7 @@ struct ConnectorInfoData
     float                   CostDiscount;                   // connector user's Discount or couponPoint, unit: 1 point
     float                   EnergyCost;                     // connector user's energy cost, unit: 1 dollar
     float                   ParkingFee;                     // connector user's parking fee, unit: 1 dollar
+    float                   RemainAmount;                   // connector user's remain amount, unit: 1 dollar
 };
 
 typedef union
@@ -900,6 +902,37 @@ typedef struct DC_METER_INFO
     unsigned char LinkStatus;                   // 0 = unknow ,1 = link , 2 miss link
 }DC_Meter_Info;
 
+typedef struct Bazel8Command
+{
+    unsigned char isReq:1;
+    unsigned char isRes:1;
+    unsigned char isWaitRes:1;
+    unsigned char isResultPass:1;
+} bazel8Command;
+
+typedef struct EventInfo
+{
+    int messageId;
+    char messageString[64];
+    unsigned char isGetOn:1;
+}eventInfo;
+
+typedef struct StartTxResp
+{
+    char statusCode[8];
+    char statusText[128];
+    char txnId[32];
+    unsigned char isGetOn:1;
+}startTxResp;
+
+struct BAZEL8
+{
+    eventInfo       event;
+    startTxResp     txResp;
+
+    bazel8Command   cmdPreAuth;
+};
+
 struct SysInfoData
 {
 	/**************System***************/
@@ -997,6 +1030,7 @@ struct SysInfoData
     unsigned char           OTPTemp;                    // OTP Temperature
     unsigned char           OTPTempR;                   // OTP Recovery Temperature
     struct LCD_OVERRIDE     LcdOveride;                 // LCD override info (no use anymore)
+    struct BAZEL8           bazel8;                     // Bazel8 payment used
 };
 
 struct SysConfigAndInfo
@@ -1328,7 +1362,7 @@ char AlarmStatusCode[160][6]=
     "012344",   // AC: Meter IC communication timeout
     "012345",   // AC: Pilot negative error
     "012346",   // Psu Communication error with CSU
-    "012347",   // reserved
+    "012347",   // AC: Local power sharing communication error (Slave disconnect from Master)
     "012348",   // reserved
     "012349",   // reserved
     "012350",   // reserved
@@ -1507,7 +1541,8 @@ struct AlarmCodeData
             unsigned char MeterIcCommTimeout:1;                     //bit 0
             unsigned char PilotNegativeError:1;                     //bit 1
             unsigned char PsuComminicationErrWithCSU:1;             //bit 2
-            unsigned char :5;                                       //reserved bit 3 ~ bit 7
+            unsigned char LocalPowerSharingCommunicationError:1;    //bit 3
+            unsigned char :4;                                       //reserved bit 4 ~ bit 7
             //AlarmVal[19]
             unsigned char :8;                                       //reserved bit 0 ~ bit 7
 		}bits;

+ 1 - 0
EVSE/rootfs/root/.gitignore

@@ -10,5 +10,6 @@ Module_EventLogging
 Module_PhBackend
 Module_InitUpgrade
 Module_Payment
+Module_Payment_Bazel8
 Module_DcMeter
 Module_PowerSharing

BIN
EVSE/rootfs/root/Module_PowerSharing


+ 22 - 6
EVSE/rootfs/var/www/set_backend.php

@@ -200,7 +200,7 @@ CORE STYLES ABOVE - NO TOUCHY
 									<section>
 										<div class="form-group" style="display:<?php echo $am101;?>">
 											<label>Backend Connection Timeout</label>
-											<input type="text" name="BackendConnTimeout" id="BackendConnTimeout" class="form-control" value="<?php echo $obj->{'BackendConnTimeout'};?>">
+											<input type="number" name="BackendConnTimeout" id="BackendConnTimeout" class="form-control" value="<?php echo $obj->{'BackendConnTimeout'};?>">
 											<small class="form-text text-muted-red">seconds</small>
 										</div>
 										<div class="form-group" style="display:<?php echo $am101;?>">
@@ -215,12 +215,12 @@ CORE STYLES ABOVE - NO TOUCHY
 										<div class="form-group" style="display:<?php echo $am101;?>">
 											<label>Offline Max Charge Energy</label>
 											<small class="form-text text-muted-red">kWh</small>
-											<input type="text" name="OfflineMaxChargeEnergy" id="OfflineMaxChargeEnergy" class="form-control" value="<?php echo $obj->{'OfflineMaxChargeEnergy'};?>">
+											<input type="number" name="OfflineMaxChargeEnergy" id="OfflineMaxChargeEnergy" class="form-control" value="<?php echo $obj->{'OfflineMaxChargeEnergy'};?>">
 										</div>
 										<div class="form-group" style="display:<?php echo $am101;?>">
 											<label>Offline Max Charge Duration</label>
 											<small class="form-text text-muted-red">minutes</small>
-											<input type="text" name="OfflineMaxChargeDuration" id="OfflineMaxChargeDuration" class="form-control" value="<?php echo $obj->{'OfflineMaxChargeDuration'};?>">
+											<input type="number" name="OfflineMaxChargeDuration" id="OfflineMaxChargeDuration" class="form-control" value="<?php echo $obj->{'OfflineMaxChargeDuration'};?>">
 										</div>
 									</section>
 								</article>
@@ -271,10 +271,16 @@ CORE STYLES ABOVE - NO TOUCHY
 												<option value="2" <?php echo $obj->{'isEnableLocalPowerSharging'}=="2"?"selected":""?>>slave</option>
 											</select>
 										</div>
+										<div id="PowerSharingCapacityDiv" class="form-group" style="display:<?php echo $am101;?>">
+											<label>Power Sharing Capacity</label><small class="form-text text-muted-red"> W</small>
+											<input type="number" min="0" max="5000000" name="PowerSharingCapacity" id="PowerSharingCapacity" class="form-control" value="<?php echo $obj->{'PowerSharingCapacity'};?>">											
+											<small class="form-text text-muted-red">'0' means follow rating power from model name</small>
+										</div>
 										<div id="PowerSharingServerIPDiv" class="form-group" style="display:<?php echo $am101;?>">
 											<label>Power Sharing Server Ip</label>
 											<input type="text" name="PowerSharingServerIP" id="PowerSharingServerIP" class="form-control" value="<?php echo $obj->{'PowerSharingServerIP'};?>">
 										</div>
+
 <?php } ?>
 										<div class="form-group" style="display:<?php echo $am101;?>">
 											<label>Maintain Server Connection Status</label>
@@ -399,6 +405,7 @@ CORE STYLES ABOVE - NO TOUCHY
 <?php if(substr($ModelName,0,2)=="AX"){?>
 				data += "&isEnableLocalPowerSharging=" + document.getElementById("isEnableLocalPowerSharging").value;
 				data += "&PowerSharingServerIP=" + document.getElementById("PowerSharingServerIP").value;
+				data += "&PowerSharingCapacity=" + document.getElementById("PowerSharingCapacity").value;
 <?php } if(substr($ModelName,0,2)=="AX" || substr($ModelName,0,1)=="D"){?>
 				data += "&OcppReceiptrURL=" + document.getElementById("OcppReceiptrURL").value;
 <?php } ?>
@@ -553,10 +560,19 @@ CORE STYLES ABOVE - NO TOUCHY
 			document.getElementById("chargePointVendor").removeAttribute("readOnly");
 		}*/
 
-		if(document.getElementById("isEnableLocalPowerSharging").selectedIndex==2){
-			document.getElementById("PowerSharingServerIPDiv").style.display="block";
+		if(document.getElementById("isEnableLocalPowerSharging").selectedIndex==1)
+		{
+			document.getElementById("PowerSharingCapacityDiv").style.display="block";	
+			document.getElementById("PowerSharingServerIPDiv").style.display="none";	
 		}
-		else{
+		else if(document.getElementById("isEnableLocalPowerSharging").selectedIndex==2)
+		{
+			document.getElementById("PowerSharingCapacityDiv").style.display="none";	
+			document.getElementById("PowerSharingServerIPDiv").style.display="block";				
+		}
+		else
+		{
+			document.getElementById("PowerSharingCapacityDiv").style.display="none";	
 			document.getElementById("PowerSharingServerIPDiv").style.display="none";
 		}
 	}

+ 3 - 0
EVSE/rootfs/var/www/set_backend_action.php

@@ -74,6 +74,9 @@
 			checkValue("isEnableLocalPowerSharging");
 			$json['isEnableLocalPowerSharging']	= (int)$_REQUEST['isEnableLocalPowerSharging'];
 		}
+		if(isset($_REQUEST['PowerSharingCapacity'])){
+			$json['PowerSharingCapacity']	= str_replace("&amp;","&",str_replace("&quot;",'"',str_replace("&#039;","'",str_replace("&lt;","<",str_replace("&gt;",">",$_REQUEST['PowerSharingCapacity'])))));
+		}
 		if(isset($_REQUEST['PowerSharingServerIP'])){
 			$json['PowerSharingServerIP']	= str_replace("&amp;","&",str_replace("&quot;",'"',str_replace("&#039;","'",str_replace("&lt;","<",str_replace("&gt;",">",$_REQUEST['PowerSharingServerIP'])))));
 		}

+ 1 - 1
EVSE/rootfs/var/www/set_system.php

@@ -516,7 +516,7 @@ img {
 				document.getElementById("isQRCode").checked=true;
 				document.getElementById("isRFID").checked=true;
 			}
-			if(document.getElementById("ModelName").value.substr(0,1) == "D"){
+			if((document.getElementById("ModelName").value.substr(0,1) == "D") || (document.getElementById("ModelName").value.substr(0,2) == "AX")){
 				document.getElementById("isAuthrizeByEVCCIDDiv").style.display="block";
 			}
 			else{