Эх сурвалжийг харах

Merge branch 'master' into DO360

Wendell 2 жил өмнө
parent
commit
9f2e1a5bfe
31 өөрчлөгдсөн 1486 нэмэгдсэн , 1348 устгасан
  1. 26 0
      EVSE/GPL/etherwake/Makefile
  2. BIN
      EVSE/GPL/etherwake/ether-wake
  3. 392 0
      EVSE/GPL/etherwake/ether-wake.c
  4. 2 1
      EVSE/Modularization/Infypwr_PsuCommObj.c
  5. 310 3
      EVSE/Modularization/Module_PowerSharing.c
  6. 7 6
      EVSE/Modularization/Module_RFID.c
  7. 3 2
      EVSE/Modularization/Module_RFID.h
  8. 2 6
      EVSE/Modularization/WebService.c
  9. 15 1
      EVSE/Modularization/ocpp20/JsonParser.c
  10. 193 81
      EVSE/Modularization/ocpp20/MessageHandler.c
  11. 88 432
      EVSE/Modularization/ocppfiles/MessageHandler.c
  12. 2 0
      EVSE/Modularization/ocppfiles/MessageHandler.h
  13. 30 0
      EVSE/Modularization/ocppfiles/Module_OcppBackend.c
  14. 46 432
      EVSE/Modularization/ocppph/MessageHandler.c
  15. 1 0
      EVSE/Modularization/ocppph/MessageHandler.h
  16. 2 1
      EVSE/Modularization/ocppph/Module_OcppBackend.c
  17. 38 18
      EVSE/Projects/AW-CCS/Apps/LCM/Module_LcmControl.c
  18. 48 48
      EVSE/Projects/AW-CCS/Apps/main.c
  19. 5 2
      EVSE/Projects/AW-Regular/Apps/Makefile
  20. 52 39
      EVSE/Projects/AW-Regular/Apps/Module_FactoryConfig.c
  21. 145 23
      EVSE/Projects/AW-Regular/Apps/main.c
  22. 12 12
      EVSE/Projects/AX80/Apps/main.c
  23. 15 3
      EVSE/Projects/define.h
  24. 1 1
      EVSE/rootfs/root/ppp/4GDetection
  25. 4 6
      EVSE/rootfs/var/www/set_backend.php
  26. 1 1
      Makefile
  27. 44 53
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/[AW-Regular]am335x-evm.dts
  28. 0 2
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/include/Kbuild
  29. 0 175
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/include/memory/jedec_ddr.h
  30. 1 0
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/.MLO.byteswap.cmd
  31. 1 0
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/.MLO.cmd

+ 26 - 0
EVSE/GPL/etherwake/Makefile

@@ -0,0 +1,26 @@
+.PHONY: clean uninstall
+
+prefix ?= /usr
+exec_prefix ?= $(prefix)
+bindir ?= $(exec_prefix)/bin
+
+ETHERWAKE_src = ether-wake.c
+ETHERWAKE_bin = ether-wake
+ETHERWAKE_tgt = $(DESTDIR)$(bindir)/etherwake
+
+all: $(ETHERWAKE_bin)
+#$(CC) -O -Wall -o $(TARGET) ether-wake.c
+
+$(ETHERWAKE_bin): $(ETHERWAKE_src)
+
+$(ETHERWAKE_tgt): $(ETHERWAKE_bin)
+	install -d $(DESTDIR)$(bindir)
+	install -m 0755 $^ $@
+
+clean:
+	rm $(ETHERWAKE_bin)
+
+install: $(ETHERWAKE_tgt)
+
+uninstall:
+	rm $(ETHERWAKE_tgt)

BIN
EVSE/GPL/etherwake/ether-wake


+ 392 - 0
EVSE/GPL/etherwake/ether-wake.c

@@ -0,0 +1,392 @@
+/* ether-wake.c: Send a magic packet to wake up sleeping machines. */
+
+static char version_msg[] =
+"etherwake.c: v1.09 11/12/2003 Donald Becker, http://www.scyld.com/";
+static char brief_usage_msg[] =
+"usage: etherwake [-i <ifname>] [-p aa:bb:cc:dd[:ee:ff]] 00:11:22:33:44:55\n"
+"   Use '-u' to see the complete set of options.\n";
+static char usage_msg[] =
+"usage: etherwake [-i <ifname>] [-p aa:bb:cc:dd[:ee:ff]] 00:11:22:33:44:55\n"
+"\n"
+"	This program generates and transmits a Wake-On-LAN (WOL)\n"
+"	\"Magic Packet\", used for restarting machines that have been\n"
+"	soft-powered-down (ACPI D3-warm state).\n"
+"	It currently generates the standard AMD Magic Packet format, with\n"
+"	an optional password appended.\n"
+"\n"
+"	The single required parameter is the Ethernet MAC (station) address\n"
+"	of the machine to wake or a host ID with known NSS 'ethers' entry.\n"
+"	The MAC address may be found with the 'arp' program while the target\n"
+"	machine is awake.\n"
+"\n"
+"	Options:\n"
+"		-b	Send wake-up packet to the broadcast address.\n"
+"		-D	Increase the debug level.\n"
+"		-i ifname	Use interface IFNAME instead of the default 'eth0'.\n"
+"		-p <pw>		Append the four or six byte password PW to the packet.\n"
+"					A password is only required for a few adapter types.\n"
+"					The password may be specified in ethernet hex format\n"
+"					or dotted decimal (Internet address)\n"
+"		-p 00:22:44:66:88:aa\n"
+"		-p 192.168.1.1\n";
+
+/*
+	This program generates and transmits a Wake-On-LAN (WOL) "Magic Packet",
+	used for restarting machines that have been soft-powered-down
+	(ACPI D3-warm state).  It currently generates the standard AMD Magic Packet
+	format, with an optional password appended.
+
+	This software may be used and distributed according to the terms
+	of the GNU Public License, incorporated herein by reference.
+	Contact the author for use under other terms.
+
+	This source file was originally part of the network tricks package, and
+	is now distributed to support the Scyld Beowulf system.
+	Copyright 1999-2003 Donald Becker and Scyld Computing Corporation.
+
+	The author may be reached as becker@scyld, or C/O
+	 Scyld Computing Corporation
+	 914 Bay Ridge Road, Suite 220
+	 Annapolis MD 21403
+
+  Notes:
+  On some systems dropping root capability allows the process to be
+  dumped, traced or debugged.
+  If someone traces this program, they get control of a raw socket.
+  Linux handles this safely, but beware when porting this program.
+
+  An alternative to needing 'root' is using a UDP broadcast socket, however
+  doing so only works with adapters configured for unicast+broadcast Rx
+  filter.  That configuration consumes more power.
+*/
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <ctype.h>
+#include <string.h>
+
+#if 0							/* Only exists on some versions. */
+#include <ioctls.h>
+#endif
+
+#include <sys/socket.h>
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <linux/if.h>
+
+#include <features.h>
+#if __GLIBC__ >= 2 && __GLIBC_MINOR >= 1
+#include <netpacket/packet.h>
+#include <net/ethernet.h>
+#else
+#include <asm/types.h>
+#include <linux/if_packet.h>
+#include <linux/if_ether.h>
+#endif
+#include <netdb.h>
+#include <netinet/ether.h>
+
+/* Grrr, no consistency between include versions.
+   Enable this if setsockopt() isn't declared with your library. */
+#if 0
+extern int setsockopt __P ((int __fd, int __level, int __optname,
+							__ptr_t __optval, int __optlen));
+#else				/* New, correct head files.  */
+#include <sys/socket.h>
+#endif
+
+u_char outpack[1000];
+int outpack_sz = 0;
+int debug = 0;
+u_char wol_passwd[6];
+int wol_passwd_sz = 0;
+
+static int opt_no_src_addr = 0, opt_broadcast = 0;
+
+static int get_dest_addr(const char *arg, struct ether_addr *eaddr);
+static int get_fill(unsigned char *pkt, struct ether_addr *eaddr);
+static int get_wol_pw(const char *optarg);
+
+int main(int argc, char *argv[])
+{
+	char *ifname = "eth0";
+	int one = 1;				/* True, for socket options. */
+	int s;						/* Raw socket */
+	int errflag = 0, verbose = 0, do_version = 0;
+	int perm_failure = 0;
+	int i, c, pktsize;
+#if defined(PF_PACKET)
+	struct sockaddr_ll whereto;
+#else
+	struct sockaddr whereto;	/* who to wake up */
+#endif
+	struct ether_addr eaddr;
+
+	while ((c = getopt(argc, argv, "bDi:p:uvV")) != -1)
+		switch (c) {
+		case 'b': opt_broadcast++;	break;
+		case 'D': debug++;			break;
+		case 'i': ifname = optarg;	break;
+		case 'p': get_wol_pw(optarg); break;
+		case 'u': printf("%s",usage_msg); return 0;
+		case 'v': verbose++;		break;
+		case 'V': do_version++;		break;
+		case '?':
+			errflag++;
+		}
+	if (verbose || do_version)
+		printf("%s\n", version_msg);
+	if (errflag) {
+		fprintf(stderr,"%s", brief_usage_msg);
+		return 3;
+	}
+
+	if (optind == argc) {
+		fprintf(stderr, "Specify the Ethernet address as 00:11:22:33:44:55.\n");
+		return 3;
+	}
+
+	/* Note: PF_INET, SOCK_DGRAM, IPPROTO_UDP would allow SIOCGIFHWADDR to
+	   work as non-root, but we need SOCK_PACKET to specify the Ethernet
+	   destination address. */
+#if defined(PF_PACKET)
+	s = socket(PF_PACKET, SOCK_RAW, 0);
+#else
+	s = socket(AF_INET, SOCK_PACKET, SOCK_PACKET);
+#endif
+	if (s < 0) {
+		if (errno == EPERM)
+			fprintf(stderr, "etherwake: This program must be run as root.\n");
+		else
+			perror("etherwake: socket");
+		perm_failure++;
+	}
+	/* Don't revert if debugging allows a normal user to get the raw socket. */
+	setuid(getuid());
+
+	/* We look up the station address before reporting failure so that
+	   errors may be reported even when run as a normal user.
+	*/
+	if (get_dest_addr(argv[optind], &eaddr) != 0)
+		return 3;
+	if (perm_failure && ! debug)
+		return 2;
+
+	pktsize = get_fill(outpack, &eaddr);
+
+	/* Fill in the source address, if possible.
+	   The code to retrieve the local station address is Linux specific. */
+	if (! opt_no_src_addr) {
+		struct ifreq if_hwaddr;
+		const char *hwaddr = if_hwaddr.ifr_hwaddr.sa_data;
+
+		strcpy(if_hwaddr.ifr_name, ifname);
+		if (ioctl(s, SIOCGIFHWADDR, &if_hwaddr) < 0) {
+			fprintf(stderr, "SIOCGIFHWADDR on %s failed: %s\n", ifname,
+					strerror(errno));
+			/* Magic packets still work if our source address is bogus, but
+			   we fail just to be anal. */
+			return 1;
+		}
+		memcpy(outpack+6, if_hwaddr.ifr_hwaddr.sa_data, 6);
+
+		if (verbose) {
+			printf("The hardware address (SIOCGIFHWADDR) of %s is type %d  "
+				   "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x.\n", ifname,
+				   if_hwaddr.ifr_hwaddr.sa_family, hwaddr[0], hwaddr[1],
+				   hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5]);
+		}
+	}
+
+	if (wol_passwd_sz > 0) {
+		memcpy(outpack+pktsize, wol_passwd, wol_passwd_sz);
+		pktsize += wol_passwd_sz;
+	}
+
+	if (verbose > 1) {
+		printf("The final packet is: ");
+		for (i = 0; i < pktsize; i++)
+			printf(" %2.2x", outpack[i]);
+		printf(".\n");
+	}
+
+	/* This is necessary for broadcasts to work */
+	if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, (char *)&one, sizeof(one)) < 0)
+		perror("setsockopt: SO_BROADCAST");
+
+#if defined(PF_PACKET)
+	{
+		struct ifreq ifr;
+		strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+		if (ioctl(s, SIOCGIFINDEX, &ifr) == -1) {
+			fprintf(stderr, "SIOCGIFINDEX on %s failed: %s\n", ifname,
+					strerror(errno));
+			return 1;
+		}
+		memset(&whereto, 0, sizeof(whereto));
+		whereto.sll_family = AF_PACKET;
+		whereto.sll_ifindex = ifr.ifr_ifindex;
+		/* The manual page incorrectly claims the address must be filled.
+		   We do so because the code may change to match the docs. */
+		whereto.sll_halen = ETH_ALEN;
+		memcpy(whereto.sll_addr, outpack, ETH_ALEN);
+
+	}
+#else
+	whereto.sa_family = 0;
+	strcpy(whereto.sa_data, ifname);
+#endif
+
+	if ((i = sendto(s, outpack, pktsize, 0, (struct sockaddr *)&whereto,
+					sizeof(whereto))) < 0)
+		perror("sendto");
+	else if (debug)
+		printf("Sendto worked ! %d.\n", i);
+
+#ifdef USE_SEND
+	if (bind(s, (struct sockaddr *)&whereto, sizeof(whereto)) < 0)
+		perror("bind");
+	else if (send(s, outpack, 100, 0) < 0)
+		perror("send");
+#endif
+#ifdef USE_SENDMSG
+	{
+		struct msghdr msghdr = { 0,};
+		struct iovec iovector[1];
+		msghdr.msg_name = &whereto;
+		msghdr.msg_namelen = sizeof(whereto);
+		msghdr.msg_iov = iovector;
+		msghdr.msg_iovlen = 1;
+		iovector[0].iov_base = outpack;
+		iovector[0].iov_len = pktsize;
+		if ((i = sendmsg(s, &msghdr, 0)) < 0)
+			perror("sendmsg");
+		else if (debug)
+			printf("sendmsg worked, %d (%d).\n", i, errno);
+	}
+#endif
+
+	return 0;
+}
+
+/* Convert the host ID string to a MAC address.
+   The string may be a
+	Host name
+    IP address string
+	MAC address string
+*/
+
+static int get_dest_addr(const char *hostid, struct ether_addr *eaddr)
+{
+	struct ether_addr *eap;
+
+	eap = ether_aton(hostid);
+	if (eap) {
+		*eaddr = *eap;
+		if (debug)
+			fprintf(stderr, "The target station address is %s.\n",
+					ether_ntoa(eaddr));
+	} else if (ether_hostton(hostid, eaddr) == 0) {
+		if (debug)
+			fprintf(stderr, "Station address for hostname %s is %s.\n",
+					hostid, ether_ntoa(eaddr));
+	} else {
+		(void)fprintf(stderr,
+					  "etherwake: The Magic Packet host address must be "
+					  "specified as\n"
+					  "  - a station address, 00:11:22:33:44:55, or\n"
+					  "  - a hostname with a known 'ethers' entry.\n");
+		return -1;
+	}
+	return 0;
+}
+
+
+static int get_fill(unsigned char *pkt, struct ether_addr *eaddr)
+{
+	int offset, i;
+	unsigned char *station_addr = eaddr->ether_addr_octet;
+
+	if (opt_broadcast)
+		memset(pkt+0, 0xff, 6);
+	else
+		memcpy(pkt, station_addr, 6);
+	memcpy(pkt+6, station_addr, 6);
+	pkt[12] = 0x08;				/* Or 0x0806 for ARP, 0x8035 for RARP */
+	pkt[13] = 0x42;
+	offset = 14;
+
+	memset(pkt+offset, 0xff, 6);
+	offset += 6;
+
+	for (i = 0; i < 16; i++) {
+		memcpy(pkt+offset, station_addr, 6);
+		offset += 6;
+	}
+	if (debug) {
+		fprintf(stderr, "Packet is ");
+		for (i = 0; i < offset; i++)
+			fprintf(stderr, " %2.2x", pkt[i]);
+		fprintf(stderr, ".\n");
+	}
+	return offset;
+}
+
+static int get_wol_pw(const char *optarg)
+{
+	int passwd[6];
+	int byte_cnt;
+	int i;
+
+	byte_cnt = sscanf(optarg, "%2x:%2x:%2x:%2x:%2x:%2x",
+					  &passwd[0], &passwd[1], &passwd[2],
+					  &passwd[3], &passwd[4], &passwd[5]);
+	if (byte_cnt < 4)
+		byte_cnt = sscanf(optarg, "%d.%d.%d.%d",
+						  &passwd[0], &passwd[1], &passwd[2], &passwd[3]);
+	if (byte_cnt < 4) {
+		fprintf(stderr, "Unable to read the Wake-On-LAN password.\n");
+		return 0;
+	}
+	printf(" The Magic packet password is %2.2x %2.2x %2.2x %2.2x (%d).\n",
+		   passwd[0], passwd[1], passwd[2], passwd[3], byte_cnt);
+	for (i = 0; i < byte_cnt; i++)
+		wol_passwd[i] = passwd[i];
+	return wol_passwd_sz = byte_cnt;
+}
+
+#if 0
+{
+	to = (struct sockaddr_in *)&whereto;
+	to->sin_family = AF_INET;
+	if (inet_aton(target, &to->sin_addr)) {
+		hostname = target;
+	}
+	memset (&sa, 0, sizeof sa);
+	sa.sa_family = AF_INET;
+	strncpy (sa.sa_data, interface, sizeof sa.sa_data);
+	sendto (sock, buf, bufix + len, 0, &sa, sizeof sa);
+	strncpy (sa.sa_data, interface, sizeof sa.sa_data);
+#if 1
+	sendto (sock, buf, bufix + len, 0, &sa, sizeof sa);
+#else
+	bind (sock, &sa, sizeof sa);
+	connect();
+	send (sock, buf, bufix + len, 0);
+#endif
+}
+#endif
+
+
+/*
+ * Local variables:
+ *  compile-command: "gcc -O -Wall -o ether-wake ether-wake.c"
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  c-indent-level: 4
+ *  tab-width: 4
+ * End:
+ */

+ 2 - 1
EVSE/Modularization/Infypwr_PsuCommObj.c

@@ -13,6 +13,7 @@
 #define MODULE_MAX_VOL		1000
 
 #define DEBUG_LIB						1
+#define CHECK_PSU_NUM_COUNT				30
 
 void PRINTF_LIB_FUNC(char *string, ...);
 float IEEE_754_to_float(const byte raw[4]);
@@ -314,7 +315,7 @@ void ReceiveDataFromCanBus()
 							}
 							else
 							{
-								if (checkTotalCount >= 10)
+								if (checkTotalCount >= CHECK_PSU_NUM_COUNT)
 								{
 									printf("***** Total Count = %d ***** \n", count);
 									_totalModuleCount = count;

+ 310 - 3
EVSE/Modularization/Module_PowerSharing.c

@@ -6,6 +6,36 @@
  */
 #include "Module_PowerSharing.h"
 
+//-----------------------------------------------------------------------------
+//#define MODPS_FW_VER_TYPE_FORMAL	//V0.XX
+#define MODPS_FW_VER_TYPE_TEST		//T0.XX
+
+#define MODPS_FW_VER_NUM	(1)    //V/T0.01
+#define MODPS_FW_DATE		("20220730")
+
+//-----------------------------------------------------------------------------
+#if (MODPS_FW_VER_NUM >= 1)
+#define MODIFY_MODPS_BALANCE_CHECK_LOOP
+#define FUNC_MODPS_APPEND_LOG
+#endif
+
+//-----------------------------------------------------------------------------
+
+char Version_And_Date[2][10] = { 0 };
+
+void Init_FW_Info(void)
+{
+#ifdef MODPS_FW_VER_TYPE_FORMAL
+    sprintf(Version_And_Date[0], "V%4.2f", MODPS_FW_VER_NUM * 0.01);
+#endif
+
+#ifdef MODPS_FW_VER_TYPE_TEST
+    sprintf(Version_And_Date[0], "T%4.2f", MODPS_FW_VER_NUM * 0.01);
+#endif
+
+    sprintf(Version_And_Date[1], "%s", MODPS_FW_DATE);
+}
+
 struct SysConfigAndInfo		*ShmSysConfigAndInfo;
 struct StatusCodeData 		*ShmStatusCodeData;
 struct OCPP16Data			*ShmOCPP16Data;
@@ -735,18 +765,18 @@ int conn_update_status(int socketFd, Connector_Info *connectorInfo, uint8_t conn
 int conn_getOnHandCurrent(void)
 {
 	int result = 0;
-
 	for(uint8_t idx=0;idx<CONNECTION_LIMIT;idx++)
 	{
 		if(ShmPowerSharing->Connection_Info[idx].isSocketConnected)
 		{
 			for(uint8_t gun_index=0;gun_index<ShmPowerSharing->Connection_Info[idx].connectorCount;gun_index++)
 			{
-				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);
+				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);
 			}
 		}
 	}
-
 	result = checkChargingProfileLimit() - result;
 
 	if(ShmPowerSharing->onHandCurrent != result)
@@ -819,6 +849,11 @@ int tcpSocketServer(void)
 	serverInfo.sin_addr.s_addr = htonl(INADDR_ANY);
 	serverInfo.sin_port = htons(LISTEN_PORT_TCP);
 
+
+#ifdef FUNC_MODULE_POWER_SHARING_APPEND_LOG
+	DEBUG_INFO("==========[ tcpSocketServer begin ]==========\n");
+#endif
+
 	if(bind(sockFd, (struct sockaddr *)&serverInfo, sizeof(serverInfo)) < 0)
 		DEBUG_ERROR("TCP server socket bind fail.\n");
 
@@ -1240,6 +1275,272 @@ int tcpSocketClient(void)
 //==========================================
 // Local loading balance check
 //==========================================
+#ifdef MODIFY_MODPS_BALANCE_CHECK_LOOP
+
+Connector_Info* GetIsetMaxGun(void)
+{
+	struct CONNECTION_INFO* pDev = NULL;
+	Connector_Info* pGun = NULL;
+	uint16_t* pIset = NULL;
+	uint16_t* pIout = NULL;
+	uint16_t Imin = 0;
+	uint16_t IsetMax = 6;
+	Connector_Info* pGunIsetMax = NULL;
+
+	for (uint8_t i = 0; i < CONNECTION_LIMIT; i++)
+	{
+		pDev = &ShmPowerSharing->Connection_Info[i];
+		if (!pDev->isSocketConnected)
+		{
+			continue;
+		}
+		for (uint8_t j = 0; j < pDev->connectorCount; j++)
+		{
+			pGun = &pDev->connectorInfo[j];
+			if (pGun->isGunConnected)
+			{
+				pIset = &pGun->availableSharingCurrent;
+				pIout = &pGun->presentOutputCurrent;
+				Imin = pGun->connectorType==CONNECTOR_TYPE_DC ? SHARE_MIN_DC : SHARE_MIN_AC;
+				if (*pIset > Imin && *pIout > Imin && *pIset > IsetMax)
+				{
+					IsetMax = *pIset;
+					pGunIsetMax = pGun;
+				}
+			}
+		}
+	}
+
+//	if (pGunIsetMax)
+//	{
+//		DEBUG_INFO("GunIsetMax: %d / %d (%d)\n", pGunIsetMax->presentOutputCurrent,
+//				pGunIsetMax->availableSharingCurrent, pGunIsetMax->connectorType);
+//	}
+	return pGunIsetMax;
+}
+
+Connector_Info* GetIsetMinGun(void)
+{
+	struct CONNECTION_INFO* pDev = NULL;
+	Connector_Info* pGun = NULL;
+	uint16_t* pIset = NULL;
+	uint16_t* pIout = NULL;
+	uint16_t Imin = 0;
+	uint16_t IsetMin = 1000;
+	Connector_Info* pGunIsetMin = NULL;
+
+	for (uint8_t i = 0; i < CONNECTION_LIMIT; i++)
+	{
+		pDev = &ShmPowerSharing->Connection_Info[i];
+		if (!pDev->isSocketConnected)
+		{
+			continue;
+		}
+		for (uint8_t j = 0; j < pDev->connectorCount; j++)
+		{
+			pGun = &pDev->connectorInfo[j];
+			if (pGun->isGunConnected)
+			{
+				pIset = &pGun->availableSharingCurrent;
+				pIout = &pGun->presentOutputCurrent;
+				Imin = pGun->connectorType==CONNECTOR_TYPE_DC ? SHARE_MIN_DC : SHARE_MIN_AC;
+				if (*pIset >= Imin && *pIout >= Imin && *pIset < IsetMin)
+				{
+					IsetMin = *pIset;
+					pGunIsetMin = pGun;
+				}
+			}
+		}
+	}
+
+//	if (pGunIsetMin)
+//	{
+//		DEBUG_INFO("GunIsetMin: %d / %d (%d)\n", pGunIsetMin->presentOutputCurrent,
+//				pGunIsetMin->availableSharingCurrent, pGunIsetMin->connectorType);
+//	}
+	return pGunIsetMin;
+}
+
+int balance_check_loop(void)
+{
+	DEBUG_INFO("==========[ balance_check_loop begin ]==========\n");
+	for(;;)
+	{
+		// Get connection info
+		conn_getConectedQuantity();
+		conn_getOnHandCurrent();
+		conn_getConectedConnector();
+
+		// Check conn heart beat
+		for(uint8_t idx=0;idx<CONNECTION_LIMIT;idx++)
+		{
+			if(ShmPowerSharing->Connection_Info[idx].isSocketConnected &&
+			   (getDiffSecNow(ShmPowerSharing->Connection_Info[idx].timer[POWERSHARING_TMR_IDX_HEARTBEAT]) > TIMEOUT_SPEC_HEARTBEAT))
+			{
+				DEBUG_INFO("SocketFd-%d heart beat is over %d seconds.\n", ShmPowerSharing->Connection_Info[idx].socketFd, TIMEOUT_SPEC_HEARTBEAT);
+				for(uint8_t gun_index=0;gun_index<ShmPowerSharing->Connection_Info[idx].connectorCount;gun_index++)
+					ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].isGunConnected = FALSE;
+				ShmPowerSharing->Connection_Info[idx].isSocketConnected = FALSE;
+			}
+		}
+
+		// Check available power
+		if(ShmPowerSharing->isDetectNewConnected || (ShmPowerSharing->onHandCurrent < 0))
+		{
+			for(uint8_t idx=0;idx<CONNECTION_LIMIT;idx++)
+			{
+				for(uint8_t gun_index=0;gun_index<ShmPowerSharing->Connection_Info[idx].connectorCount;gun_index++)
+				{
+					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_DC?SHARE_MIN_DC:SHARE_MIN_AC);
+					}
+					else
+					{
+						ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent = 0;
+					}
+				}
+			}
+
+			if(ShmPowerSharing->onHandCurrent < 0)
+				DEBUG_INFO("On hand current < 0 re-allocate available current to each connection.\n");
+
+			if(ShmPowerSharing->isDetectNewConnected)
+			{
+				DEBUG_INFO("Detect gun connected re-allocate available current to each connection.\n");
+				ShmPowerSharing->isDetectNewConnected = NO;
+			}
+		}
+
+		struct CONNECTION_INFO* pDev = NULL;
+		Connector_Info* pGun = NULL;
+		uint16_t* pIset = NULL;
+		uint16_t* pIout = NULL;
+		uint16_t Imin = 0;
+
+		for(uint8_t idx = 0; idx < CONNECTION_LIMIT; idx++)
+		{
+			pDev = &ShmPowerSharing->Connection_Info[idx];
+			for(uint8_t gun_index = 0; gun_index < pDev->connectorCount; gun_index++)
+			{
+				pGun = &pDev->connectorInfo[gun_index];
+				pIset = &pGun->availableSharingCurrent;
+				pIout = &pGun->presentOutputCurrent;
+				Imin = (pGun->connectorType == CONNECTOR_TYPE_DC ? SHARE_MIN_DC : SHARE_MIN_AC);
+
+				if(pDev->isSocketConnected && pGun->isGunConnected)
+				{
+					if((getDiffSecNow(pGun->tmrCheckCapacity) >= INTERVAL_SPEC_CHECK_CAPACITY))
+					{
+						int16_t Idiff = *pIset - *pIout;
+						if(Idiff > 3)
+						{
+							int32_t IsetAdd = - (Idiff >> 1);
+							uint16_t IsetNext = *pIset + IsetAdd;
+							if(IsetNext >= Imin)
+								*pIset = IsetNext;
+							else
+								*pIset = Imin;
+						}
+						else if((abs(Idiff) <= 1) && (ShmPowerSharing->onHandCurrent > 0))
+						{
+							int AvgCurr = ShmPowerSharing->onHandCurrent /
+								(ShmPowerSharing->connectedConnectorQty == 0 ? 1 : ShmPowerSharing->connectedConnectorQty);
+							*pIset += (pGun->connectorType == CONNECTOR_TYPE_AC_THREE ? AvgCurr / 3 : AvgCurr);
+						}
+						else
+						{
+						}
+
+						Connector_Info* pGunIsetMax = GetIsetMaxGun();
+						Connector_Info* pGunIsetMin = GetIsetMinGun();
+						if (pGun == pGunIsetMax && pGunIsetMax == pGunIsetMin)
+						{
+							if (pGun->connectorType == CONNECTOR_TYPE_AC_THREE)
+							{
+								if (ShmPowerSharing->onHandCurrent >= 3)
+								{
+									*pIset += 1;
+									conn_getOnHandCurrent();
+								}
+							}
+							else
+							{
+								for (uint8_t i = 1; i <= 1; i++)
+								{
+									if (ShmPowerSharing->onHandCurrent > 0)
+									{
+										*pIset += 1;
+										conn_getOnHandCurrent();
+									}
+									else
+									{
+										break;
+									}
+								}
+							}
+						}
+						else if (pGun == pGunIsetMin)
+						{
+							if (pGun->connectorType == CONNECTOR_TYPE_AC_THREE)
+							{
+								if (ShmPowerSharing->onHandCurrent >= 3)
+								{
+									*pIset += 1;
+									conn_getOnHandCurrent();
+								}
+							}
+							else
+							{
+								for (uint8_t i = 1; i <= 1; i++)
+								{
+									if (ShmPowerSharing->onHandCurrent > 0)
+									{
+										*pIset += 1;
+										conn_getOnHandCurrent();
+									}
+									else
+									{
+										break;
+									}
+								}
+							}
+						}
+						else if (pGun == pGunIsetMax)
+						{
+							if (pGun->connectorType == CONNECTOR_TYPE_AC_THREE)
+							{
+								*pIset -= 1;
+								conn_getOnHandCurrent();
+							}
+							else
+							{
+								*pIset -= 1;
+								conn_getOnHandCurrent();
+							}
+						}
+						refreshStartTimer(&ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].tmrCheckCapacity);
+					}
+				}
+				else
+				{
+					if(*pIset != 0)
+					{
+						DEBUG_INFO("Dupfd-%d on conn-%d available current reset to 0A\n", ShmPowerSharing->Connection_Info[idx].socketFd, idx);
+					}
+					*pIset = 0;
+				}
+			}
+		}
+
+		usleep(100000);
+	}
+
+	return FAIL;
+}
+#else //MODIFY_MODPS_BALANCE_CHECK_LOOP
+
 int balance_check_loop(void)
 {
 	for(;;)
@@ -1334,6 +1635,7 @@ int balance_check_loop(void)
 
 	return FAIL;
 }
+#endif //MODIFY_MODPS_BALANCE_CHECK_LOOP
 
 //==========================================
 // Main process
@@ -1355,6 +1657,11 @@ int main(void)
 		return 0;
 	}
 
+	Init_FW_Info();
+	DEBUG_INFO("\n\n");
+	DEBUG_INFO("Latest Firmware Version : [ %s ]\n", Version_And_Date[0]);
+	DEBUG_INFO("Latest Upgrade Date : [ %s ]\n", Version_And_Date[1]);
+
 	// Enable server if rotary switch not slave mode
 	if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing == 1)
 	{

+ 7 - 6
EVSE/Modularization/Module_RFID.c

@@ -2,9 +2,9 @@
  * 	Module_RFID.c
  *
  *  Created on: 2019-10-24
- *  Update: 2020-10-19
+ *  Update: 2022-08-09
  *  Author: Eason Yang
- *	Version: V0.03
+ *	Version: V0.04
  *
  * History 
  * 1. Added : Reyax code.
@@ -60,6 +60,7 @@ unsigned int LENGTH_0	= 0;
 unsigned int LENGTH_4	= 4;
 unsigned int LENGTH_6	= 6;
 unsigned int LENGTH_7	= 7;
+unsigned int LENGTH_8	= 8;
 unsigned int LENGTH_10	= 10;
 
 //==================================
@@ -250,7 +251,7 @@ bool getRequestCardSN(int Fd, int moduleType, RFID* rfid)
 	else if(FELICA_REQUEST_SN(Fd,moduleType,serialNumber) == true)
 	{
 		rfid->cardType = FELICA;
-		rfid->snType = RFID_SN_TYPE_6BYTE;
+		rfid->snType = RFID_SN_TYPE_8BYTE;
 		memcpy(rfid->currentCard, &serialNumber, 32);
 		sleep(2);
 
@@ -571,9 +572,9 @@ bool FELICA_REQUEST_SN(int Fd, int moduleType, unsigned char *data)
 					{
 						if((rxByte[1] == RFID_CMD_FELICA_POLLING_REQUEST) && (rxByte[0] >= 22))
 						{
-							cardLength = LENGTH_6;
-							memcpy(data, rxByte+6, cardLength);
-							DEBUG_INFO_1("FELICA SN: %02X-%02X-%02X-%02X-%02X-%02X\n", data[0], data[1], data[2], data[3], data[4], data[5]);
+							cardLength = LENGTH_8;
+							memcpy(data, rxByte+4, cardLength);
+							DEBUG_INFO_1("FELICA SN: %02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X\n", data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
 
 							isSuccess = true;
 						}

+ 3 - 2
EVSE/Modularization/Module_RFID.h

@@ -2,9 +2,9 @@
  * 	Module_RFID.h
  *
  *  Created on: 2019-10-24
- *  Update: 2020-10-19
+ *  Update: 2022-08-09
  *  Author: Eason Yang
- *	Version: V0.03
+ *	Version: V0.04
  *
  * History
  * 1. Added : Reyax constant.
@@ -63,6 +63,7 @@ typedef struct Rfid
 #define RFID_SN_TYPE_4BYTE		4
 #define RFID_SN_TYPE_6BYTE		6
 #define RFID_SN_TYPE_7BYTE      7
+#define RFID_SN_TYPE_8BYTE		8
 #define RFID_SN_TYPE_10BYTE     10
 
 //==================================

+ 2 - 6
EVSE/Modularization/WebService.c

@@ -2642,12 +2642,10 @@ int main(int argc, char *argv[]) {
 		MaintainServerSecurityPassword = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.MaintainServerSecurityPassword);
 		chargePointVendor = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.chargePointVendor);
 		MaintainServerURL = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.MaintainServerURL);
-		if(strcmp(IsDO, "AX") == 0 ){
+		if(strcmp(IsDO, "AX") == 0 || strcmp(IsDO, "AW") == 0 || strcmp(IsAcDc, "D") == 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){
 			OcppReceiptrURL = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.OcppReceiptrURL);
 		}
 		/*for TTIA*/
@@ -3078,12 +3076,10 @@ int main(int argc, char *argv[]) {
 		json_object_object_add(jobj4,"MaintainServerSecurityProfile",MaintainServerSecurityProfile);
 		json_object_object_add(jobj4,"MaintainServerSecurityPassword",MaintainServerSecurityPassword);
 		json_object_object_add(jobj4,"MaintainServerURL",MaintainServerURL);
-		if(strcmp(IsDO, "AX") == 0){
+		if(strcmp(IsDO, "AX") == 0 || strcmp(IsDO, "AW") == 0 || strcmp(IsAcDc, "D") == 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){
 			json_object_object_add(jobj4,"OcppReceiptrURL",OcppReceiptrURL);
 		}
 		/*for TTIA*/

+ 15 - 1
EVSE/Modularization/ocpp20/JsonParser.c

@@ -181,7 +181,7 @@ void ReceivedMessage(void *in, size_t len)
 
 	if(tempin[0] != '\0')
 	{
-		if(strcmp((const char *)tempin,"[ ]") == 0)
+		if(strcmp((const char *)tempin,"[ ]") == 0 || strcmp((const char *)tempin,"[]") == 0)
 		{
 			DEBUG_WARN("Message is empty array.\n");
 			return;
@@ -191,6 +191,20 @@ void ReceivedMessage(void *in, size_t len)
 		obj = json_tokener_parse(tempin);
 		if(!is_error(obj))
 		{
+			if(json_object_is_type(obj, json_type_array))
+			{
+				if(json_object_array_length(obj) < 3)
+				{
+					DEBUG_WARN("Message parsed array count is less than 3.\n");
+					return;
+				}
+			}
+			else
+			{
+				DEBUG_WARN("Message is not an array type.\n");
+				return;
+			}
+
 			MsgType = json_object_get_int(json_object_array_get_idx(obj, 0));
 			sprintf(UniqueId, "%s", json_object_get_string(json_object_array_get_idx(obj, 1)));
 

+ 193 - 81
EVSE/Modularization/ocpp20/MessageHandler.c

@@ -4277,9 +4277,17 @@ void checkChargingStationMaxProfile(uint32_t durationReq, struct ChargingProfile
 									for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
 									{
 										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
-										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0 ), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
-																														 3:
-																														 json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
+										if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
+										{
+											if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
+												maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
+											else
+												maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
+										}
+										else
+										{
+											maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
+										}
 										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
 									}
 								}
@@ -4290,9 +4298,17 @@ void checkChargingStationMaxProfile(uint32_t durationReq, struct ChargingProfile
 									for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
 									{
 										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
-										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
-																														 3:
-																														 json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
+										if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
+										{
+											if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
+												maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
+											else
+												maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
+										}
+										else
+										{
+											maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
+										}
 										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
 									}
 								}
@@ -4387,9 +4403,17 @@ void checkChargingStationMaxProfile(uint32_t durationReq, struct ChargingProfile
 							for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
 							{
 								maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
-								maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
-																												 3:
-																												 json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
+								if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
+								{
+									if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
+										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
+									else
+										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
+								}
+								else
+								{
+									maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
+								}
 								maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr((char*)json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
 							}
 						}
@@ -4400,9 +4424,17 @@ void checkChargingStationMaxProfile(uint32_t durationReq, struct ChargingProfile
 							for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
 							{
 								maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
-								maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
-																												 3:
-																												 json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
+								if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
+								{
+									if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
+										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
+									else
+										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
+								}
+								else
+								{
+									maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
+								}
 								maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr((char*)json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
 							}
 						}
@@ -4732,7 +4764,7 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 		compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
 		compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
 		compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
-		compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 0;
+		compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
 	}
 	compositeProfile.id = 0;
 	compositeProfile.stackLevel = 99 ;
@@ -4817,9 +4849,17 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 									for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
 									{
 										txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
-										txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
-																													    3:
-																														json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
+										if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
+										{
+											if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
+												txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
+											else
+												txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
+										}
+										else
+										{
+											txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
+										}
 										txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
 									}
 								}
@@ -4830,9 +4870,17 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 									for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
 									{
 										txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
-										txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
-																													    3:
-																														json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
+										if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
+										{
+											if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
+												txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
+											else
+												txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
+										}
+										else
+										{
+											txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
+										}
 										txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
 									}
 								}
@@ -4930,9 +4978,17 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 							for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
 							{
 								txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
-								txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
-																												3:
-																												json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
+								if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
+								{
+									if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
+										txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
+									else
+										txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
+								}
+								else
+								{
+									txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
+								}
 								txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
 							}
 						}
@@ -4943,9 +4999,17 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 							for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
 							{
 								txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
-								txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
-																												3:
-																												json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
+								if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
+								{
+									if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
+										txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
+									else
+										txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
+								}
+								else
+								{
+									txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
+								}
 								txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
 							}
 						}
@@ -5117,9 +5181,17 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 									for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
 									{
 										defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
-										defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
-																															   3:
-																															   json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
+										if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
+										{
+											if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
+												defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
+											else
+												defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
+										}
+										else
+										{
+											defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
+										}
 										defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
 									}
 								}
@@ -5130,9 +5202,17 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 									for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
 									{
 										defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
-										defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
-																															   3:
-																															   json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
+										if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
+										{
+											if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
+												defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
+											else
+												defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
+										}
+										else
+										{
+											defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
+										}
 										defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
 									}
 								}
@@ -5229,9 +5309,17 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 							for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
 							{
 								defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
-								defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
-																											  	  	   3:
-																													   json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
+								if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
+								{
+									if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
+										defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
+									else
+										defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
+								}
+								else
+								{
+									defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
+								}
 								defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
 							}
 						}
@@ -5242,9 +5330,17 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 							for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
 							{
 								defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
-								defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
-																											  	  	   3:
-																													   json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
+								if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
+								{
+									if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
+										defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
+									else
+										defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
+								}
+								else
+								{
+									defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
+								}
 								defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
 							}
 						}
@@ -5415,9 +5511,17 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 									for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
 									{
 										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
-										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
-																														 3:
-																														 json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
+										if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
+										{
+											if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
+												maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
+											else
+												maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
+										}
+										else
+										{
+											maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
+										}
 										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
 									}
 								}
@@ -5428,9 +5532,17 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 									for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
 									{
 										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
-										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
-																														 3:
-																														 json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
+										if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
+										{
+											if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
+												maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
+											else
+												maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
+										}
+										else
+										{
+											maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
+										}
 										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
 									}
 								}
@@ -5526,9 +5638,17 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 							for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
 							{
 								maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
-								maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
-																												 3:
-																												 json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
+								if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
+								{
+									if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
+										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
+									else
+										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
+								}
+								else
+								{
+									maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
+								}
 								maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr((char*)json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
 							}
 						}
@@ -5539,9 +5659,17 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 							for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
 							{
 								maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
-								maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
-																												 3:
-																												 json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
+								if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
+								{
+									if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
+										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
+									else
+										maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
+								}
+								else
+								{
+									maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
+								}
 								maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr((char*)json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
 							}
 						}
@@ -7324,7 +7452,7 @@ void CheckSystemValue(void)
 					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
 					if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
 					{
-						cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
+						cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
 					}
 				}// End for GB
 			}
@@ -7638,7 +7766,7 @@ void CheckSystemValue(void)
 
 						if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CHARGING) &&
 						   (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_COMPLETE) &&
-						   (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]))
+						   (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) && (AcPreviousSystemStatus[index] != 99))
 						{
 							ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
 						}
@@ -7723,7 +7851,8 @@ void CheckSystemValue(void)
 		}
 
 		// Sample period MeterValue
-		if(getDiffSecNow(clientTime.MeterValues[gun_index]) >= ((atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)>3)?(atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)- 1):3))
+		if((atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value) > 0) &&
+		   (getDiffSecNow(clientTime.MeterValues[gun_index]) >= ((atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)>3)?(atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)- 1):3)))
 		{
 			//check Transaction active
 			if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
@@ -7838,8 +7967,9 @@ void CheckSystemValue(void)
 			if(cpinitateMsg.bits[gun_index].SampleMeterReq == ON)
 			{
 				if(atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value) > 0)
+				{
 					sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic);
-
+				}
 				cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
 			}
 
@@ -9612,7 +9742,6 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 		// Transaction meter value send by TransactionEvent message
 		memcpy(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], &ShmOCPP20Data->MeterValues[gun_index].meterValue[0], sizeof(struct MeterValueType));
 		ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
-
 		result = PASS;
 	}
 	else
@@ -11448,7 +11577,6 @@ int sendTransactionEventRequest(int gun_index)
 	json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
 	json_object_object_add(TransactionEvent, "evse", evse);
 
-
 	if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
 	{
 		for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
@@ -13648,12 +13776,12 @@ int handleClearChargingProfileRequest(char *uuid, char *payload)
 			while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
 			{
 				//------------------------tempconnectorIdInt------------------------//
-				loc = strstr(sLineWord, "connectorId");
+				loc = strstr(sLineWord, "evseId");
 				c = 0;
 				memset(sstr ,0, sizeof(sstr) );
-				while (loc[strlen("connectorId")+2+c] != ',')
+				while (loc[strlen("evseId")+2+c] != ',')
 				{
-					sstr[c] = loc[strlen("connectorId")+2+c];
+					sstr[c] = loc[strlen("evseId")+2+c];
 					c++;
 				}
 				sstr[c] = '\0';
@@ -13737,7 +13865,6 @@ int handleClearChargingProfileRequest(char *uuid, char *payload)
 			   // clear temp file
 			   sprintf(str,"rm -f %s",temp);
 			   system(str);
-
 		   }
 		   else
 		   {
@@ -15933,10 +16060,7 @@ int handleRequestStartTransactionRequest(char *uuid, char *payload)
 							}
 							else
 							{
-								if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE)				//S_IDLE
-									&& (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARING ) 	//S_PRECHARGE
-									&& (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV ) 	//S_PREPARING_FOR_EV
-									&& (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE ))   // S_PREPARING_FOR_EVSE
+								if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq)
 								{
 									DEBUG_WARN("CHAdeMO connector not allow start cause busy.\n.");
 									isAllowStart = FALSE;
@@ -15973,10 +16097,7 @@ int handleRequestStartTransactionRequest(char *uuid, char *payload)
 							}
 							else
 							{
-								if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE)          //S_IDLE
-									&& (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARING)   	//S_PRECHARGE
-									&& (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV)   	//S_PREPARING_FOR_EV
-									&& (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) 	// S_PREPARING_FOR_EVSE
+								if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq)
 								{
 									DEBUG_WARN("CCS connector not allow start cause busy.\n.");
 									isAllowStart = FALSE;
@@ -16014,10 +16135,7 @@ int handleRequestStartTransactionRequest(char *uuid, char *payload)
 							}
 							else
 							{
-								if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE)         	//S_IDLE
-									&& (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARING)		//S_PRECHARGE
-									&& (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV)		//S_PREPARING_FOR_EV
-									&& (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) 		// S_PREPARING_FOR_EVSE
+								if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq)
 								{
 									DEBUG_WARN("GBT connector not allow start cause busy.\n");
 									isAllowStart = FALSE;
@@ -16048,10 +16166,7 @@ int handleRequestStartTransactionRequest(char *uuid, char *payload)
 							}
 							else
 							{
-								if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE)         	//S_IDLE
-									&& (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARING)		//S_PRECHARGE
-									&& (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EV)		//S_PREPARING_FOR_EV
-									&& (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) 		// S_PREPARING_FOR_EVSE
+								if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE) || ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq)
 								{
 									DEBUG_WARN("Dispenser connector not allow start cause busy.\n");
 									isAllowStart = FALSE;
@@ -16090,10 +16205,7 @@ int handleRequestStartTransactionRequest(char *uuid, char *payload)
 							}
 							else
 							{
-								if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE)				//S_IDLE
-									&& (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARING) 	//S_PRECHARGE
-									&& (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) 	//S_PREPARING_FOR_EV
-									&& (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE))   // S_PREPARING_FOR_EVSE
+								if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq)
 								{
 									DEBUG_WARN("AC connector not allow start cause busy.\n");
 									isAllowStart = FALSE;
@@ -16202,7 +16314,7 @@ int handleRequestStartTransactionRequest(char *uuid, char *payload)
 					 }
 				 }
 
-				 if(isHasIdleConnector == TRUE)
+				 if((isHasIdleConnector == TRUE) && !ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq)
 				 {
 					 DEBUG_INFO("Start wait connector link to EV in %s seconds.\n", ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value);
 
@@ -17601,7 +17713,7 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 					}
 					fclose(filePtr);
 
-					if(SetProfileReq.chargingProfile.transactionId != ShmOCPP20Data->TransactionEvent[SetProfileReq.evseId-1].transactionInfo.transactionId)
+					if(strcmp((char*)SetProfileReq.chargingProfile.transactionId, (char*)ShmOCPP20Data->TransactionEvent[SetProfileReq.evseId-1].transactionInfo.transactionId) != 0)
 						isTransactiodIdMismatch = TRUE;
 				}
 			}

+ 88 - 432
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -5078,6 +5078,15 @@ void CheckSystemValue(void)
 			memset(&ShmOCPP16Data->SessionTarget[gun_index], 0x00, sizeof(struct StructSessionTarget));
 		}
 
+		//==========================================
+		// Charger OCMF message
+		//==========================================
+		if(/*(server_sign == TRUE) &&*/ ((ShmOCPP16Data->OcmfData[gun_index].SendOcmfDataReq == 1)))
+		{
+			sendOcmfByDataTransferRequest(gun_index);
+			ShmOCPP16Data->OcmfData[gun_index].SendOcmfDataReq = 0;
+		}
+
 		//==========================================
 		// Charger status report
 		//==========================================
@@ -5858,6 +5867,39 @@ int sendUnplugByDataTransferRequest(int gun_index)
 	return result;
 }
 
+int sendOcmfByDataTransferRequest(int gun_index)
+{
+	sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].VendorId, (char*)ShmSysConfigAndInfo->SysConfig.chargePointVendor);
+	sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].MessageId, "ID_OCMF");
+	sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].Data, "{\\\"txId\\\":%d,\\\"dataString\\\":\\\"%s\\\",\\\"publicKey\\\":\\\"%s\\\"}", ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId, ShmOCPP16Data->OcmfData[gun_index].DataString, ShmOCPP16Data->OcmfData[gun_index].PublicKey);
+
+	mtrace();
+	char message[3000]={0};
+	char guid[37]={0};
+	char tempdata[65]={0};
+	int result = FAIL;
+
+	random_uuid(guid);
+	sprintf(message,"%d,[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
+			(gun_index+1),
+			MESSAGE_TYPE_CALL,
+			guid,
+			ShmOCPP16Data->DataTransfer[gun_index].VendorId,
+			ShmOCPP16Data->DataTransfer[gun_index].MessageId,
+			ShmOCPP16Data->DataTransfer[gun_index].Data);
+
+	sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
+	if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
+	{
+		result = PASS;
+		DEBUG_INFO("DataTransfer mapItem pass\n");
+	}
+
+	queue_operation(QUEUE_OPERATION_ADD, guid, message);
+
+	return result;
+}
+
 int sendDiagnosticsStatusNotificationRequest(char *status)
 {
 	mtrace();
@@ -12286,416 +12328,6 @@ int handleGetLocalListVersionRequest(char *uuid, char *payload)
 	return result;
 }
 
-int handleRemoteStartRequestOrg(char *uuid, char *payload)
-{
-	mtrace();
-	int result = FAIL;
-	int connectorIdInt=-1;
-	int tempIndex = 0;
-	int connectorIdIsNULL, chargingProfileIsNULL;
-	char comfirmstr[20]={0};
-	char cmdBuf[512];
-	json_object *RemoteStartTransaction;
-	FILE *fp;
-
-	DEBUG_INFO("handleRemoteStartRequest ...\n");
-	if(server_pending == TRUE)
-	{
-		return 0;
-	}
-
-	connectorIdIsNULL = chargingProfileIsNULL= FALSE;
-
-	RemoteStartTransaction = json_tokener_parse(payload);
-	if(!is_error(RemoteStartTransaction))
-	{
-		if(json_object_object_get(RemoteStartTransaction, "connectorId") != NULL)
-		{
-			connectorIdInt = json_object_get_int(json_object_object_get(RemoteStartTransaction, "connectorId"));
-		}
-		else
-		{
-			connectorIdIsNULL = TRUE;
-			for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
-			{
-				if(!cpinitateMsg.bits[gun_index].isOnCharging && (strstr((char*)ShmOCPP16Data->StatusNotification[gun_index].Status, "Preparing") != NULL))
-				{
-					connectorIdIsNULL = FALSE;
-					connectorIdInt = (gun_index+1);
-
-					DEBUG_INFO("Remote start without connectorId but detect connector-%02d connected ready to start.\n", connectorIdInt);
-					break;
-				}
-			}
-		}
-
-		if((connectorIdInt <= gunTotalNumber) && (connectorIdInt > 0))
-		{
-			memset(&ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1], 0x00, sizeof(struct StructRemoteStartTransaction));
-			// Required data
-			sprintf((char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].IdTag, "%s", json_object_get_string(json_object_object_get(RemoteStartTransaction, "idTag")));
-
-			// Optional data
-			if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
-			{
-				ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingProfileId = json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfileId"));
-				ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.StackLevel = json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "stackLevel"));
-				sprintf((char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")));
-				sprintf((char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfileKind")));
-
-				if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "transactionId") != NULL)
-					ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.TransactionId = json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "transactionId"));
-
-				if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "recurrencyKind") != NULL)
-					sprintf((char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.RecurrencyKind , "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "recurrencyKind")));
-
-				if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "validFrom") != NULL)
-					sprintf((char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ValidFrom , "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "validFrom")));
-
-				if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "validTo") != NULL)
-					sprintf((char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ValidTo , "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "validTo")));
-
-				if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule") != NULL)
-				{
-					sprintf((char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingRateUnit , "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingRateUnit")));
-
-					if(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
-						ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.Duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "duration"));
-
-					if(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
-						ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.MinChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
-
-					if(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
-						sprintf((char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.StartSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "startSchedule")));
-
-					if(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod") != NULL)
-					{
-						for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
-						{
-							ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
-							ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"));
-
-							if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases") != NULL)
-								ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
-						}
-					}
-				}
-			}
-			else
-			{
-				chargingProfileIsNULL = TRUE;
-			}
-		}
-	}
-	else
-	{
-		connectorIdIsNULL = TRUE;
-	}
-
-	if(connectorIdIsNULL == TRUE)  // Number of the connector on which to start the transaction. connectorId SHALL be > 0
-	{
-		DEBUG_WARN("Connector id is NULL\n.");
-		strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-		goto end;
-	}
-
-	/*
-	enum _SYSTEM_STATUS
-	{
-		S_BOOTING               = 0,
-		S_IDLE,                 = 1
-		S_AUTHORIZING,          = 2
-		S_REASSIGN_CHECK,       = 3
-		S_REASSIGN,             = 4
-		S_PRECHARGE,            = 5
-		S_PREPARING_FOR_EV,     = 6
-		S_PREPARING_FOR_EVSE,   = 7
-		S_CHARGING,             = 8
-		S_TERMINATING,          = 9
-		S_COMPLETE,             = 10
-		S_ALARM,                = 11
-		S_FAULT                 = 12
-	}
-	 */
-	if((connectorIdIsNULL == FALSE)&&(connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber))
-	{
-		//check Transaction active
-		if(gunType[connectorIdInt -1] == GUN_TYPE_CHAdeMO)
-		{
-			if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
-			{
-				tempIndex =  ((connectorIdInt -1) == 2) ? 1: 0;
-			}
-			else
-			{
-				tempIndex = connectorIdInt -1;
-			}
-
-			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
-			{
-				if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex )
-				{
-
-					if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16Data->ReserveNow[index].IdTag, (char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].IdTag) == 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
-					}
-					else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16Data->ReserveNow[index].IdTag, (char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].IdTag) != 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
-						strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-						goto end;
-					}
-					else
-					{
-						if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE)				//S_IDLE
-							&& (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARING ) 	//S_PRECHARGE
-							&& (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV ) 	//S_PREPARING_FOR_EV
-							&& (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE ))   // S_PREPARING_FOR_EVSE
-						{
-							DEBUG_WARN("CHAdeMO connector not allow start\n.");
-							strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-							goto end;
-						}
-					}//END FOR ELSE
-				}
-			}// END FOR CHAdeMO_QUANTITY
-		}
-		else if(gunType[connectorIdInt -1] == GUN_TYPE_CCS)
-		{
-			if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
-			{
-				tempIndex =  ((connectorIdInt -1) == 2) ? 1: 0;
-			}
-			else
-			{
-				tempIndex = connectorIdInt -1;
-			}
-
-			for (int index = 0; index < CCS_QUANTITY; index++)
-			{
-				if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
-				{
-					if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16Data->ReserveNow[index].IdTag, (char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].IdTag) == 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
-					}
-					else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16Data->ReserveNow[index].IdTag, (char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].IdTag) != 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
-						strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-						goto end;
-					}
-					else
-					{
-						if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE)          //S_IDLE
-							&& (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARING)   	//S_PRECHARGE
-							&& (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV)   	//S_PREPARING_FOR_EV
-							&& (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) 	// S_PREPARING_FOR_EVSE
-						{
-							DEBUG_WARN("CCS connector not allow start\n.");
-							strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-							goto end;
-						}
-
-					}// END FOR ELSE
-				}
-			}// END FOR CCS_QUANTITY
-		}
-		else if(gunType[connectorIdInt -1] == GUN_TYPE_GBT)
-		{
-			if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
-			{
-				tempIndex =  ((connectorIdInt -1) == 2) ? 1: 0;
-			}
-			else
-			{
-				tempIndex = connectorIdInt -1;
-			}
-
-			for (int index = 0; index < GB_QUANTITY; index++)
-			{
-				if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex )
-				{
-					if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16Data->ReserveNow[index].IdTag, (char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].IdTag) == 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
-					}
-					else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16Data->ReserveNow[index].IdTag, (char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].IdTag) != 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
-						strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-						goto end;
-					}
-					else
-					{
-						if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE)         	//S_IDLE
-							&& (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARING)		//S_PRECHARGE
-							&& (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV)		//S_PREPARING_FOR_EV
-							&& (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) 		// S_PREPARING_FOR_EVSE
-						{
-							DEBUG_WARN("GB connector not allow start\n.");
-							strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-							goto end;
-						}
-
-					}// END FOR ELSE
-				}
-			} // END FOR GB_QUANTITY
-
-		}
-		else if(gunType[connectorIdInt -1] == GUN_TYPE_DO)
-		{
-			tempIndex = connectorIdInt -1;
-
-			for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
-			{
-				if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex )
-				{
-					if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16Data->ReserveNow[index].IdTag, (char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].IdTag) == 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
-					}
-					else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16Data->ReserveNow[index].IdTag, (char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].IdTag) != 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
-						strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-						goto end;
-					}
-					else
-					{
-						if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE)         	//S_IDLE
-							&& (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARING)		//S_PRECHARGE
-							&& (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EV)		//S_PREPARING_FOR_EV
-							&& (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) 		// S_PREPARING_FOR_EVSE
-						{
-							DEBUG_WARN("GB connector not allow start\n.");
-							strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-							goto end;
-						}
-
-					}// END FOR ELSE
-				}
-			} // END FOR GB_QUANTITY
-
-		}
-		else
-		{
-			if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
-			{
-				tempIndex = 2;
-			}
-			else
-			{
-				tempIndex = connectorIdInt -1;
-			}
-
-			for (int index = 0; index < AC_QUANTITY; index++)
-			{
-				if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex )
-				{
-
-					if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16Data->ReserveNow[index].IdTag, (char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].IdTag) == 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
-					}
-					else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16Data->ReserveNow[index].IdTag, (char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].IdTag) != 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
-						strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-						goto end;
-					}
-					else
-					{
-						if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE)				//S_IDLE
-							&& (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARING) 	//S_PRECHARGE
-							&& (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) 	//S_PREPARING_FOR_EV
-							&& (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE))   // S_PREPARING_FOR_EVSE
-						{
-							DEBUG_WARN("AC connector not allow start\n.");
-							strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-							goto end;
-						}
-
-					}//END FOR ELSE
-				}
-			}// END FOR AC_QUANTITY
-		}
-
-		if(chargingProfileIsNULL == FALSE)
-		{
-			if(strcmp((char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingProfilePurpose, ChargingProfilePurposeTypeStr[TxProfile]) == 0)
-			{
-				ShmOCPP16Data->CsMsg.bits[connectorIdInt -1].RemoteStartTransactionReq = 1;
-				strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Accepted]);
-
-				//memset idTag
-				memset((char *)ShmOCPP16Data->StartTransaction[connectorIdInt -1].IdTag,0, 20);
-				strcpy((char *)ShmOCPP16Data->StartTransaction[connectorIdInt -1].IdTag, (char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].IdTag);
-
-				memset((char *)ShmOCPP16Data->StopTransaction[connectorIdInt -1].IdTag,0, 20);
-				strcpy((char *)ShmOCPP16Data->StopTransaction[connectorIdInt -1].IdTag, (char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].IdTag);
-
-				// Save profile to file
-				sprintf(cmdBuf, "rm -f /Storage/OCPP/TxProfile_%d.json", connectorIdInt);
-				system(cmdBuf);
-
-				sprintf(cmdBuf, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
-				fp = fopen(cmdBuf, "w");
-				fprintf(fp, "{\"connectorId\":%d,\"csChargingProfiles\":%s}\n", connectorIdInt, json_object_to_json_string_ext(json_object_object_get(RemoteStartTransaction, "chargingProfile"), JSON_C_TO_STRING_PLAIN));
-				fclose(fp);
-			}
-			else
-			{
-				DEBUG_WARN("Carging profile purpose not TxProfile.\n.");
-				strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-			}
-		}
-		else
-		{
-			ShmOCPP16Data->CsMsg.bits[connectorIdInt -1].RemoteStartTransactionReq = 1;
-			strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Accepted]);
-
-			//memset idTag
-			memset((char *)ShmOCPP16Data->StartTransaction[connectorIdInt -1].IdTag,0, 20);
-			strcpy((char *)ShmOCPP16Data->StartTransaction[connectorIdInt -1].IdTag, (char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].IdTag);
-
-			memset((char *)ShmOCPP16Data->StopTransaction[connectorIdInt -1].IdTag,0, 20);
-			strcpy((char *)ShmOCPP16Data->StopTransaction[connectorIdInt -1].IdTag, (char*)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].IdTag);
-		}
-	 }
-	 else
-	 {
-		 DEBUG_WARN("Connector id over\n.");
-		 strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-		 //sprintf((char *)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ResponseStatus, "%s" ,comfirmstr);
-	 }
-
-end:
-	json_object_put(RemoteStartTransaction);
-
-	if((connectorIdIsNULL == FALSE) && (connectorIdInt <= gunTotalNumber))
-	{
-		ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ConnectorId = connectorIdInt;
-		sprintf((char *)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ResponseStatus, "%s" ,comfirmstr);
-	}
-
-	//OCPP send RemoteStartConfirmation by first.
-	sendRemoteStartConfirmation(uuid, comfirmstr);
-
-	return result;
-}
-
 int handleRemoteStartRequest(char *uuid, char *payload)
 {
 	mtrace();
@@ -12904,10 +12536,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
 						}
 						else
 						{
-							if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE)				//S_IDLE
-								&& (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARING ) 	//S_PRECHARGE
-								&& (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV ) 	//S_PREPARING_FOR_EV
-								&& (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE ))   // S_PREPARING_FOR_EVSE
+							if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP16Data->MsMsg.bits.isRemoteStartWaitReq)
 							{
 								DEBUG_WARN("CHAdeMO connector not allow start cause busy.\n");
 								strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
@@ -12950,10 +12579,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
 						}
 						else
 						{
-							if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE)          //S_IDLE
-								&& (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARING)   	//S_PRECHARGE
-								&& (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV)   	//S_PREPARING_FOR_EV
-								&& (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) 	// S_PREPARING_FOR_EVSE
+							if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP16Data->MsMsg.bits.isRemoteStartWaitReq)
 							{
 								DEBUG_WARN("CCS connector not allow start cause busy.\n");
 								strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
@@ -12997,10 +12623,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
 						}
 						else
 						{
-							if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE)         	//S_IDLE
-								&& (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARING)		//S_PRECHARGE
-								&& (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV)		//S_PREPARING_FOR_EV
-								&& (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) 		// S_PREPARING_FOR_EVSE
+							if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP16Data->MsMsg.bits.isRemoteStartWaitReq)
 							{
 								DEBUG_WARN("GBT connector not allow start cause busy.\n");
 								strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
@@ -13038,10 +12661,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
 						}
 						else
 						{
-							if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE)         	//S_IDLE
-								&& (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARING)		//S_PRECHARGE
-								&& (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EV)		//S_PREPARING_FOR_EV
-								&& (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) 		// S_PREPARING_FOR_EVSE
+							if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE) || ShmOCPP16Data->MsMsg.bits.isRemoteStartWaitReq)
 							{
 								DEBUG_WARN("Dispenser connector not allow start cause busy.\n");
 								strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
@@ -13087,10 +12707,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
 						}
 						else
 						{
-							if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE)				//S_IDLE
-								&& (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARING) 	//S_PRECHARGE
-								&& (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) 	//S_PREPARING_FOR_EV
-								&& (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE))   // S_PREPARING_FOR_EVSE
+							if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP16Data->MsMsg.bits.isRemoteStartWaitReq)
 							{
 								DEBUG_WARN("AC connector not allow start cause busy.\n");
 								strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
@@ -13145,7 +12762,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
 				 }
 			 }
 
-			 if(isHasIdleConnector == TRUE)
+			 if((isHasIdleConnector == TRUE) && !ShmOCPP16Data->MsMsg.bits.isRemoteStartWaitReq)
 			 {
 				 DEBUG_INFO("Start wait connector link to EV in %s seconds.\n", ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData);
 
@@ -16346,7 +15963,7 @@ int initialConfigurationTable(void)
 	char sstr[256]={0};
 	int c = 0;
 	char *loc;
-	int	confVersion = 18;
+	int	confVersion = 19;
 
 	DEBUG_INFO("initialConfigurationTable...version: %d\n", confVersion);
 	//start_t = clock();
@@ -16811,6 +16428,12 @@ int initialConfigurationTable(void)
 
 		fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","CharingProfileRefreshInterval", "false", ShmOCPP16Data->ConfigurationTable.CoreProfile[CharingProfileRefreshInterval].ItemData);
 
+		// Ocpp Software certificated version
+		ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemAccessibility = 0;
+		strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemName, "OcppSoftwareVersion");
+		sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData, "%s", "V1.00");
+
+		fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","OcppSoftwareVersion", "true", ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData);
 
 		//* Local Auth List Management Profile*/
 		#if 0
@@ -17311,6 +16934,12 @@ int initialConfigurationTable(void)
 					sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[CharingProfileRefreshInterval].ItemData, "%s", valuestr);
 				}
 
+				if(strcmp(keystr, "OcppSoftwareVersion") == 0)
+				{
+					ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
+					sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData, "%s", valuestr);
+				}
+
 				if(strcmp(keystr, "LocalAuthListEnabled") == 0)
 				{
 					ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
@@ -17918,6 +17547,15 @@ void StoreConfigurationTable(void)
 
 	fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","CharingProfileRefreshInterval", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[CharingProfileRefreshInterval].ItemData);
 
+	// OcppSoftwareVersion
+	/*
+	ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemAccessibility = 1;
+	strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemName, "OcppSoftwareVersion");
+	strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData, "" );
+	*/
+
+	fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","OcppSoftwareVersion", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData);
+
 	//* Local Auth List Management Profile*/
 	//LocalAuthListEnabled
 	/*
@@ -19059,6 +18697,24 @@ void getKeyValue(char *keyReq)
 			  strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_CharingProfileRefreshInterval].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[CharingProfileRefreshInterval].ItemData );
 			  isKnowKey = TRUE;
 		  }
+
+		  if(isEmpty ||  strcmp(keyReq, "OcppSoftwareVersion") == 0 )
+		  {
+			  strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_OcppSoftwareVersion].Item, "OcppSoftwareVersion");
+			  strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_OcppSoftwareVersion].Key, "OcppSoftwareVersion");
+
+			  if(ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemAccessibility == 1)
+			  {
+				  strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_OcppSoftwareVersion].ReadOnly, "0"/*"FALSE"*/);
+			  }
+			  else
+			  {
+				  strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_OcppSoftwareVersion].ReadOnly, "1"/*"TRUE"*/);
+			  }
+
+			  strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_OcppSoftwareVersion].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData );
+			  isKnowKey = TRUE;
+		  }
 #if 1
 	      if(isEmpty ||  strcmp(keyReq, "LocalAuthListEnabled") == 0 )
 	      {

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

@@ -418,6 +418,7 @@ enum GetConfigurationKey {
 	GetConfiguration_MaxChargingProfilesInstalled,
 	GetConfiguration_ConfigurationVersion,
 	GetConfiguration_CharingProfileRefreshInterval,
+	GetConfiguration_OcppSoftwareVersion,
 	_GetConfiguration_CNT
 };
 
@@ -468,6 +469,7 @@ int sendAuthorizeRequest(int gun_index);
 int sendBootNotificationRequest(void);
 int sendDataTransferRequest(int gun_index);
 int sendUnplugByDataTransferRequest(int gun_index);
+int sendOcmfByDataTransferRequest(int gun_index);
 int sendFirmwareVersionByDataTransfer(void);
 int sendDiagnosticsStatusNotificationRequest(char *status);
 int sendFirmwareStatusNotificationRequest(char *status);

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

@@ -34,6 +34,7 @@ char OcppPath[384]={0};
 char OcppProtocol[10]={0},OcppHost[128]={0}, OcppTempPath[256]={0};
 int OcppPort=0;
 unsigned char StartTransactionIdTagTemp[20]={0};
+int LastQueuedTransactionId[8] = {0};
 uint8_t	isWebsocketSendable = 1;
 uint8_t	isQueueSendable = 1;
 uint8_t	counterLwsRestart = 0;
@@ -1045,6 +1046,7 @@ int sentqueue()
 							{
 								transactionId_map = transactionId_org;
 							}
+							LastQueuedTransactionId[connectorId-1] = transactionId_map;
 							DEBUG_INFO("Final transactionId       = %d\n", transactionId_map);
 						}
 
@@ -1091,6 +1093,33 @@ int sentqueue()
 								}
 								DEBUG_INFO("Final transactionId       = %d\n", transactionId_map);
 
+								json_object_object_add(objPayload, "data", json_object_new_string(json_object_to_json_string_ext(objData, JSON_C_TO_STRING_PLAIN)));
+								json_object_array_put_idx(obj, 3, objPayload);
+								LWS_Send((char*)json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PLAIN));
+							}
+						}
+						else if(strstr(json_object_get_string(json_object_object_get(objPayload, "messageId")), "ID_OCMF") != NULL)
+						{
+							objData = json_tokener_parse(json_object_get_string(json_object_object_get(objPayload, "data")));
+							if(!is_error(objData))
+							{
+								transactionId_org = json_object_get_int(json_object_object_get(objData, "txId"));
+								DEBUG_INFO("original  transactionId   = %d\n", transactionId_org);
+
+								if(transactionId_org == 0)
+								{
+									//replace transactionId
+									transactionId_map = GetStartTransactionId(connectorId-1);
+									if(transactionId_map == 0)
+										transactionId_map = LastQueuedTransactionId[connectorId-1];
+									json_object_object_add(objData, "txId", json_object_new_int(transactionId_map));
+								}
+								else
+								{
+									transactionId_map = transactionId_org;
+								}
+								DEBUG_INFO("Final transactionId       = %d\n", transactionId_map);
+
 								json_object_object_add(objPayload, "data", json_object_new_string(json_object_to_json_string_ext(objData, JSON_C_TO_STRING_PLAIN)));
 								json_object_array_put_idx(obj, 3, objPayload);
 								LWS_Send((char*)json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PLAIN));
@@ -1328,6 +1357,7 @@ int main(void)
 	queueOpInfo.TransactionMessageResend = 0;
 
 	DEBUG_INFO("Module_OcppBackend task initialization...\n");
+	DEBUG_INFO("Last update date: 2022/08/05 \n");
 	//lws_set_log_level(LLL_PARSER | LLL_HEADER | LLL_ERR | LLL_WARN | LLL_NOTICE | LLL_INFO | LLL_DEBUG | LLL_EXT | LLL_CLIENT | LLL_LATENCY  , NULL);
 
 	if(ProcessShareMemory()== FAIL)

+ 46 - 432
EVSE/Modularization/ocppph/MessageHandler.c

@@ -11791,416 +11791,6 @@ int handleGetLocalListVersionRequest(char *uuid, char *payload)
 	return result;
 }
 
-int handleRemoteStartRequestOrg(char *uuid, char *payload)
-{
-	mtrace();
-	int result = FAIL;
-	int connectorIdInt=-1;
-	int tempIndex = 0;
-	int connectorIdIsNULL, chargingProfileIsNULL;
-	char comfirmstr[20]={0};
-	char cmdBuf[512];
-	json_object *RemoteStartTransaction;
-	FILE *fp;
-
-	DEBUG_INFO("handleRemoteStartRequest ...\n");
-	if(server_pending == TRUE)
-	{
-		return 0;
-	}
-
-	connectorIdIsNULL = chargingProfileIsNULL= FALSE;
-
-	RemoteStartTransaction = json_tokener_parse(payload);
-	if(!is_error(RemoteStartTransaction))
-	{
-		if(json_object_object_get(RemoteStartTransaction, "connectorId") != NULL)
-		{
-			connectorIdInt = json_object_get_int(json_object_object_get(RemoteStartTransaction, "connectorId"));
-		}
-		else
-		{
-			connectorIdIsNULL = TRUE;
-			for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
-			{
-				if(!cpinitateMsg.bits[gun_index].isOnCharging && (strstr((char*)ShmOCPP16DataPH->StatusNotification[gun_index].Status, "Preparing") != NULL))
-				{
-					connectorIdIsNULL = FALSE;
-					connectorIdInt = (gun_index+1);
-
-					DEBUG_INFO("Remote start without connectorId but detect connector-%02d connected ready to start.\n", connectorIdInt);
-					break;
-				}
-			}
-		}
-
-		if((connectorIdInt <= gunTotalNumber) && (connectorIdInt > 0))
-		{
-			memset(&ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1], 0x00, sizeof(struct StructRemoteStartTransaction));
-			// Required data
-			sprintf((char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag, "%s", json_object_get_string(json_object_object_get(RemoteStartTransaction, "idTag")));
-
-			// Optional data
-			if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
-			{
-				ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingProfileId = json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfileId"));
-				ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.StackLevel = json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "stackLevel"));
-				sprintf((char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")));
-				sprintf((char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfileKind")));
-
-				if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "transactionId") != NULL)
-					ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.TransactionId = json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "transactionId"));
-
-				if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "recurrencyKind") != NULL)
-					sprintf((char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.RecurrencyKind , "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "recurrencyKind")));
-
-				if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "validFrom") != NULL)
-					sprintf((char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ValidFrom , "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "validFrom")));
-
-				if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "validTo") != NULL)
-					sprintf((char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ValidTo , "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "validTo")));
-
-				if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule") != NULL)
-				{
-					sprintf((char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingRateUnit , "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingRateUnit")));
-
-					if(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
-						ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.Duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "duration"));
-
-					if(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
-						ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.MinChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
-
-					if(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
-						sprintf((char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.StartSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "startSchedule")));
-
-					if(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod") != NULL)
-					{
-						for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
-						{
-							ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
-							ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"));
-
-							if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases") != NULL)
-								ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
-						}
-					}
-				}
-			}
-			else
-			{
-				chargingProfileIsNULL = TRUE;
-			}
-		}
-	}
-	else
-	{
-		connectorIdIsNULL = TRUE;
-	}
-
-	if(connectorIdIsNULL == TRUE)  // Number of the connector on which to start the transaction. connectorId SHALL be > 0
-	{
-		DEBUG_WARN("Connector id is NULL\n.");
-		strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-		goto end;
-	}
-
-	/*
-	enum _SYSTEM_STATUS
-	{
-		S_BOOTING               = 0,
-		S_IDLE,                 = 1
-		S_AUTHORIZING,          = 2
-		S_REASSIGN_CHECK,       = 3
-		S_REASSIGN,             = 4
-		S_PRECHARGE,            = 5
-		S_PREPARING_FOR_EV,     = 6
-		S_PREPARING_FOR_EVSE,   = 7
-		S_CHARGING,             = 8
-		S_TERMINATING,          = 9
-		S_COMPLETE,             = 10
-		S_ALARM,                = 11
-		S_FAULT                 = 12
-	}
-	 */
-	if((connectorIdIsNULL == FALSE)&&(connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber))
-	{
-		//check Transaction active
-		if(gunType[connectorIdInt -1] == GUN_TYPE_CHAdeMO)
-		{
-			if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
-			{
-				tempIndex =  ((connectorIdInt -1) == 2) ? 1: 0;
-			}
-			else
-			{
-				tempIndex = connectorIdInt -1;
-			}
-
-			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
-			{
-				if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex )
-				{
-
-					if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) == 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
-					}
-					else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) != 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
-						strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-						goto end;
-					}
-					else
-					{
-						if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE)				//S_IDLE
-							&& (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARING ) 	//S_PRECHARGE
-							&& (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV ) 	//S_PREPARING_FOR_EV
-							&& (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE ))   // S_PREPARING_FOR_EVSE
-						{
-							DEBUG_WARN("CHAdeMO connector not allow start\n.");
-							strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-							goto end;
-						}
-					}//END FOR ELSE
-				}
-			}// END FOR CHAdeMO_QUANTITY
-		}
-		else if(gunType[connectorIdInt -1] == GUN_TYPE_CCS)
-		{
-			if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
-			{
-				tempIndex =  ((connectorIdInt -1) == 2) ? 1: 0;
-			}
-			else
-			{
-				tempIndex = connectorIdInt -1;
-			}
-
-			for (int index = 0; index < CCS_QUANTITY; index++)
-			{
-				if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
-				{
-					if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) == 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
-					}
-					else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) != 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
-						strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-						goto end;
-					}
-					else
-					{
-						if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE)          //S_IDLE
-							&& (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARING)   	//S_PRECHARGE
-							&& (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV)   	//S_PREPARING_FOR_EV
-							&& (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) 	// S_PREPARING_FOR_EVSE
-						{
-							DEBUG_WARN("CCS connector not allow start\n.");
-							strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-							goto end;
-						}
-
-					}// END FOR ELSE
-				}
-			}// END FOR CCS_QUANTITY
-		}
-		else if(gunType[connectorIdInt -1] == GUN_TYPE_GBT)
-		{
-			if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
-			{
-				tempIndex =  ((connectorIdInt -1) == 2) ? 1: 0;
-			}
-			else
-			{
-				tempIndex = connectorIdInt -1;
-			}
-
-			for (int index = 0; index < GB_QUANTITY; index++)
-			{
-				if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex )
-				{
-					if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) == 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
-					}
-					else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) != 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
-						strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-						goto end;
-					}
-					else
-					{
-						if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE)         	//S_IDLE
-							&& (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARING)		//S_PRECHARGE
-							&& (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV)		//S_PREPARING_FOR_EV
-							&& (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) 		// S_PREPARING_FOR_EVSE
-						{
-							DEBUG_WARN("GB connector not allow start\n.");
-							strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-							goto end;
-						}
-
-					}// END FOR ELSE
-				}
-			} // END FOR GB_QUANTITY
-
-		}
-		else if(gunType[connectorIdInt -1] == GUN_TYPE_DO)
-		{
-			tempIndex = connectorIdInt -1;
-
-			for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
-			{
-				if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex )
-				{
-					if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) == 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
-					}
-					else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) != 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
-						strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-						goto end;
-					}
-					else
-					{
-						if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE)         	//S_IDLE
-							&& (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARING)		//S_PRECHARGE
-							&& (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EV)		//S_PREPARING_FOR_EV
-							&& (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) 		// S_PREPARING_FOR_EVSE
-						{
-							DEBUG_WARN("GB connector not allow start\n.");
-							strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-							goto end;
-						}
-
-					}// END FOR ELSE
-				}
-			} // END FOR GB_QUANTITY
-
-		}
-		else
-		{
-			if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
-			{
-				tempIndex = 2;
-			}
-			else
-			{
-				tempIndex = connectorIdInt -1;
-			}
-
-			for (int index = 0; index < AC_QUANTITY; index++)
-			{
-				if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex )
-				{
-
-					if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) == 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
-					}
-					else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) != 0))
-					{
-						//Reserved
-						DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
-						strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-						goto end;
-					}
-					else
-					{
-						if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE)				//S_IDLE
-							&& (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARING) 	//S_PRECHARGE
-							&& (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) 	//S_PREPARING_FOR_EV
-							&& (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE))   // S_PREPARING_FOR_EVSE
-						{
-							DEBUG_WARN("AC connector not allow start\n.");
-							strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-							goto end;
-						}
-
-					}//END FOR ELSE
-				}
-			}// END FOR AC_QUANTITY
-		}
-
-		if(chargingProfileIsNULL == FALSE)
-		{
-			if(strcmp((char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingProfilePurpose, ChargingProfilePurposeTypeStr[TxProfile]) == 0)
-			{
-				ShmOCPP16DataPH->CsMsg.bits[connectorIdInt -1].RemoteStartTransactionReq = 1;
-				strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Accepted]);
-
-				//memset idTag
-				memset((char *)ShmOCPP16DataPH->StartTransaction[connectorIdInt -1].IdTag,0, 20);
-				strcpy((char *)ShmOCPP16DataPH->StartTransaction[connectorIdInt -1].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag);
-
-				memset((char *)ShmOCPP16DataPH->StopTransaction[connectorIdInt -1].IdTag,0, 20);
-				strcpy((char *)ShmOCPP16DataPH->StopTransaction[connectorIdInt -1].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag);
-
-				// Save profile to file
-				sprintf(cmdBuf, "rm -f /Storage/OCPP_PH/TxProfile_%d.json", connectorIdInt);
-				system(cmdBuf);
-
-				sprintf(cmdBuf, "/Storage/OCPP_PH/TxProfile_%d.json", connectorIdInt);
-				fp = fopen(cmdBuf, "w");
-				fprintf(fp, "{\"connectorId\":%d,\"csChargingProfiles\":%s}\n", connectorIdInt, json_object_to_json_string_ext(json_object_object_get(RemoteStartTransaction, "chargingProfile"), JSON_C_TO_STRING_PLAIN));
-				fclose(fp);
-			}
-			else
-			{
-				DEBUG_WARN("Carging profile purpose not TxProfile.\n.");
-				strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-			}
-		}
-		else
-		{
-			ShmOCPP16DataPH->CsMsg.bits[connectorIdInt -1].RemoteStartTransactionReq = 1;
-			strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Accepted]);
-
-			//memset idTag
-			memset((char *)ShmOCPP16DataPH->StartTransaction[connectorIdInt -1].IdTag,0, 20);
-			strcpy((char *)ShmOCPP16DataPH->StartTransaction[connectorIdInt -1].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag);
-
-			memset((char *)ShmOCPP16DataPH->StopTransaction[connectorIdInt -1].IdTag,0, 20);
-			strcpy((char *)ShmOCPP16DataPH->StopTransaction[connectorIdInt -1].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag);
-		}
-	 }
-	 else
-	 {
-		 DEBUG_WARN("Connector id over\n.");
-		 strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
-		 //sprintf((char *)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ResponseStatus, "%s" ,comfirmstr);
-	 }
-
-end:
-	json_object_put(RemoteStartTransaction);
-
-	if((connectorIdIsNULL == FALSE) && (connectorIdInt <= gunTotalNumber))
-	{
-		ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ConnectorId = connectorIdInt;
-		sprintf((char *)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ResponseStatus, "%s" ,comfirmstr);
-	}
-
-	//OCPP send RemoteStartConfirmation by first.
-	sendRemoteStartConfirmation(uuid, comfirmstr);
-
-	return result;
-}
-
 int handleRemoteStartRequest(char *uuid, char *payload)
 {
 	mtrace();
@@ -12409,10 +11999,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
 						}
 						else
 						{
-							if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE)				//S_IDLE
-								&& (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARING ) 	//S_PRECHARGE
-								&& (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV ) 	//S_PREPARING_FOR_EV
-								&& (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE ))   // S_PREPARING_FOR_EVSE
+							if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP16DataPH->MsMsg.bits.isRemoteStartWaitReq)
 							{
 								DEBUG_WARN("CHAdeMO connector not allow start cause busy.\n");
 								strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
@@ -12455,10 +12042,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
 						}
 						else
 						{
-							if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE)          //S_IDLE
-								&& (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARING)   	//S_PRECHARGE
-								&& (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV)   	//S_PREPARING_FOR_EV
-								&& (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) 	// S_PREPARING_FOR_EVSE
+							if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP16DataPH->MsMsg.bits.isRemoteStartWaitReq)
 							{
 								DEBUG_WARN("CCS connector not allow start cause busy.\n");
 								strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
@@ -12502,10 +12086,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
 						}
 						else
 						{
-							if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE)         	//S_IDLE
-								&& (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARING)		//S_PRECHARGE
-								&& (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV)		//S_PREPARING_FOR_EV
-								&& (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) 		// S_PREPARING_FOR_EVSE
+							if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP16DataPH->MsMsg.bits.isRemoteStartWaitReq)
 							{
 								DEBUG_WARN("GBT connector not allow start cause busy.\n");
 								strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
@@ -12543,10 +12124,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
 						}
 						else
 						{
-							if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE)         	//S_IDLE
-								&& (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARING)		//S_PRECHARGE
-								&& (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EV)		//S_PREPARING_FOR_EV
-								&& (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) 		// S_PREPARING_FOR_EVSE
+							if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE) || ShmOCPP16DataPH->MsMsg.bits.isRemoteStartWaitReq)
 							{
 								DEBUG_WARN("Dispenser connector not allow start cause busy.\n");
 								strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
@@ -12592,10 +12170,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
 						}
 						else
 						{
-							if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE)				//S_IDLE
-								&& (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARING) 	//S_PRECHARGE
-								&& (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) 	//S_PREPARING_FOR_EV
-								&& (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE))   // S_PREPARING_FOR_EVSE
+							if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP16DataPH->MsMsg.bits.isRemoteStartWaitReq)
 							{
 								DEBUG_WARN("AC connector not allow start cause busy.\n");
 								strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
@@ -12650,7 +12225,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
 				 }
 			 }
 
-			 if(isHasIdleConnector == TRUE)
+			 if((isHasIdleConnector == TRUE) && !ShmOCPP16DataPH->MsMsg.bits.isRemoteStartWaitReq)
 			 {
 				 DEBUG_INFO("Start wait connector link to EV in %s seconds.\n", ShmOCPP16DataPH->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData);
 
@@ -15838,7 +15413,7 @@ int initialConfigurationTable(void)
 	char sstr[256]={0};
 	int c = 0;
 	char *loc;
-	int	confVersion = 17;
+	int	confVersion = 18;
 
 	DEBUG_INFO("initialConfigurationTable...version: %d\n", confVersion);
 	//start_t = clock();
@@ -16275,6 +15850,13 @@ int initialConfigurationTable(void)
 
 		fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","CharingProfileRefreshInterval", "false", ShmOCPP16DataPH->ConfigurationTable.CoreProfile[CharingProfileRefreshInterval].ItemData);
 
+		// Ocpp Software certificated version
+		ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemAccessibility = 0;
+		strcpy((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemName, "OcppSoftwareVersion");
+		sprintf((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData, "%s", "V1.00");
+
+		fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","OcppSoftwareVersion", "true", ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData);
+
 		//* Local Auth List Management Profile*/
 		#if 0
 			//For OCTT Test Case
@@ -16751,6 +16333,12 @@ int initialConfigurationTable(void)
 					sprintf((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[CharingProfileRefreshInterval].ItemData, "%s", valuestr);
 				}
 
+				if(strcmp(keystr, "OcppSoftwareVersion") == 0)
+				{
+					ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
+					sprintf((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData, "%s", valuestr);
+				}
+
 				if(strcmp(keystr, "LocalAuthListEnabled") == 0)
 				{
 					ShmOCPP16DataPH->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
@@ -17321,6 +16909,14 @@ void StoreConfigurationTable(void)
 
 	fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","CharingProfileRefreshInterval", "false", (char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[CharingProfileRefreshInterval].ItemData);
 
+	// OcppSoftwareVersion
+	/*
+	ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemAccessibility = 1;
+	strcpy((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemName, "OcppSoftwareVersion");
+	strcpy((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData, "" );
+	*/
+
+	fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","OcppSoftwareVersion", "true", (char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData);
 
 	//* Local Auth List Management Profile*/
 	//LocalAuthListEnabled
@@ -18391,6 +17987,24 @@ void getKeyValue(char *keyReq)
 			  strcpy((char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[GetConfiguration_CharingProfileRefreshInterval].Value, (const char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[CharingProfileRefreshInterval].ItemData );
 			  isKnowKey = TRUE;
 		  }
+
+		  if(isEmpty ||  strcmp(keyReq, "OcppSoftwareVersion") == 0 )
+		  {
+			  strcpy((char *)ShmOCPP16DataPH->GetConfiguration.Key[GetConfiguration_OcppSoftwareVersion].Item, "OcppSoftwareVersion");
+			  strcpy((char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[GetConfiguration_OcppSoftwareVersion].Key, "OcppSoftwareVersion");
+
+			  if(ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemAccessibility == 1)
+			  {
+				  strcpy((char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[GetConfiguration_OcppSoftwareVersion].ReadOnly, "0"/*"FALSE"*/);
+			  }
+			  else
+			  {
+				  strcpy((char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[GetConfiguration_OcppSoftwareVersion].ReadOnly, "1"/*"TRUE"*/);
+			  }
+
+			  strcpy((char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[GetConfiguration_OcppSoftwareVersion].Value, (const char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData );
+			  isKnowKey = TRUE;
+		  }
 #if 1
 	      if(isEmpty ||  strcmp(keyReq, "LocalAuthListEnabled") == 0 )
 	      {

+ 1 - 0
EVSE/Modularization/ocppph/MessageHandler.h

@@ -414,6 +414,7 @@ enum GetConfigurationKey {
 	GetConfiguration_MaxChargingProfilesInstalled,
 	GetConfiguration_ConfigurationVersion,
 	GetConfiguration_CharingProfileRefreshInterval,
+	GetConfiguration_OcppSoftwareVersion,
 	_GetConfiguration_CNT
 };
 

+ 2 - 1
EVSE/Modularization/ocppph/Module_OcppBackend.c

@@ -1326,7 +1326,8 @@ int main(void)
 	queueOpInfo.IsUsing = FALSE;
 	queueOpInfo.TransactionMessageResend = 0;
 
-	DEBUG_INFO("Module_OcppBackend task initialization...\n");
+	DEBUG_INFO("Module_OcppBackendPH task initialization...\n");
+	DEBUG_INFO("Last update date: 2022/08/05 \n");
 	//lws_set_log_level(LLL_PARSER | LLL_HEADER | LLL_ERR | LLL_WARN | LLL_NOTICE | LLL_INFO | LLL_DEBUG | LLL_EXT | LLL_CLIENT | LLL_LATENCY  , NULL);
 
 	if(ProcessShareMemory()== FAIL)

+ 38 - 18
EVSE/Projects/AW-CCS/Apps/LCM/Module_LcmControl.c

@@ -2,9 +2,9 @@
  * Module_LcmControl.c
  *
  * Created on : 2020-10-20
- * Update on : 2022-05-27
+ * Update on : 2022-08-03
  * Author : Folus Wen, Eason Yang
- * Version : V0.29
+ * Version : V0.30
  *
  */
 
@@ -132,7 +132,7 @@ int Uart1Fd;
 //=======================================
 // Record version and date
 //=======================================
-char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.29", "2022-05-27", "REV.03.00"};
+char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.30", "2022-08-03", "REV.03.00"};
 
 //=======================================
 // Common routine
@@ -643,28 +643,48 @@ void page_complete(uint8_t gun_index, uint8_t system_mode)
 	}
 	else
 	{
-		if((strcmp((char *)&ShmSysConfigAndInfo->SysConfig.OcppReceiptrURL,"") == 0))
+		if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 		{
-			if(getCurrentPage() != SYSTEM_SCREEN_COMPLETE)
+			if(ShmOCPP16Data->StopTransaction[gun_index].TransactionId != ShmOCPP16Data->Cost.FinalCost[gun_index].txId)
 			{
-				setCurrentPage(SYSTEM_SCREEN_COMPLETE);
-				DEBUG_INFO("Setting page to complete.\n");
+				if(getCurrentPage() != SYSTEM_SCREEN_COMPLETE)
+				{
+					setCurrentPage(SYSTEM_SCREEN_COMPLETE);
+					DEBUG_INFO("Setting page to complete.\n");
+				}
+				else
+				{}
 			}
 			else
-			{}
+			{
+				if((strcmp((char *)&ShmSysConfigAndInfo->SysConfig.OcppReceiptrURL,"") != 0))
+				{
+					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 [CDFA 1.0].\n");
+					}
+					else
+					{
+						setQRCodeReceipt(gun_index);
+					}
+				}
+				else
+				{
+					if(getCurrentPage() != SYSTEM_SCREEN_COMPLETE)
+					{
+						setCurrentPage(SYSTEM_SCREEN_COMPLETE);
+						DEBUG_INFO("Setting page to complete.\n");
+					}
+					else
+					{}
+				}
+			}
 		}
 		else
 		{
-			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);
-			}
+			// DISPLAY BY OCPP 2.0.1
 		}
 	}
 

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

@@ -819,7 +819,7 @@ uint8_t ocpp_get_auth_result(uint8_t isValidParent, ...)
 					DEBUG_INFO("Authorize.ResponseIdTagInfo.ParentIdTag : %s \n", ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag);
 					DEBUG_INFO("StartTransaction[%d].ResponseIdTagInfo.ParentIdTag : %s \n", gun_index ,ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.ParentIdTag);
 					*/
-					
+
 					if((strcmp((char*)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted")==0) &&
 					   (strcmp((char*)ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag, (char*)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.ParentIdTag)==0))
 						result = PASS;
@@ -833,7 +833,7 @@ uint8_t ocpp_get_auth_result(uint8_t isValidParent, ...)
 					DEBUG_INFO("Authorize.Response_idTokenInfo.groupIdToken.idToken : %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken);
 					DEBUG_INFO("TransactionEvent[%d].Response_idTokenInfo.groupIdToken.idToken : %s \n", gun_index, ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.groupIdToken.idToken);
 					*/
-					
+
 					if((strcmp((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, "Accepted")==0) &&
 					   ((strcmp((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.groupIdToken.idToken) == 0) ||
 						(strcmp((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].value) == 0)))
@@ -2177,7 +2177,7 @@ void InitGPIO()
 
 	/*Wake up button GPIO1_31 => H:OFF; L:ON*/
 	system("echo 63 > /sys/class/gpio/export");
-	system("echo \"in\" > /sys/class/gpio/gpio64/direction");
+	system("echo \"in\" > /sys/class/gpio/gpio63/direction");
 
 	sleep(1);
 	DEBUG_INFO("Initial GPIO OK\n");
@@ -2372,7 +2372,7 @@ int LoadSysConfigAndInfo(struct SysConfigData *ptr)
 	free(buf);
 
 	system("rm -f /mnt/EvseConfig.bin");
-	
+
 	// SysConfig in flash is empty (0xffffffff)
 	if((strlen((char*)ShmSysConfigAndInfo->SysConfig.ModelName) > ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.ModelName)) ||
 	   (strlen((char*)ShmSysConfigAndInfo->SysConfig.SerialNumber) > ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.SerialNumber)) ||
@@ -2418,7 +2418,7 @@ int LoadSysConfigAndInfo(struct SysConfigData *ptr)
 		sleep(3);
 		system("/usr/bin/run_evse_restart.sh");
 	}
-	
+
 	DEBUG_INFO("Load SysConfigData OK\n");
 
 	ShmCharger->isCcsEnable = OFF;
@@ -2431,9 +2431,9 @@ int LoadSysConfigAndInfo(struct SysConfigData *ptr)
 	#ifdef ENABLE_CCS
 	ShmCharger->isCcsEnable = ON;
 	#endif
-	
+
 	DEBUG_INFO("Is CCS Enable: %s \n",((ShmCharger->isCcsEnable == ON)?"YES":"NO"));
-	
+
 	RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo);
 
 	return PASS;
@@ -3389,8 +3389,8 @@ int isMatchStartUser(unsigned char gun_index)
 		// Big endian
 		switch(rfid.snType)
 		{
-			case RFID_SN_TYPE_6BYTE:
-				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5]);
+			case RFID_SN_TYPE_8BYTE:
+				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6], rfid.currentCard[7]);
 				break;
 			case RFID_SN_TYPE_7BYTE:
 				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6]);
@@ -3409,8 +3409,8 @@ int isMatchStartUser(unsigned char gun_index)
 		// Little endian
 		switch(rfid.snType)
 		{
-			case RFID_SN_TYPE_6BYTE:
-				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
+			case RFID_SN_TYPE_8BYTE:
+				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[7], rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
 				break;
 			case RFID_SN_TYPE_7BYTE:
 				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
@@ -3447,8 +3447,8 @@ int isMatchPresentUser()
 		// Big endian
 		switch(rfid.snType)
 		{
-			case RFID_SN_TYPE_6BYTE:
-				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5]);
+			case RFID_SN_TYPE_8BYTE:
+				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6], rfid.currentCard[7]);
 				break;
 			case RFID_SN_TYPE_7BYTE:
 				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6]);
@@ -3467,8 +3467,8 @@ int isMatchPresentUser()
 		// Little endian
 		switch(rfid.snType)
 		{
-			case RFID_SN_TYPE_6BYTE:
-				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
+			case RFID_SN_TYPE_8BYTE:
+				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[7], rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
 				break;
 			case RFID_SN_TYPE_7BYTE:
 				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
@@ -3621,7 +3621,7 @@ void setLedMotion(unsigned char gun_index,unsigned char led_mode)
 // Request on/off set
 //===============================================
 void setRequest(unsigned char gun_index,unsigned char isOn)
-{							
+{
 	if(isOn == ON)
 	{
 		if(ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest == OFF)
@@ -3652,7 +3652,7 @@ int getRequest(unsigned char gun_index)
 // Relay on/off set
 //===============================================
 void setRelay(unsigned char gun_index,unsigned char isOn)
-{							
+{
 	if(isOn == ON)
 	{
 		if(ShmCharger->gun_info[gun_index].legacyRequest.isRelayOn == OFF)
@@ -4717,7 +4717,7 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
 void checkStopReason(uint8_t gun_index)
 {
 	sleep(2);
-	
+
 	if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 	{
 		memset(ShmOCPP16Data->StopTransaction[gun_index].IdTag, 0x00, ARRAY_SIZE(ShmOCPP16Data->StopTransaction[gun_index].IdTag));
@@ -4744,7 +4744,7 @@ void checkStopReason(uint8_t gun_index)
 		else if(ShmCharger->gun_info[gun_index].rfidReq || ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop)
 		{
 			sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Local");
-			
+
 			if(!isMatchStartUser(gun_index))
 			{
 				memcpy((char*)ShmOCPP16Data->StopTransaction[gun_index].IdTag, (char*)ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmOCPP16Data->StopTransaction[gun_index].IdTag));
@@ -4772,7 +4772,7 @@ void checkStopReason(uint8_t gun_index)
 		ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption/10000.0);
 		presentChargedEnergyUpdate(gun_index);
 		DEBUG_INFO("Gun-[%d] : PresentChargedEnergy [ %.4f ].\n",gun_index ,ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy);
-		
+
 		ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq = ON;
 	}
 	else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
@@ -4801,7 +4801,7 @@ void checkStopReason(uint8_t gun_index)
 		else if(ShmCharger->gun_info[gun_index].rfidReq || ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop)
 		{
 			sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "Local");
-			
+
 			if(!isMatchStartUser(gun_index))
 			{
 				memcpy((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, (char*)ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
@@ -4835,7 +4835,7 @@ void checkStopReason(uint8_t gun_index)
 		ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption/10000.0);
 		presentChargedEnergyUpdate(gun_index);
 		DEBUG_INFO("Gun-[%d] : PresentChargedEnergy [ %.4f ].\n",gun_index ,ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy);
-		
+
 		ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
 	}
 
@@ -4985,8 +4985,8 @@ void checkRfidAuthrize()
 					// Big endian
 					switch(rfid.snType)
 					{
-						case RFID_SN_TYPE_6BYTE:
-							sprintf((char*)bufferRFID, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5]);
+						case RFID_SN_TYPE_8BYTE:
+							sprintf((char*)bufferRFID, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6], rfid.currentCard[7]);
 							break;
 						case RFID_SN_TYPE_7BYTE:
 							sprintf((char*)bufferRFID, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6]);
@@ -5005,8 +5005,8 @@ void checkRfidAuthrize()
 					// Little endian
 					switch(rfid.snType)
 					{
-						case RFID_SN_TYPE_6BYTE:
-							sprintf((char*)bufferRFID, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
+						case RFID_SN_TYPE_8BYTE:
+							sprintf((char*)bufferRFID, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[7], rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
 							break;
 						case RFID_SN_TYPE_7BYTE:
 							sprintf((char*)bufferRFID, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
@@ -5055,7 +5055,7 @@ void checkRfidAuthrize()
 					ShmCharger->isGetAuthResult = FALSE;
 					isCheckdResult = FALSE;
 				}
-				
+
 				isReadable = FALSE;
 			}
 		}
@@ -5147,7 +5147,7 @@ void checkRfidAuthrize()
 									setSpeaker(ON, SPEAKER_SHORT);
 									ShmCharger->isAuthrizing = FALSE;
 								}
-								
+
 								isReadable = FALSE;
 							}
 						}
@@ -5173,7 +5173,7 @@ void checkRfidAuthrize()
 									break;
 								}
 							}
-							
+
 							isReadable = TRUE;
 						}
 					}
@@ -5649,7 +5649,7 @@ int main(void)
 					ShmCharger->gun_info[gun_index].isRemoteStartWait = ON;
 					DEBUG_INFO("Remote start without connector id... \n");
 				}
-				
+
 				refreshStartTimer(&startTime[gun_index][TMR_IDX_CLEAN_REMOTE_START_WAIT]);
 			}
 			else
@@ -5773,7 +5773,7 @@ int main(void)
 						else
 							setChargerMode(gun_index, SYS_MODE_IDLE);
 
-						// The system identifies 1 phase or 3 phases depending on the model name 
+						// The system identifies 1 phase or 3 phases depending on the model name
 						ShmSysConfigAndInfo->SysConfig.AcPhaseCount = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') ||
 																	   (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') ||
 																	   (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')
@@ -5802,7 +5802,7 @@ int main(void)
 						ShmCharger->gun_info[gun_index].targetCurrent = 0xFF;
 						ocpp_set_unlocker_req(gun_index, OFF);
 						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].ReservationId = -1;
-						
+
 						// Response StopTransactionConf
 						ocpp_set_stoptransaction_conf(gun_index, OFF);
 						memset(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId));
@@ -6119,7 +6119,7 @@ int main(void)
 									  (!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));
-										
+
 										ShmCharger->gun_info[gun_index].resultAuthorization = VALIDATED_RFID;
 										DEBUG_INFO("Authorize pass [EVCCID].\n");
 										setSpeaker(ON, SPEAKER_SHORT);
@@ -6185,7 +6185,7 @@ int main(void)
 							setRequest(gun_index, ON);
 						}
 					}
-					
+
 					// If control pilot detect Bx, skip watch dog time out.
 					if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B) ||
 						(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C))
@@ -6534,9 +6534,9 @@ int main(void)
 					{
 						DEBUG_INFO("The connector was connected to the EV before.\n");
 						//Cancel CCS task negotiating
-						ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;	
+						ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;
 						ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = NOTIFICATION_STOP;
-						ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;	
+						ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;
 					}
 
 					// Use RFID card to stop handshaking
@@ -6544,9 +6544,9 @@ int main(void)
 					{
 						DEBUG_INFO("Use RFID card to stop handshaking.\n");
 						//Cancel CCS task negotiating
-						ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;	
+						ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;
 						ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = NOTIFICATION_STOP;
-						ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;	
+						ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;
 					}
 					else
 					{
@@ -6561,20 +6561,20 @@ int main(void)
 						if(getDiffSecNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > (ShmCharger->timeoutSpec.Present_Timeout_Spec+5))
 						{
 							DEBUG_INFO("Handshaking timeout...\n");
-							
+
 							//Cancel CCS task negotiating
-							ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;	
+							ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;
 							ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = NOTIFICATION_STOP;
-							ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;	
+							ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;
 						}
-					}		
+					}
 
 					if((ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty == ON) && ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty != CCS_PWM_DUTY_5)
 					{
 						ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_100;
-						ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;	
+						ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;
 						ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = OFF;
-						
+
 						setChargerMode(gun_index, SYS_MODE_IDLE);
 					}
 					break;
@@ -6854,7 +6854,7 @@ int main(void)
 							DEBUG_INFO("==============================================================\n");
 							*/
 							refreshStartTimer(&startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]);
-							
+
 							getDateTimeString((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StopDateTime);
 							DB_Update_Record_Buf(localDb, gun_index);
 						}
@@ -7010,7 +7010,7 @@ int main(void)
 						setRequest(gun_index, OFF);
 						sleep(13);
 					}
-					
+
 					if(((ShmCharger->gun_info[gun_index].chargingMode != CHARGING_MODE_SOCKETE) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)) ||
 					   ((ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_SOCKETE) && (!ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn)) ||
 					   ocpp_get_reset_req())
@@ -7025,7 +7025,7 @@ int main(void)
 						DB_Insert_Record(localDb, gun_index);
 						setChargerMode(gun_index, SYS_MODE_IDLE);
 					}
-					
+
 					break;
 				case SYS_MODE_ALARM:
 					setLedMotion(gun_index,LED_ACTION_ALARM);
@@ -7161,7 +7161,7 @@ int main(void)
 								sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "InstallationFailed");
 								ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
 								DEBUG_WARN("Firmware upgrade fail.\n");
-								
+
 								sleep(5);
 								system("rm -rvf /mnt/* ");
 								close(wtdFd);

+ 5 - 2
EVSE/Projects/AW-Regular/Apps/Makefile

@@ -4,7 +4,10 @@ export PATH=/bin:/sbin:/usr/bin:$(SDK_PATH_TARGET)/usr/bin:$PATH
 #define library variable
 Lib_Module_RFID = "-L../../../Modularization" -lModule_RFID
 Lib_Module_Upgrade = "-L../../../Modularization" -lModule_Upgrade
+Lib_Module_RatedCurrent = "-L../../../Modularization" -lm -lModule_RatedCurrent
 Lib_SQLite3 = "-L../../../Modularization/ocppfiles" -lsqlite3
+Lib_JSONC = "-L../../../GPL/json-c-json-c-0.13.1-20180305/release/lib" -ljson-c
+
 
 all: CopyFile apps
 apps: Module_InternalComm_Task Module_FactoryConfig_Task Module_AlarmDetect_Task Module_CSU_Task Module_Speaker_Task Module_ConfigTools_Task Module_Debug_Task
@@ -73,8 +76,8 @@ Module_AlarmDetect_Task:
 Module_CSU_Task:
 	@echo "===== Module_CSU_Task ============================================"
 	rm -f main 
-	$(CC) -D $(Project) "-I../../" "-include../../../Modularization/ocppfiles/sqlite3.h" "-include../../../Modularization/Module_Upgrade.h" "-include../../../Modularization/Module_RFID.h" -O0  -Wall -c -fmessage-length=0 -o main.o "./main.c"
-	$(CC) -o main main.o ${Lib_Module_RFID} ${Lib_Module_Upgrade} ${Lib_SQLite3}
+	$(CC) -D $(Project) "-I../../" "-include../../../GPL/json-c-json-c-0.13.1-20180305/release/include/json-c/json.h" "-include../../../Modularization/ocppfiles/sqlite3.h" "-include../../../Modularization/Module_Upgrade.h" "-include../../../Modularization/Module_RFID.h" "-include../../../Modularization/Module_RatedCurrent.h" -O0  -Wall -c -fmessage-length=0 -o main.o "./main.c"
+	$(CC) -o main main.o ${Lib_Module_RFID} ${Lib_Module_Upgrade} ${Lib_SQLite3} ${Lib_Module_RatedCurrent} ${Lib_JSONC} 
 	rm -f *.o
 	mv -f main ../Images/root		
 	@echo \

+ 52 - 39
EVSE/Projects/AW-Regular/Apps/Module_FactoryConfig.c

@@ -15,12 +15,12 @@
 
 #include 	<unistd.h>
 #include 	<stdarg.h>
-#include    <stdio.h>      /*標準輸入輸出定義*/
-#include    <stdlib.h>     /*標準函數庫定義*/
-#include    <unistd.h>     /*Unix 標準函數定義*/
-#include    <fcntl.h>      /*檔控制定義*/
-#include    <termios.h>    /*PPSIX 終端控制定義*/
-#include    <errno.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>
@@ -264,23 +264,25 @@ int main(int argc, char *argv[])
 	{
 		memcpy((char*)SysConfig.ModelName, ShmSysConfigAndInfo->SysConfig.ModelName, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.ModelName));
 		memcpy((char*)SysConfig.SerialNumber, ShmSysConfigAndInfo->SysConfig.SerialNumber, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.SerialNumber));
+		memcpy((char*)SysConfig.CsuBootLoadFwRev, ShmSysConfigAndInfo->SysConfig.CsuBootLoadFwRev, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.CsuBootLoadFwRev));
 
 		DEBUG_INFO("InitShareMemory OK.\n");
 	}
 	
 	sprintf((char*)SysConfig.SystemId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
 	sprintf((char*)SysConfig.SystemDateTime, "%d-%d-%d %d:%d:%d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
-	SysConfig.AuthorisationMode = 0;	// 0: enable, 1: disable
-	SysConfig.DefaultLanguage  = 0;		// 0:English	1:Big5				2: GB			3: JN		4: Français 	5: Italiano		6: Español		7: Deutsch		8: Nederland	9: Norsk	10: Suomalainen		11: Svenska		12: Pусский		13: ไทย
-	SysConfig.RfidCardNumEndian = 0;	// 0: Little endian		1: Big endian
+	SysConfig.AuthorisationMode = 0;		// 0: enable, 1: disable
+	SysConfig.DefaultLanguage  = 0;			// 0: English 1: Big5 2: GB 3: JN 4: Français 5: Italiano 6: Español 7: Deutsch 8: Nederland 9: Norsk 10: Suomalainen 11: Svenska 12: Pусский 13: ไทย
+	SysConfig.RfidCardNumEndian = 0;		// 0: Little endian 1: Big endian
+	SysConfig.BillingData.isBilling = 0;	// 0: not for business	1: for business
 
 	// Charging configuration
-	SysConfig.MaxChargingEnergy = 0;	// 0: No limit	Other: 1~65536 KWH
-	SysConfig.MaxChargingPower = 0;		// 0: No limit	Other: 1~65536 KW
-	SysConfig.MaxChargingCurrent = 0;	// 0: Rating value	Other: 1~Rating A
-	SysConfig.MaxChargingDuration = 0;	// 0: No limit	Other: 1~65536 Minute
-	SysConfig.PhaseLossPolicy = 0;		// 0: Charging	1: Stop charging
-	SysConfig.AcPhaseCount = 1;			// 1: One phase	3: Three phase
+	SysConfig.MaxChargingEnergy = 0;		// 0: No limit	Other: 1~65536 KWH
+	SysConfig.MaxChargingPower = 0;			// 0: No limit	Other: 1~65536 KW
+	SysConfig.MaxChargingCurrent = 0;		// 0: Rating value	Other: 1~Rating A
+	SysConfig.MaxChargingDuration = 0;		// 0: No limit	Other: 1~65536 Minute
+	SysConfig.PhaseLossPolicy = 0;			// 0: Charging	1: Stop charging
+	SysConfig.AcPhaseCount = 1;				// 1: One phase	3: Three phase
 
 	// Network configuration
 	strcpy((char*)SysConfig.FtpServer, "");
@@ -294,26 +296,37 @@ int main(int argc, char *argv[])
 	strcpy((char*)SysConfig.Eth1Interface.EthSubmaskAddress, "255.255.255.0");
 	strcpy((char*)SysConfig.Eth1Interface.EthGatewayAddress, "192.168.0.254");
 
-	SysConfig.AthInterface.WifiMode = 2;		// 0: Disable	1: Infrastructure client	2: Infrastructure server	3: Ad-Hoc
-	SysConfig.AthInterface.WifiRssi = 0;		// Wifi rssi value
-	SysConfig.AthInterface.WifiDhcpServer = 0;	// 0: Enable	1: Disable
-	SysConfig.AthInterface.WifiDhcpClient = 0;	// 0: Enable	1: Disable
-
-	strcpy((char*)SysConfig.TelecomInterface.TelcomApn, "");
-	SysConfig.TelecomInterface.TelcomEnabled = 1; 	//0: disable, 1: enable
-	SysConfig.TelecomInterface.TelcomSimStatus = 0;	// SIM card status
-	SysConfig.TelecomInterface.TelcomModemMode = 0;	//0: No services	1: CDMA		2: GSM/GPRS	3: WCDMA	4: GSM/WCDMA	5: TD_SCDMA		6: Unknown
+	// Wifi configuration
+	SysConfig.AthInterface.WifiMode = 2;								// 0: Disable 1: Infrastructure client 2: Infrastructure server	3: Ad-Hoc
+	SysConfig.AthInterface.WifiRssi = 0;								// Wifi rssi value
+	strcpy((char *) SysConfig.AthInterface.WifiSsid, "");				// default: Null
+	strcpy((char *) SysConfig.AthInterface.WifiPassword, "");			// default: Null
+	SysConfig.AthInterface.WifiDhcpServer = 0;							// 0: Enable 1: Disable
+	SysConfig.AthInterface.WifiDhcpClient = 0;							// 0: Enable 1: Disable
+	SysConfig.AthInterface.WifiBroadcastSsid = 1;						// 0: hidden 1: broadcast
+
+	// Telecom configuration
+	strcpy((char*)SysConfig.TelecomInterface.TelcomApn, "");			// default: Null
+	SysConfig.TelecomInterface.TelcomEnabled = 1; 						// 0: disable, 1: enable
+	SysConfig.TelecomInterface.TelcomRssi = 0;							// default: 0
+	SysConfig.TelecomInterface.TelcomSimStatus = 0;						// SIM card status
+	SysConfig.TelecomInterface.TelcomModemMode = 0;						// 0: No services 1: CDMA 2: GSM/GPRS 3: WCDMA 4: GSM/WCDMA 5: TD_SCDMA 6: Unknown
+	strcpy((char *) SysConfig.TelecomInterface.TelcomChapPapId, "");	// default: Null
+	strcpy((char *) SysConfig.TelecomInterface.TelcomChapPapPwd, "");	// default: Null
+	strcpy((char *) SysConfig.TelecomInterface.TelcomModemImei, "");	// default: Null
+	strcpy((char *) SysConfig.TelecomInterface.TelcomSimImsi, "");		// default: Null
+	strcpy((char *) SysConfig.TelecomInterface.TelcomSimIccid, "");		// default: Null
 
 	// Backend configuration
 	strcpy((char*)SysConfig.OcppServerURL, "");
 	sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
-	strcpy((char *)SysConfig.chargePointVendor, "");	// default: Null
+	strcpy((char *)SysConfig.chargePointVendor, "");					// default: Null
 	strcpy((char*)SysConfig.MaintainServerURL, "");
-	SysConfig.BackendConnTimeout=300; 		// 300 seconds
-	SysConfig.OfflinePolicy = 2;			// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
-	SysConfig.OfflineMaxChargeEnergy = 0;	// 0: Same as MaxChargeEnergy	Other: 1~65535KWH
-	SysConfig.OfflineMaxChargeDuration = 0; // 0: Same as MaxChargeDuration Other: 1~65535 minutes
-	//SysConfig.isReqFirstUpgrade = 1;		// 0: Skip first upgrade, 	1: Process first upgrade
+	SysConfig.BackendConnTimeout=300; 									// 300 seconds
+	SysConfig.OfflinePolicy = 2;										// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
+	SysConfig.OfflineMaxChargeEnergy = 0;								// 0: Same as MaxChargeEnergy	Other: 1~65535KWH
+	SysConfig.OfflineMaxChargeDuration = 0; 							// 0: Same as MaxChargeDuration Other: 1~65535 minutes
+	//SysConfig.isReqFirstUpgrade = 1;									// 0: Skip first upgrade, 	1: Process first upgrade
 
 	// Customization configuration item
 	if(SysConfig.ModelName[12] == 'P')
@@ -321,16 +334,16 @@ int main(int argc, char *argv[])
 		// Phihong standard configuration
 		strcpy((char*)SysConfig.OcppServerURL, "");
 		sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
-		strcpy((char *)SysConfig.chargePointVendor, "");	// default: Null
+		strcpy((char *)SysConfig.chargePointVendor, "");				// default: Null
 		strcpy((char*)SysConfig.MaintainServerURL, "wss://ocpp.phihong.com.tw:2013/");
 	}
 	else if(SysConfig.ModelName[12] == 'A')
 	{
 		// ChargeLab customization configuration
-		SysConfig.AuthorisationMode = 0;	// 0: enable, 1: disable
-		SysConfig.RfidCardNumEndian = 1;	// 0: Little endian	1: Big endian
+		SysConfig.AuthorisationMode = 0;								// 0: enable, 1: disable
+		SysConfig.RfidCardNumEndian = 1;								// 0: Little endian	1: Big endian
 		
-		SysConfig.AthInterface.WifiMode = 1;		// 0: Disable 1: Infrastructure client 2: Infrastructure server	3: Ad-Hoc
+		SysConfig.AthInterface.WifiMode = 1;							// 0: Disable 1: Infrastructure client 2: Infrastructure server	3: Ad-Hoc
 		strcpy((char*)SysConfig.AthInterface.WifiSsid, "ChargeLab-EVC");
 		strcpy((char*)SysConfig.AthInterface.WifiPassword, "evc-pwd-default-21");
 		
@@ -339,15 +352,15 @@ int main(int argc, char *argv[])
 		strcpy((char*)SysConfig.OcppServerURL, "wss://ocpp.io");
 		sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
 		strcpy((char*)SysConfig.chargePointVendor, "ChargeLab");
-		SysConfig.OfflinePolicy = 0;			// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
+		SysConfig.OfflinePolicy = 0;									// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
 	}
 	else if(SysConfig.ModelName[12] == 'T')
 	{
 		// ChargeLab customization configuration
-		SysConfig.AuthorisationMode = 0;	// 0: enable, 1: disable
-		SysConfig.RfidCardNumEndian = 1;	// 0: Little endian	1: Big endian
+		SysConfig.AuthorisationMode = 0;								// 0: enable, 1: disable
+		SysConfig.RfidCardNumEndian = 1;								// 0: Little endian	1: Big endian
 		
-		SysConfig.AthInterface.WifiMode = 1;		// 0: Disable 1: Infrastructure client 2: Infrastructure server	3: Ad-Hoc
+		SysConfig.AthInterface.WifiMode = 1;							// 0: Disable 1: Infrastructure client 2: Infrastructure server	3: Ad-Hoc
 		strcpy((char*)SysConfig.AthInterface.WifiSsid, "ChargeLab-EVC");
 		strcpy((char*)SysConfig.AthInterface.WifiPassword, "evc-pwd-default-21");
 		
@@ -356,7 +369,7 @@ int main(int argc, char *argv[])
 		strcpy((char*)SysConfig.OcppServerURL, "wss://ocpp.io");
 		sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
 		strcpy((char*)SysConfig.chargePointVendor, "ChargeLab");
-		SysConfig.OfflinePolicy = 0;			// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
+		SysConfig.OfflinePolicy = 0;									// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
 	}
 	else
 	{

+ 145 - 23
EVSE/Projects/AW-Regular/Apps/main.c

@@ -91,6 +91,7 @@ struct timeb					endChargingTime[AC_QUANTITY];
 sqlite3 *localDb;
 
 struct SysConfigData			SysConfigOrg;
+ParsingRatedCur 				modelnameInfo={0};
 
 struct PreviousData
 {
@@ -432,6 +433,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
 //======================================================
@@ -1729,13 +1755,20 @@ void InitGPIO()
 	system("echo \"out\" > /sys/class/gpio/gpio65/direction");
 	system("echo 0 > /sys/class/gpio/gpio65/value");
 
-	/*POWER (4G/WIFI) RST:GPIO3_14 => H:ON; L:OFF*/
+	/*(FOR ACCSU-01-RW) 4G POWER RST:GPIO3_14 => H:ON; L:OFF*/
 	system("echo 110 > /sys/class/gpio/export");
 	system("echo \"out\" > /sys/class/gpio/gpio110/direction");
 	system("echo 1 > /sys/class/gpio/gpio110/value");
 	sleep(3);
 	system("echo 0 > /sys/class/gpio/gpio110/value");
 
+	/*(FOR ACCSU3P5-01-RW) 4G POWER RST:GPIO3_18 => H:ON; L:OFF*/
+	system("echo 114 > /sys/class/gpio/export");
+	system("echo \"out\" > /sys/class/gpio/gpio114/direction");
+	system("echo 1 > /sys/class/gpio/gpio114/value");
+	sleep(3);
+	system("echo 0 > /sys/class/gpio/gpio114/value");
+
 	DEBUG_INFO("Initial GPIO OK\n");
 }
 
@@ -1972,6 +2005,8 @@ int LoadSysConfigAndInfo(struct SysConfigData *ptr)
 	}
 
 	DEBUG_INFO("Load SysConfigData OK\n");
+	
+	RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo);
 
 	return PASS;
 }
@@ -2045,6 +2080,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 &",
@@ -2266,17 +2306,34 @@ void InitEthernet()
 
 			// Check is need to reset WIFI/4G module power
 			if((!ShmSysConfigAndInfo->SysInfo.OcppConnStatus) &&
-			   ((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))) &&
-			   ((system("pidof -s Module_4g > /dev/null") != 0) || (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == 0) || ((ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == 1) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApnDisconnectVia4Gi == ON))))
+			
+			   ((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))) &&
+				
+			    ((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(DiffTimebWithNow(startTime[0][TMR_IDX_RESET_4G_WIFI_POWER]) > TIMEOUT_SPEC_RESET_4G_WIFI_POWER)
 				{
 					if((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode != 0) || (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled != 0))
 					{
 						DEBUG_WARN("WIFI/4G module reset.\n");
+
+						// FOR ACCSU-01-RW RESET 4G
 						system("echo 1 > /sys/class/gpio/gpio110/value");
+
+						// FOR ACCSU3P5-01-RW RESET 4G
+						system("echo 1 > /sys/class/gpio/gpio114/value");
 						sleep(3);
+
+						// FOR ACCSU-01-RW RESET 4G
 						system("echo 0 > /sys/class/gpio/gpio110/value");
+
+						// FOR ACCSU3P5-01-RW RESET 4G
+						system("echo 0 > /sys/class/gpio/gpio114/value");
 					}
 
 					ftime(&startTime[0][TMR_IDX_RESET_4G_WIFI_POWER]);
@@ -2287,6 +2344,33 @@ void InitEthernet()
 				ftime(&startTime[0][TMR_IDX_RESET_4G_WIFI_POWER]);
 			}
 
+			// 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");
+			}
+
+			// Change uap0 to low priority
+			if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing &&
+			  (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2) &&
+			  (isUap0up() == PASS))
+			{
+				system("/sbin/ifmetric uap0 1");
+			}
+
 			sleep(5);
 		}
 	}
@@ -2762,8 +2846,8 @@ int isMatchStartUser(unsigned char gun_index)
 		// Big endian
 		switch(rfid.snType)
 		{
-			case RFID_SN_TYPE_6BYTE:
-				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5]);
+			case RFID_SN_TYPE_8BYTE:
+				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6], rfid.currentCard[7]);
 				break;
 			case RFID_SN_TYPE_7BYTE:
 				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6]);
@@ -2782,8 +2866,8 @@ int isMatchStartUser(unsigned char gun_index)
 		// Little endian
 		switch(rfid.snType)
 		{
-			case RFID_SN_TYPE_6BYTE:
-				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
+			case RFID_SN_TYPE_8BYTE:
+				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[7], rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
 				break;
 			case RFID_SN_TYPE_7BYTE:
 				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
@@ -3462,6 +3546,13 @@ void checkTask()
 		DEBUG_INFO("Module_ProduceUtils not running, restart it.\n");
 		system ("/root/Module_ProduceUtils &");
 	}
+
+	if((system("pidof -s Module_PowerSharing > /dev/null") != 0) &&
+		ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing)
+	{
+		DEBUG_INFO("Module_PowerSharing not running, restart it.\n");
+		system ("/root/Module_PowerSharing &");
+	}
 }
 
 void checkConnectionTimeout()
@@ -3801,6 +3892,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:
@@ -4236,6 +4341,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
 		//==============================================
@@ -4421,8 +4543,8 @@ int main(void)
 								// Big endian
 								switch(rfid.snType)
 								{
-									case RFID_SN_TYPE_6BYTE:
-										sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5]);
+									case RFID_SN_TYPE_8BYTE:
+										sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6], rfid.currentCard[7]);
 										break;
 									case RFID_SN_TYPE_7BYTE:
 										sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6]);
@@ -4441,8 +4563,8 @@ int main(void)
 								// Little endian
 								switch(rfid.snType)
 								{
-									case RFID_SN_TYPE_6BYTE:
-										sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
+									case RFID_SN_TYPE_8BYTE:
+										sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[7], rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
 										break;
 									case RFID_SN_TYPE_7BYTE:
 										sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
@@ -4743,8 +4865,8 @@ int main(void)
 										// Big endian
 										switch(rfid.snType)
 										{
-											case RFID_SN_TYPE_6BYTE:
-												sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5]);
+											case RFID_SN_TYPE_8BYTE:
+												sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6], rfid.currentCard[7]);
 												break;
 											case RFID_SN_TYPE_7BYTE:
 												sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6]);
@@ -4763,8 +4885,8 @@ int main(void)
 										// Little endian
 										switch(rfid.snType)
 										{
-											case RFID_SN_TYPE_6BYTE:
-												sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
+											case RFID_SN_TYPE_8BYTE:
+												sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[7], rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
 												break;
 											case RFID_SN_TYPE_7BYTE:
 												sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
@@ -5063,8 +5185,8 @@ int main(void)
 										// Big endian
 										switch(rfid.snType)
 										{
-											case RFID_SN_TYPE_6BYTE:
-												sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5]);
+											case RFID_SN_TYPE_8BYTE:
+												sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6], rfid.currentCard[7]);
 												break;
 											case RFID_SN_TYPE_7BYTE:
 												sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6]);
@@ -5083,8 +5205,8 @@ int main(void)
 										// Little endian
 										switch(rfid.snType)
 										{
-											case RFID_SN_TYPE_6BYTE:
-												sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
+											case RFID_SN_TYPE_8BYTE:
+												sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[7], rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
 												break;
 											case RFID_SN_TYPE_7BYTE:
 												sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
@@ -5395,8 +5517,8 @@ int main(void)
 									// Big endian
 									switch(rfid.snType)
 									{
-										case RFID_SN_TYPE_6BYTE:
-											sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5]);
+										case RFID_SN_TYPE_8BYTE:
+											sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6], rfid.currentCard[7]);
 											break;
 										case RFID_SN_TYPE_7BYTE:
 											sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6]);
@@ -5415,8 +5537,8 @@ int main(void)
 									// Little endian
 									switch(rfid.snType)
 									{
-										case RFID_SN_TYPE_6BYTE:
-											sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
+										case RFID_SN_TYPE_8BYTE:
+											sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[7], rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
 											break;
 										case RFID_SN_TYPE_7BYTE:
 											sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);

+ 12 - 12
EVSE/Projects/AX80/Apps/main.c

@@ -3440,8 +3440,8 @@ int isMatchStartUser(unsigned char gun_index)
 		// Big endian
 		switch(rfid.snType)
 		{
-			case RFID_SN_TYPE_6BYTE:
-				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5]);
+			case RFID_SN_TYPE_8BYTE:
+				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6], rfid.currentCard[7]);
 				break;
 			case RFID_SN_TYPE_7BYTE:
 				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6]);
@@ -3460,8 +3460,8 @@ int isMatchStartUser(unsigned char gun_index)
 		// Little endian
 		switch(rfid.snType)
 		{
-			case RFID_SN_TYPE_6BYTE:
-				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
+			case RFID_SN_TYPE_8BYTE:
+				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[7], rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
 				break;
 			case RFID_SN_TYPE_7BYTE:
 				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
@@ -3493,8 +3493,8 @@ int isMatchPresentUser()
 		// Big endian
 		switch(rfid.snType)
 		{
-			case RFID_SN_TYPE_6BYTE:
-				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5]);
+			case RFID_SN_TYPE_8BYTE:
+				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6], rfid.currentCard[7]);
 				break;
 			case RFID_SN_TYPE_7BYTE:
 				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6]);
@@ -3513,8 +3513,8 @@ int isMatchPresentUser()
 		// Little endian
 		switch(rfid.snType)
 		{
-			case RFID_SN_TYPE_6BYTE:
-				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
+			case RFID_SN_TYPE_8BYTE:
+				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[7], rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
 				break;
 			case RFID_SN_TYPE_7BYTE:
 				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
@@ -4931,8 +4931,8 @@ void checkRfidAuthrize()
 					// Big endian
 					switch(rfid.snType)
 					{
-						case RFID_SN_TYPE_6BYTE:
-							sprintf((char*)bufferRFID, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5]);
+						case RFID_SN_TYPE_8BYTE:
+							sprintf((char*)bufferRFID, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6], rfid.currentCard[7]);
 							break;
 						case RFID_SN_TYPE_7BYTE:
 							sprintf((char*)bufferRFID, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6]);
@@ -4951,8 +4951,8 @@ void checkRfidAuthrize()
 					// Little endian
 					switch(rfid.snType)
 					{
-						case RFID_SN_TYPE_6BYTE:
-							sprintf((char*)bufferRFID, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
+						case RFID_SN_TYPE_8BYTE:
+							sprintf((char*)bufferRFID, "%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[7], rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
 							break;
 						case RFID_SN_TYPE_7BYTE:
 							sprintf((char*)bufferRFID, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);

+ 15 - 3
EVSE/Projects/define.h

@@ -345,6 +345,7 @@ enum CoreProfile {
      OffLineMaxChargingPower,
      ConfigurationVersion,
 	 CharingProfileRefreshInterval,
+	 OcppSoftwareVersion,
 	 _CoreProfile_CNT
 };
 
@@ -1659,7 +1660,7 @@ char InfoStatusCode[384][6]=
 	"023716",	//CHAdeMO:  connector temperature sensor broken
 	"023717",	//CHAdeMO:  connector lock fail
 	"023718",	//CHAdeMO:	D1 ON No Receive
-	"023719",	//CHAdeMO:	BMS K to J Timeout
+	"023719",	//CHAdeMO:	Permission ON but charge sequence timeout
 	"023720",	//CHAdeMO:	BMS Charge Allow Timeout
 	"023721",	//CHAdeMO:	Wait GroundFault Timeout
 	"023722",	//CHAdeMO:	BMS EV Relay Timeout
@@ -2416,6 +2417,7 @@ struct DynamicReleaseCtrl
     unsigned char       ReleaseLoopStep;    // 0 : None, 1 : Limit Pwr, 2 : Pwr OFF, 3. RCB OFF, 4. Finish
     float               CheckOutPwrIsStable;// 0.1kw
     unsigned char       TargetRelay;        // 255 : None
+    unsigned char		AutoRelease;
 
     float               LimitCurCap;        // Inform 0.1A
     float               LimitPwrCap;        // Inform 0.1kw
@@ -4780,6 +4782,15 @@ struct StructTcciCustomData
     unsigned char ChargerInfoConf:1;
     unsigned char WeatherInfoReq:1;
     unsigned char WeatherInfoConf:1;
+    unsigned char :3;                  // bit 5-7 , reserved
+};
+
+struct OCMFData
+{
+	unsigned char SendOcmfDataReq:1;   // bit 0 , Flag to ask OCPP sending OCMF message to backend.
+	unsigned char :7;                  // bit 1-7 , reserved
+	unsigned char DataString[2048];    // Data got from meter.
+	unsigned char PublicKey[256];      // PublicKey with header got from meter.
 };
 
 struct OCPP16Data
@@ -4789,7 +4800,7 @@ struct OCPP16Data
     unsigned char                           OcppConnStatus;         //0: disconnected, 1: connected
     unsigned int                            Timeout_Secs;
     unsigned short                          Ping_Pong_Interval;
-    unsigned int                            procDogTime;            // Process watch dog refresh timer
+    long  int	                            procDogTime;            // Process watch dog refresh timer
     union
     {
         //Operations Initiated by Charge Point
@@ -4972,6 +4983,7 @@ struct OCPP16Data
     struct StructSignedFirmwareStatusNotification   SignedFirmwareStatusNotification;
     struct StructSessionTarget                      SessionTarget[CONNECTOR_QUANTITY];
     struct StructTcciCustomData                     TcciCustomData;
+    struct OCMFData                                 OcmfData[CONNECTOR_QUANTITY];
 };
 
 
@@ -6100,7 +6112,7 @@ struct OCPP20Data
 	unsigned char 							OcppConnStatus;			//0: disconnected, 1: connected
 	unsigned int 							Timeout_Secs;
 	unsigned short 							Ping_Pong_Interval;
-	unsigned int                            procDogTime;            // Process watch dog refresh timer
+	long int 							procDogTime;            // Process watch dog refresh timer
 	struct ReportDataType                   ControllerComponentVariable[CtrlrVariable_CNT];
 	struct NetworkConnectionProfile_20      NetworkConnectionProfile[10];
 

+ 1 - 1
EVSE/rootfs/root/ppp/4GDetection

@@ -5,7 +5,7 @@ do
 InterFace=`ifconfig | grep -o "ppp0"`
 if [ "$InterFace" == "ppp0" ]; then
 	if [ ! -f "/etc/resolv.conf.org" ]; then
-		route del default &>/dev/null
+#		route del default &>/dev/null
 		route add default dev $InterFace &>/dev/null
 		route add dev $InterFace &>/dev/null
 		if [ -f "/etc/ppp/resolv.conf" ]; then

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

@@ -257,12 +257,11 @@ CORE STYLES ABOVE - NO TOUCHY
 											<label><?php echo $lang->showWord("ocpp_security_password"); ?></label>
 											<input type="text" name="OcppSecurityPassword" id="OcppSecurityPassword" class="form-control" value="<?php echo $obj->{'OcppSecurityPassword'};?>">
 										</div>
-<?php if(substr($ModelName,0,2)=="AX" || substr($ModelName,0,1)=="D"){?>
+<?php if(substr($ModelName,0,2)=="AX" || substr($ModelName,0,2)=="AW" || substr($ModelName,0,1)=="D"){?>
 										<div class="form-group" style="display:block">
 											<label><?php echo $lang->showWord("ocpp_receipt_url"); ?></label>
 											<input type="text" name="OcppReceiptrURL" id="OcppReceiptrURL" class="form-control" value="<?php echo $obj->{'OcppReceiptrURL'};?>">
 										</div>
-<?php } if(substr($ModelName,0,2)=="AX"){?>
 										<div class="form-group" style="display:block">
 											<label><?php echo $lang->showWord("local_loading_balance"); ?></label>
 											<select class="form-control" id="isEnableLocalPowerSharging" name="isEnableLocalPowerSharging" onChange="isEnableLocalPowerSharging_changed()">
@@ -367,7 +366,7 @@ CORE STYLES ABOVE - NO TOUCHY
 ?>
 
 <script type="text/JavaScript">
-<?php if(substr($ModelName,0,2)=="AX"){?>
+<?php if(substr($ModelName,0,2)=="AX" || substr($ModelName,0,2)=="AW" || substr($ModelName,0,1)=="D"){?>
 	$(document).ready(function(){
 		isEnableLocalPowerSharging_changed();
 	});
@@ -402,11 +401,10 @@ CORE STYLES ABOVE - NO TOUCHY
 						"&OcppSecurityPassword=" + escape(document.getElementById("OcppSecurityPassword").value)+
 						"&MaintainServerSecurityProfile=" + document.getElementById("MaintainServerSecurityProfile").value+
 						"&MaintainServerSecurityPassword=" + escape(document.getElementById("MaintainServerSecurityPassword").value);
-<?php if(substr($ModelName,0,2)=="AX"){?>
+<?php if(substr($ModelName,0,2)=="AX" || substr($ModelName,0,2)=="AW" || substr($ModelName,0,1)=="D"){?>
 				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 } ?>
 <?php if(substr($ModelName,0,1)=="D" && substr($ModelName,3,1)=="C"){?>
@@ -544,7 +542,7 @@ CORE STYLES ABOVE - NO TOUCHY
 		}
 	}
 
-<?php if(substr($ModelName,0,2)=="AX"){?>
+<?php if(substr($ModelName,0,2)=="AX" || substr($ModelName,0,2)=="AW" || substr($ModelName,0,1)=="D"){?>
 	function isEnableLocalPowerSharging_changed(){
 		/*
 		if(document.getElementById("isEnableLocalPowerSharging").selectedIndex!=0){

+ 1 - 1
Makefile

@@ -547,7 +547,7 @@ AW-Regular-uboot:
 	@echo    Building U-boot
 	@echo ===================================
 	@cp -f $(UBOOT_INSTALL_DIR)/arch/arm/dts/[AW-Regular]am335x-evm.dts $(UBOOT_INSTALL_DIR)/arch/arm/dts/am335x-evm.dts
-	$(MAKE) -j $(MAKE_JOBS) -C $(UBOOT_INSTALL_DIR) CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F8G08_BCH16 DDR_IC=MT41K256M16HA125E_303 PMIC=TPS65910
+	$(MAKE) -j $(MAKE_JOBS) -C $(UBOOT_INSTALL_DIR) CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F8G08_BCH16 DDR_IC=MT41K256M16HA125E_303 PMIC=TPS65217
 	@cp -f $(UBOOT_INSTALL_DIR)/MLO EVSE/Projects/AW-Regular/Images/
 	@cp -f $(UBOOT_INSTALL_DIR)/u-boot.img EVSE/Projects/AW-Regular/Images/
 	@cp -f $(UBOOT_INSTALL_DIR)/spl/u-boot-spl.bin EVSE/Projects/AW-Regular/Images/

+ 44 - 53
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/[AW-Regular]am335x-evm.dts

@@ -25,7 +25,7 @@
 
 	cpus {
 		cpu@0 {
-			cpu0-supply = <&vdd1_reg>;
+			cpu0-supply = <&dcdc2_reg>;
 		};
 	};
 
@@ -65,7 +65,7 @@
 		
 			/** Offset: 0x800 */
 			/** GPIO 0 */ 
-			0x144 (PIN_INPUT | MUX_MODE7)    			/* RMII1_REF_CLK		=>	GPIO0_29 */	/*USB 0 OCP detection*/
+			0x144 (PIN_INPUT | MUX_MODE7)    		/* RMII1_REF_CLK	=>	GPIO0_29 */	/*USB 0 OCP detection*/
 			0x1B0 (PIN_OUTPUT | MUX_MODE7)			/*XDMA_EVENT_INTR0	=>	GPIO0_19 */	/*AM_RFID_RST*/
 			0x1B4 (PIN_INPUT | MUX_MODE7)			/*XDMA_EVENT_INTR1	=>	GPIO0_20 */	/*AM_RFID_ICC*/
 			/** GPIO 1 */			
@@ -80,6 +80,7 @@
 			0x0E8 (PIN_INPUT | MUX_MODE7)			/*LCD_PCLK	=>	GPIO2_24*/	/*communication board proximity*/
 			0x0E0 (PIN_OUTPUT | MUX_MODE7)			/*LCD_VSYNC	=>	GPIO2_22*/	/*Breath LED*/
 			/** GPIO 3 */
+			0x1A0 (PIN_OUTPUT | MUX_MODE7)          /* MCASP0_AXR1  =>  GPIO3_18 */ /*control 4G reset pin*/
 			0x1A8 (PIN_OUTPUT | MUX_MODE7)			/* MCASP0_AXR1	=>	GPIO3_20 */	/*control MCU to output CP PWM*/
 		>;
 	};
@@ -323,8 +324,8 @@
 	status = "okay";
 	clock-frequency = <400000>;
 
-	tps: tps@2d {
-		reg = <0x2d>;
+	tps: tps@24 {
+		reg = <0x24>;
 	};
 
 /*	rtc0: rtc@51 {
@@ -406,7 +407,7 @@
 	pinctrl-0 = <&nandflash_pins_default>;
 	pinctrl-1 = <&nandflash_pins_sleep>;
 	/*ranges = <0 0 0x08000000 0x10000000>;*/	/* CS0: NAND */
-	ranges = <0 0 0x08000000 0x80000000>;	/*+++ vern,NAND,20181030 ---*/
+	ranges = <0 0 0x08000000 0x40000000>;	/*+++ vern,NAND,20181030 ---*/
 	nand@0,0 {
 		compatible = "ti,omap2-nand";
 		reg = <0 0 4>; /* CS0, offset 0, IO size 4 */
@@ -500,85 +501,74 @@
 		};
 		partition@13 {
 			label = "Storage";
-			reg = <0x0A200000 0x75E00000>;
+			reg = <0x0A200000 0x35E00000>;
 		};
 	};
 };
 
-#include "tps65910.dtsi"
+/include/ "tps65217.dtsi"
 
 &tps {
-	vcc1-supply = <&vbat>;
-	vcc2-supply = <&vbat>;
-	vcc3-supply = <&vbat>;
-	vcc4-supply = <&vbat>;
-	vcc5-supply = <&vbat>;
-	vcc6-supply = <&vbat>;
-	vcc7-supply = <&vbat>;
-	vccio-supply = <&vbat>;
+	/*
+	 * Configure pmic to enter OFF-state instead of SLEEP-state ("RTC-only
+	 * mode") at poweroff.  Most BeagleBone versions do not support RTC-only
+	 * mode and risk hardware damage if this mode is entered.
+	 *
+	 * For details, see linux-omap mailing list May 2015 thread
+	 *	[PATCH] ARM: dts: am335x-bone* enable pmic-shutdown-controller
+	 * In particular, messages:
+	 *	http://www.spinics.net/lists/linux-omap/msg118585.html
+	 *	http://www.spinics.net/lists/linux-omap/msg118615.html
+	 *
+	 * You can override this later with
+	 *	&tps {  /delete-property/ ti,pmic-shutdown-controller;  }
+	 * if you want to use RTC-only mode and made sure you are not affected
+	 * by the hardware problems. (Tip: double-check by performing a current
+	 * measurement after shutdown: it should be less than 1 mA.)
+	 */
+	ti,pmic-shutdown-controller;
 
 	regulators {
-		vrtc_reg: regulator@0 {
+		dcdc1_reg: regulator@0 {
+			regulator-name = "vdds_dpr";
 			regulator-always-on;
 		};
 
-		vio_reg: regulator@1 {
-			regulator-always-on;
-		};
-
-		vdd1_reg: regulator@2 {
-			/* VDD_MPU voltage limits 0.95V - 1.325V with +/-4% tolerance */
+		dcdc2_reg: regulator@1 {
+			/* VDD_MPU voltage limits 0.95V - 1.26V with +/-4% tolerance */
 			regulator-name = "vdd_mpu";
-			regulator-min-microvolt = <912500>;
-			regulator-max-microvolt = <1378000>;
+			regulator-min-microvolt = <1100000>;
+			regulator-max-microvolt = <1351500>;
 			regulator-boot-on;
 			regulator-always-on;
 		};
 
-		vdd2_reg: regulator@3 {
+		dcdc3_reg: regulator@2 {
 			/* VDD_CORE voltage limits 0.95V - 1.1V with +/-4% tolerance */
 			regulator-name = "vdd_core";
-			regulator-min-microvolt = <912500>;
+			regulator-min-microvolt = <925000>;
 			regulator-max-microvolt = <1150000>;
 			regulator-boot-on;
 			regulator-always-on;
 		};
 
-		vdd3_reg: regulator@4 {
-			regulator-always-on;
-		};
-
-		vdig1_reg: regulator@5 {
+		ldo1_reg: regulator@3 {
+			regulator-name = "vio,vrtc,vdds";
 			regulator-always-on;
 		};
 
-		vdig2_reg: regulator@6 {
+		ldo2_reg: regulator@4 {
+			regulator-name = "vdd_3v3aux";
 			regulator-always-on;
 		};
 
-		vpll_reg: regulator@7 {
+		ldo3_reg: regulator@5 {
+			regulator-name = "vdd_1v8";
 			regulator-always-on;
 		};
 
-		vdac_reg: regulator@8 {
-			regulator-always-on;
-		};
-
-		vaux1_reg: regulator@9 {
-			regulator-always-on;
-		};
-
-		vaux2_reg: regulator@10 {
-			regulator-always-on;
-		};
-
-		vaux33_reg: regulator@11 {
-			regulator-always-on;
-		};
-
-		vmmc_reg: regulator@12 {
-			regulator-min-microvolt = <1800000>;
-			regulator-max-microvolt = <3300000>;
+		ldo4_reg: regulator@6 {
+			regulator-name = "vdd_3v3a";
 			regulator-always-on;
 		};
 	};
@@ -604,6 +594,7 @@
  	phy-mode = "mii";
 
 };
+
 #if 0
 &cpsw_emac1 {
 	phy_id = <&davinci_mdio>, <2>;
@@ -628,7 +619,7 @@
 
 &mmc1 {
 	status = "okay";
-	vmmc-supply = <&vmmc_reg>;
+	vmmc-supply = <&ldo4_reg>;
 	bus-width = <4>;
 	pinctrl-names = "default";
 	pinctrl-0 = <&mmc1_pins_default>;

+ 0 - 2
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/include/Kbuild

@@ -1,2 +0,0 @@
-# Top-level Makefile calls into asm-$(ARCH)
-# List only non-arch directories below

+ 0 - 175
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/include/memory/jedec_ddr.h

@@ -1,175 +0,0 @@
-/*
- * Definitions for DDR memories based on JEDEC specs
- *
- * Copyright (C) 2012 Texas Instruments, Inc.
- *
- * Aneesh V <aneesh@ti.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#ifndef __LINUX_JEDEC_DDR_H
-#define __LINUX_JEDEC_DDR_H
-
-#include <linux/types.h>
-
-/* DDR Densities */
-#define DDR_DENSITY_64Mb	1
-#define DDR_DENSITY_128Mb	2
-#define DDR_DENSITY_256Mb	3
-#define DDR_DENSITY_512Mb	4
-#define DDR_DENSITY_1Gb		5
-#define DDR_DENSITY_2Gb		6
-#define DDR_DENSITY_4Gb		7
-#define DDR_DENSITY_8Gb		8
-#define DDR_DENSITY_16Gb	9
-#define DDR_DENSITY_32Gb	10
-
-/* DDR type */
-#define DDR_TYPE_DDR2		1
-#define DDR_TYPE_DDR3		2
-#define DDR_TYPE_LPDDR2_S4	3
-#define DDR_TYPE_LPDDR2_S2	4
-#define DDR_TYPE_LPDDR2_NVM	5
-
-/* DDR IO width */
-#define DDR_IO_WIDTH_4		1
-#define DDR_IO_WIDTH_8		2
-#define DDR_IO_WIDTH_16		3
-#define DDR_IO_WIDTH_32		4
-
-/* Number of Row bits */
-#define R9			9
-#define R10			10
-#define R11			11
-#define R12			12
-#define R13			13
-#define R14			14
-#define R15			15
-#define R16			16
-
-/* Number of Column bits */
-#define C7			7
-#define C8			8
-#define C9			9
-#define C10			10
-#define C11			11
-#define C12			12
-
-/* Number of Banks */
-#define B1			0
-#define B2			1
-#define B4			2
-#define B8			3
-
-/* Refresh rate in nano-seconds */
-#define T_REFI_15_6		15600
-#define T_REFI_7_8		7800
-#define T_REFI_3_9		3900
-
-/* tRFC values */
-#define T_RFC_90		90000
-#define T_RFC_110		110000
-#define T_RFC_130		130000
-#define T_RFC_160		160000
-#define T_RFC_210		210000
-#define T_RFC_300		300000
-#define T_RFC_350		350000
-
-/* Mode register numbers */
-#define DDR_MR0			0
-#define DDR_MR1			1
-#define DDR_MR2			2
-#define DDR_MR3			3
-#define DDR_MR4			4
-#define DDR_MR5			5
-#define DDR_MR6			6
-#define DDR_MR7			7
-#define DDR_MR8			8
-#define DDR_MR9			9
-#define DDR_MR10		10
-#define DDR_MR11		11
-#define DDR_MR16		16
-#define DDR_MR17		17
-#define DDR_MR18		18
-
-/*
- * LPDDR2 related defines
- */
-
-/* MR4 register fields */
-#define MR4_SDRAM_REF_RATE_SHIFT			0
-#define MR4_SDRAM_REF_RATE_MASK				7
-#define MR4_TUF_SHIFT					7
-#define MR4_TUF_MASK					(1 << 7)
-
-/* MR4 SDRAM Refresh Rate field values */
-#define SDRAM_TEMP_NOMINAL				0x3
-#define SDRAM_TEMP_RESERVED_4				0x4
-#define SDRAM_TEMP_HIGH_DERATE_REFRESH			0x5
-#define SDRAM_TEMP_HIGH_DERATE_REFRESH_AND_TIMINGS	0x6
-#define SDRAM_TEMP_VERY_HIGH_SHUTDOWN			0x7
-
-#define NUM_DDR_ADDR_TABLE_ENTRIES			11
-#define NUM_DDR_TIMING_TABLE_ENTRIES			4
-
-/* Structure for DDR addressing info from the JEDEC spec */
-struct lpddr2_addressing {
-	u32 num_banks;
-	u32 tREFI_ns;
-	u32 tRFCab_ps;
-};
-
-/*
- * Structure for timings from the LPDDR2 datasheet
- * All parameters are in pico seconds(ps) unless explicitly indicated
- * with a suffix like tRAS_max_ns below
- */
-struct lpddr2_timings {
-	u32 max_freq;
-	u32 min_freq;
-	u32 tRPab;
-	u32 tRCD;
-	u32 tWR;
-	u32 tRAS_min;
-	u32 tRRD;
-	u32 tWTR;
-	u32 tXP;
-	u32 tRTP;
-	u32 tCKESR;
-	u32 tDQSCK_max;
-	u32 tDQSCK_max_derated;
-	u32 tFAW;
-	u32 tZQCS;
-	u32 tZQCL;
-	u32 tZQinit;
-	u32 tRAS_max_ns;
-};
-
-/*
- * Min value for some parameters in terms of number of tCK cycles(nCK)
- * Please set to zero parameters that are not valid for a given memory
- * type
- */
-struct lpddr2_min_tck {
-	u32 tRPab;
-	u32 tRCD;
-	u32 tWR;
-	u32 tRASmin;
-	u32 tRRD;
-	u32 tWTR;
-	u32 tXP;
-	u32 tRTP;
-	u32 tCKE;
-	u32 tCKESR;
-	u32 tFAW;
-};
-
-extern const struct lpddr2_addressing
-	lpddr2_jedec_addressing_table[NUM_DDR_ADDR_TABLE_ENTRIES];
-extern const struct lpddr2_timings
-	lpddr2_jedec_timings[NUM_DDR_TIMING_TABLE_ENTRIES];
-extern const struct lpddr2_min_tck lpddr2_jedec_min_tck;
-
-#endif /* __LINUX_JEDEC_DDR_H */

+ 1 - 0
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/.MLO.byteswap.cmd

@@ -0,0 +1 @@
+cmd_MLO.byteswap := ./tools/mkimage -T omapimage -n byteswap -a 0x402F0400 -d spl/u-boot-spl.bin MLO.byteswap  >/dev/null

+ 1 - 0
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/.MLO.cmd

@@ -0,0 +1 @@
+cmd_MLO := ./tools/mkimage -T omapimage -a 0x402F0400 -d spl/u-boot-spl.bin MLO  >/dev/null