Browse Source

Merge branch 'AW-CCS' of https://git.phihong.com.tw:30000/System_Integration/CSU3_AM335x into AW-CCS

8009 3 years ago
parent
commit
b86b48022c
19 changed files with 241 additions and 62 deletions
  1. 52 27
      EVSE/Modularization/Module_4g.c
  2. 2 2
      EVSE/Modularization/Module_Wifi.c
  3. 157 19
      EVSE/Projects/AW-CCS/Apps/main.c
  4. 1 1
      EVSE/Projects/AW-CCS/Apps/main.h
  5. 9 0
      EVSE/rootfs/etc/init.d/rcS
  6. 7 0
      Makefile
  7. 1 1
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[ATE]am335x-evm.dts
  8. 1 1
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[CCS]am335x-evm.dts
  9. 1 1
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[DD360Audi]am335x-evm.dts
  10. 1 1
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[DD360]am335x-evm.dts
  11. 1 1
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[DM30]am335x-evm.dts
  12. 1 1
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[DO360]am335x-evm.dts
  13. 1 1
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[DS60-120-Infy]am335x-evm.dts
  14. 1 1
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[DS60-120]am335x-evm.dts
  15. 1 1
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[DW30]am335x-evm.dts
  16. 1 1
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[PlugIt360]am335x-evm.dts
  17. 1 1
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[Taurus]am335x-evm.dts
  18. 1 1
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[Zanobe]am335x-evm.dts
  19. 1 1
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[e4you]am335x-evm.dts

+ 52 - 27
EVSE/Modularization/Module_4g.c

@@ -82,7 +82,7 @@ void substr(char *dest, const char* src, unsigned int start, unsigned int cnt);
 
 char *portName[3] 				= {"/dev/ttyUSB2", "/dev/ttyUSB2", "/dev/ttyACM2"};
 char *valid_Internet[2] 		= {"8.8.8.8", "180.76.76.76"};
-char *Version_And_Date[2]		= {"V0.10","2021-03-16"};
+char *Version_And_Date[2]		= {"V0.11","2021-07-06"};
 pid_t	pid;
 
 struct dongle_info
@@ -95,6 +95,10 @@ struct dongle_info
 	char MODELNAME[10];
 	char REVISION[18];
 	unsigned char MODE;
+	char act[16];
+	char operator[16];
+	char band[16];
+	int channel;
 	int CSQ;
 	int cnt_InternetFail;
 	int cnt_ReadInfoFail;
@@ -414,26 +418,30 @@ int isReadInfo(void)
 				if(Length > 0)
 				{
 					memset(tmp, 0, sizeof tmp);
-
-					strncpy(tmp, &rx[strcspn(rx,":")+2], strcspn(rx,",")-(strcspn(rx,":")+2));
-
-
-					if(strstr(tmp, "CDMA") != NULL)
-						Dongle.MODE = NET_MODE_CDMA;
-					else if((strstr(tmp, "GPRS") != NULL) || (strstr(tmp, "EDGE") != NULL))
-						Dongle.MODE = NET_MODE_GMS_GPRS;
-					else if(strstr(tmp, "WCDMA") != NULL)
-						Dongle.MODE = NET_MODE_WCDMA;
-					else if(strstr(tmp, "GSM") != NULL)
-						Dongle.MODE = NET_MODE_GSM_WCDMA;
-					else if(strstr(tmp, "TDSCDMA") != NULL)
-						Dongle.MODE = NET_MODE_TD_SCDMA;
-					else if(strstr(tmp, "LTE") != NULL)
-						Dongle.MODE = NET_MODE_LTE;
-					else if((strstr(tmp, "HSDPA") != NULL) || (strstr(tmp, "HSUPA") != NULL) || (strstr(tmp, "HSPA+") != NULL))
-						Dongle.MODE = NET_MODE_HSPA;
+					if(sscanf(rx, "%*[^:]:%[^,],%[^,],%[^,],%d", Dongle.act, Dongle.operator, Dongle.band, &Dongle.channel) == 4)
+					{
+						//strncpy(tmp, &rx[strcspn(rx,":")+2], strcspn(rx,",")-(strcspn(rx,":")+2));
+						if((strstr(Dongle.act, "GPRS") != NULL) || (strstr(Dongle.act, "EDGE") != NULL))
+							Dongle.MODE = NET_MODE_GMS_GPRS;
+						else if(strstr(Dongle.act, "WCDMA") != NULL)
+							Dongle.MODE = NET_MODE_WCDMA;
+						else if(strstr(Dongle.act, "GSM") != NULL)
+							Dongle.MODE = NET_MODE_GSM_WCDMA;
+						else if(strstr(Dongle.act, "TDSCDMA") != NULL)
+							Dongle.MODE = NET_MODE_TD_SCDMA;
+						else if(strstr(Dongle.act, "CDMA") != NULL)
+							Dongle.MODE = NET_MODE_CDMA;
+						else if(strstr(Dongle.act, "LTE") != NULL)
+							Dongle.MODE = NET_MODE_LTE;
+						else if((strstr(Dongle.act, "HSDPA") != NULL) || (strstr(Dongle.act, "HSUPA") != NULL) || (strstr(Dongle.act, "HSPA+") != NULL))
+							Dongle.MODE = NET_MODE_HSPA;
+						else
+							Dongle.MODE = NET_MODE_UNKNOWN;
+					}
 					else
-						Dongle.MODE = NET_MODE_UNKNOWN;
+					{
+						DEBUG_WARN("at+qnwinfo response can not parse.\n");
+					}
 				}
 				else
 					result = FAIL;
@@ -1264,6 +1272,9 @@ TOP:
 						DEBUG_INFO("Device IMEI: %s\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemImei);
 						DEBUG_INFO("Device RSSI: %d dBm (CSQ:%d)\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomRssi, Dongle.CSQ);
 						DEBUG_INFO("Device MODE: %d\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode);
+						DEBUG_INFO("Device Act: %s\n", Dongle.act);
+						DEBUG_INFO("Device Band: %s\n", Dongle.band);
+						DEBUG_INFO("Device Channel: %d\n", Dongle.channel);
 						DEBUG_INFO("========================================\n");
 						
 						Dongle.cnt_ReadInfoFail = 0;
@@ -1294,12 +1305,13 @@ TOP:
 								DEBUG_INFO("Status: PPP interface found...\n");
 								DEBUG_INFO("========================================\n");
 								DEBUG_INFO("PPP IP: %s\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomIpAddress);
+								DEBUG_INFO("Telecom network connection: %d\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn);
 								DEBUG_INFO("========================================\n");
+								ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn = 1;
 
 								Dongle.cnt_pppFail = 0;
 								if(isReachableInternet() == PASS)
 								{
-									ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn = 1;
 									ShmStatusCodeData->AlarmCode.AlarmEvents.bits.Telecom4GModuleCommFail = 0;
 									ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi = 0;
 									ShmStatusCodeData->InfoCode.InfoEvents.bits.ApnDisconnectVia4Gi = 0;
@@ -1314,7 +1326,6 @@ TOP:
 									DEBUG_INFO("========================================\n");
 									DEBUG_INFO("Status: 4G Device connecting...\n");
 									DEBUG_INFO("========================================\n");
-									DEBUG_INFO("Network connection: %d\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn);
 									DEBUG_INFO("Dongle internet valid result: Pass\n");
 									DEBUG_INFO("========================================\n");
 								
@@ -1330,12 +1341,11 @@ TOP:
 								{
 									DEBUG_INFO("Dongle internet valid result: Fail %d time\n", Dongle.cnt_InternetFail);
 
-									ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn = 0;
 									ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi = 1;
 									ShmStatusCodeData->InfoCode.InfoEvents.bits.ApnDisconnectVia4Gi = 1;
 
 									Dongle.cnt_InternetFail++;
-									if(Dongle.cnt_InternetFail > 3)
+									if((Dongle.cnt_InternetFail > 3) && !ShmSysConfigAndInfo->SysInfo.OcppConnStatus)
 									{
 										system("killall 4GDetection");
 										system("killall pppd");
@@ -1350,6 +1360,8 @@ TOP:
 							}
 							else
 							{
+								ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn = 0;
+
 								if(Load4gConfiguration() == FAIL)
 								{
 									DEBUG_ERROR("4G configuration value NG.\n");
@@ -1518,9 +1530,22 @@ TOP:
 				memset(ShmSysConfigAndInfo->SysInfo.TelcomModemFwRev, 0, sizeof ShmSysConfigAndInfo->SysInfo.TelcomModemFwRev);
 				memset(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModelName, 0, sizeof ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModelName);
 				
-				system("killall 4GDetection");
-				system("killall pppd");
-				system("ifconfig ppp0 down");
+				if(system("pidof -s 4GDetection > /dev/null") == 0)
+				{
+					DEBUG_INFO("4GDetection running, stop it.\n");
+					system("killall 4GDetection");
+				}
+
+				if(system("pidof -s pppd > /dev/null") == 0)
+				{
+					DEBUG_INFO("pppd running, stop it.\n");
+					system("killall pppd");
+				}
+
+				if(isPppUp() == PASS)
+				{
+					system("ifconfig ppp0 down");
+				}
 				
 				sleep(SystemInterval);
 				

+ 2 - 2
EVSE/Modularization/Module_Wifi.c

@@ -260,7 +260,7 @@ int isValidCheckSum(uint8_t *message);
 char *Support_InterfaceSTA[2]	= {"mlan0", "wlan0"};
 char *Support_InterfaceAP[1]	= {"uap0"};
 char *valid_Internet[2]			= {"8.8.8.8", "180.76.76.76"};
-char *Version_And_Date[2]		= {"V0.18","2021-03-25"};
+char *Version_And_Date[2]		= {"V0.19","2021-07-06"};
 int protocol_Version [] 		= {0,7,0};
 
 int StoreLogMsg(const char *fmt, ...)
@@ -4540,7 +4540,7 @@ void proc_sta()
 				sleep(5);
 			}
 
-			if(cnt_pingDNS_Fail >= 3)
+			if((cnt_pingDNS_Fail >= 3) && !ShmSysConfigAndInfo->SysInfo.OcppConnStatus)
 			{
 				ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi=1;
 				ShmSysConfigAndInfo->SysConfig.AthInterface.WifiNetworkConn=0;

+ 157 - 19
EVSE/Projects/AW-CCS/Apps/main.c

@@ -1,10 +1,12 @@
 #include	"define.h"
 #include 	"main.h"
 
+//#define CDFA_CERTIFICATE	// Only enable for CDFA certificate to send receipt by Phihong back end API
 
 //==========================
 // System basic sample constant
 //==========================
+#define is_error(ptr) 					((unsigned long)ptr > (unsigned long)-4000L)
 #define ARRAY_SIZE(A)					(sizeof(A) / sizeof(A[0]))
 #define PASS							1
 #define FAIL							-1
@@ -1192,9 +1194,91 @@ int CreatShareMemory()
     return result;
 }
 
-//===============================================
+//======================================================
+// Call WEBAPI to mail receipt (Only for CDFA verify)
+//======================================================
+#ifdef CDFA_CERTIFICATE
+int sendReceiptMail(char *startDateTime, char *stopDateTime, char *receiptInfo)
+{
+	int result = FAIL;
+	char reciever[128];
+	char subject[128];
+	char content[8192];
+	char priceDetail[4098]={0};
+	char cmdBuf[8192];
+
+	double totalEnergy;
+	double totalPrice;
+	json_object *detailPrice = json_tokener_parse(receiptInfo);
+
+	if(!is_error(detailPrice))
+	{
+		if(json_object_object_get(detailPrice, "totalChargedEnergy") != NULL)
+			totalEnergy = json_object_get_double(json_object_object_get(detailPrice, "totalChargedEnergy"));
+
+		if(json_object_object_get(detailPrice, "totalPrice") != NULL)
+			totalPrice = json_object_get_double(json_object_object_get(detailPrice, "totalPrice"));
+
+		if(json_object_object_get(detailPrice, "receiptDetail") != NULL)
+		{
+			for(int idx=0;idx<json_object_array_length(json_object_object_get(detailPrice, "receiptDetail"));idx++)
+			{
+				sprintf(priceDetail, "%s---%02d:00, %.4f KWH @ $ %.2f = $ %.2f<br/>\n", priceDetail
+																                 , json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(detailPrice, "receiptDetail"), idx), "hour"))
+																			     , json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(detailPrice, "receiptDetail"), idx), "chargedEnergy"))
+																				 , json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(detailPrice, "receiptDetail"), idx), "unitPrice"))
+																				 , json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(detailPrice, "receiptDetail"), idx), "periodPrice")));
+			}
+		}
+
+	}
+	json_object_put(detailPrice);
+
+	// Generate mail content
+	sprintf(reciever, "folus_wen@phihong.com.tw");
+	sprintf(subject, "Charging Receipt From %s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
+	sprintf(content, "<img src=\"https://www.phihong.com/images/logo.png\"/><br/>\n"
+					 "<h1>Receipt of charging on %s</h1><br/>\n"
+					 "<b>Location Name:</b> CDFA Lab<br/>\n"
+					 "<b>Location Address:</b> xxxxxxxxxxx<br/>\n"
+					 "<b>EVSE ID:</b> %s<br/>\n"
+					 "<b>Maximum Rate of Energy Transfer:</b> 11.5 KW AC<br/>\n"
+					 "<b>Charging start date time:</b> %s<br/>\n"
+					 "<b>Charging stop date time:</b> %s<br/>\n"
+					 "<b>Energy Delivered:</b> %.4f KWH<br/>\n"
+					 "<b>Cost of Charging:</b><br/>\n"
+				     "%s"
+					 "***Total charged cost: $ %.2f<br/>\n"
+					 "<br/>\n"
+					 "<br/>\n"
+					 "%s<br/>\n"
+					 "47800 Fremont Blvd.<br/>\n"
+					 "Fremont, CA 94538, USA<br/>\n", startDateTime
+					 	 	 	 	 	 	   	    , ShmSysConfigAndInfo->SysConfig.ChargeBoxId
+													, startDateTime
+												    , stopDateTime
+												    , totalEnergy
+												    , priceDetail
+												    , totalPrice
+												    , ShmSysConfigAndInfo->SysConfig.chargePointVendor);
+
+	json_object *post = json_object_new_object();
+	json_object_object_add(post, "Receiver", json_object_new_string(reciever));
+	json_object_object_add(post, "Subject", json_object_new_string(subject));
+	json_object_object_add(post, "Body", json_object_new_string(content));
+	json_object_object_add(post, "UseHtml", json_object_new_boolean(1));
+	// Call WEBAPI
+	sprintf(cmdBuf, "curl -X POST -k -d '%s' -H \"Content-Type: application/json\" https://ocpp.phihong.com.tw:5014/api/Notification/ &", json_object_to_json_string_ext(post, JSON_C_TO_STRING_PLAIN));
+	system(cmdBuf);
+	//DEBUG_INFO("cmdBuf: %s\n", cmdBuf);
+	json_object_put(post);
+
+	return result;
+}
+#endif	/* CDFA_CERTIFICATE */
+//======================================================
 // SQLite3 related routine
-//===============================================
+//======================================================
 int getReceiptInfo(uint8_t gun_index, char *receiptInfo)
 {
 	int result = PASS;
@@ -1229,6 +1313,8 @@ int getReceiptInfo(uint8_t gun_index, char *receiptInfo)
 	sprintf(receiptInfo, "%s", json_object_to_json_string_ext(receipt, JSON_C_TO_STRING_PLAIN));
 	json_object_put(receipt);
 
+	//DEBUG_INFO("receiptInfo: %s\n", receiptInfo);
+
 	return result;
 }
 
@@ -1369,6 +1455,13 @@ int DB_Check_Record_Buf(sqlite3 *db, int gun_index)
 				{
 					DEBUG_INFO( "Copy local charging record buffer successfully\n");
 				}
+
+#ifdef CDFA_CERTIFICATE
+				// Only for CDFA certificate
+				sendReceiptMail(rs[(idxRow*cols)+4],
+								rs[(idxRow*cols)+5],
+								rs[(idxRow*cols)+10]);
+#endif /* CDFA_CERTIFICATE */
 			}
 
 			// Delete buffer
@@ -1399,6 +1492,9 @@ int DB_Update_Record_Buf(sqlite3 *db, int gun_index)
 	int result = PASS;
 	char* errMsg = NULL;
 	char sqlStr[4096];
+	char receiptInfo[2048];
+
+	getReceiptInfo(gun_index, receiptInfo);
 
 	if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 	{
@@ -1414,12 +1510,21 @@ int DB_Update_Record_Buf(sqlite3 *db, int gun_index)
 					    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc,
 					    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy,
 					    "Power Loss",
-					    ShmOCPP16Data->Cost.FinalCost[gun_index].description);
+#ifdef CDFA_CERTIFICATE
+						receiptInfo);// Only for CDFA certificate
+#else
+						ShmOCPP16Data->Cost.FinalCost[gun_index].description);
+#endif /* CDFA_CERTIFICATE */
 	}
 	else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 	{
 		sprintf(sqlStr, "insert into charging_record_buffer(reservationId, transactionId, startMethod, userId, dateTimeStart, dateTimeStop, socStart, socStop, chargeEnergy, stopReason, finalCost) "
- 					    "values('%d', '%s', '%d', '%s', '%s', '%s', '%d', '%d', '%f', '%s', '%f');",
+#ifdef CDFA_CERTIFICATE
+				"values('%d', '%s', '%d', '%s', '%s', '%s', '%d', '%d', '%f', '%s', '%s');",
+#else
+				"values('%d', '%s', '%d', '%s', '%s', '%s', '%d', '%d', '%f', '%s', '%f');",
+#endif /* CDFA_CERTIFICATE */
+
 					    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].ReservationId,
 					    ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId,
 					    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod,
@@ -1430,7 +1535,12 @@ int DB_Update_Record_Buf(sqlite3 *db, int gun_index)
 					    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc,
 					    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy,
 					    "Power Loss",
-					    ShmOCPP20Data->CostUpdated.totalCost);
+#ifdef CDFA_CERTIFICATE
+						//receiptInfo);// Only for CDFA certificate
+#else
+						ShmOCPP20Data->CostUpdated.totalCost);
+#endif /* CDFA_CERTIFICATE */
+
 	}
 
 	if(sqlite3_open(DB_FILE, &db))
@@ -1477,12 +1587,11 @@ int DB_Insert_Record(sqlite3 *db, int gun_index)
 	char receiptInfo[2048];
 
 	getReceiptInfo(gun_index, receiptInfo);
-	DEBUG_INFO("Receipt Info: %s\n", receiptInfo);
 
 	if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 	{
 		sprintf(sqlStr, "insert into charging_record(reservationId, transactionId, startMethod, userId, dateTimeStart, dateTimeStop, socStart, socStop, chargeEnergy, stopReason, finalCost) "
- 					    "values('%d', '%d', '%d', '%s', '%s', '%s', '%d', '%d', '%f', '%s', '%s');",
+						"values('%d', '%d', '%d', '%s', '%s', '%s', '%d', '%d', '%f', '%s', '%s');",
 					    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].ReservationId,
 					    ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId,
 					    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod,
@@ -1493,12 +1602,21 @@ int DB_Insert_Record(sqlite3 *db, int gun_index)
 					    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc,
 					    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy,
 					    ShmOCPP16Data->StopTransaction[gun_index].StopReason,
-					    ShmOCPP16Data->Cost.FinalCost[gun_index].description);
+#ifdef CDFA_CERTIFICATE
+						receiptInfo);// Only for CDFA certificate
+#else
+						ShmOCPP16Data->Cost.FinalCost[gun_index].description);
+#endif /* CDFA_CERTIFICATE */
+
 	}
 	else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 	{
 		sprintf(sqlStr, "insert into charging_record(reservationId, transactionId, startMethod, userId, dateTimeStart, dateTimeStop, socStart, socStop, chargeEnergy, stopReason, finalCost) "
- 					    "values('%d', '%s', '%d', '%s', '%s', '%s', '%d', '%d', '%f', '%s', '%f');",
+#ifdef CDFA_CERTIFICATE
+ 					    "values('%d', '%s', '%d', '%s', '%s', '%s', '%d', '%d', '%f', '%s', '%s');",
+#else
+						"values('%d', '%s', '%d', '%s', '%s', '%s', '%d', '%d', '%f', '%s', '%f');",
+#endif /* CDFA_CERTIFICATE */
 					    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].ReservationId,
 					    ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId,
 					    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod,
@@ -1509,7 +1627,13 @@ int DB_Insert_Record(sqlite3 *db, int gun_index)
 					    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc,
 					    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy,
 					    ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason,
-					    ShmOCPP20Data->CostUpdated.totalCost);
+#ifdef CDFA_CERTIFICATE
+						receiptInfo);// Only for CDFA certificate
+#else
+						ShmOCPP20Data->CostUpdated.totalCost);
+#endif /* CDFA_CERTIFICATE */
+
+
 	}
 	//DEBUG_INFO("sqlStr= %s\n", sqlStr);
 
@@ -1557,6 +1681,13 @@ int DB_Insert_Record(sqlite3 *db, int gun_index)
 		sqlite3_close(db);
 	}
 
+#ifdef CDFA_CERTIFICATE
+	// Only for CDFA certificate
+	sendReceiptMail((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartDateTime,
+					(char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StopDateTime,
+					receiptInfo);
+#endif
+
 	return result;
 }
 
@@ -1637,7 +1768,6 @@ int DB_Get_Operactive(sqlite3 *db, uint8_t gun_index)
 	return result;
 }
 
-
 //======================================================
 // Peripheral initial
 //======================================================
@@ -4347,15 +4477,23 @@ int main(void)
 		ShmSysConfigAndInfo->SysInfo.OcppConnStatus = ocpp_get_connection_status();
 
 		//==============================================
-		// Check task processing
+		// Period check for 10 seconds
 		//==============================================
-		if(ShmSysConfigAndInfo->SysInfo.AcChargingData[0].SystemStatus != SYS_MODE_BOOTING)
-			checkTask();
+		if(DiffTimebWithNow(startTime[0][TMR_IDX_CHECK_TASK]) > 10000)
+		{
+			//==============================================
+			// Check task processing
+			//==============================================
+			if(ShmSysConfigAndInfo->SysInfo.AcChargingData[0].SystemStatus != SYS_MODE_BOOTING)
+				checkTask();
 
-		//==============================================
-		// Check connection timeout specification
-		//==============================================
-		checkConnectionTimeout();
+			//==============================================
+			// Check connection timeout specification
+			//==============================================
+			checkConnectionTimeout();
+
+			ftime(&startTime[0][TMR_IDX_CHECK_TASK]);
+		}
 
 		//==============================================
 		// Something need run in Idle mode
@@ -4371,7 +4509,7 @@ int main(void)
 				{
 					setLedMotion(gun_index,LED_ACTION_INIT);
 				}
-				
+
 				sleep(5);
 				system("cd /root;./Module_FactoryConfig -m");
 				system("rm -f /Storage/OCPP/OCPPConfiguration");

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

@@ -221,7 +221,7 @@ enum TIMER_IDX
 	TMR_IDX_POWERSAVING_RFID,
 	TMR_IDX_POWERSAVING_METER,
 	TMR_IDX_POWERSAVING_STATE_B,
-	TMR_IDX_11,
+	TMR_IDX_CHECK_TASK,
 	TMR_IDX_12,
 	TMR_IDX_13,
 	TMR_IDX_14,

+ 9 - 0
EVSE/rootfs/etc/init.d/rcS

@@ -118,3 +118,12 @@ echo 3 > /proc/sys/kernel/panic
 #echo 1 > /proc/sys/kernel/panic_on_rcu_stall
 /sbin/klogd
 /sbin/syslogd -f /etc/syslog.conf
+
+#   ---------------------------------------------
+#   Enable swap
+#   ---------------------------------------------
+#dd if=/dev/zero of=/Storage/swapfile bs=1024 count=65535
+#losetup /dev/loop7 /Storage/swapfile
+#mkswap /dev/loop7
+#swapon /dev/loop7
+

+ 7 - 0
Makefile

@@ -25,6 +25,7 @@ Taurus-uboot:
 	$(MAKE) -j $(MAKE_JOBS) -C $(TI_SDK_PATH)/board-support/u-boot-* CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F16G08
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/MLO EVSE/Projects/Taurus/Images/
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/u-boot.img EVSE/Projects/Taurus/Images/
+	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/spl/u-boot-spl.bin EVSE/Projects/Taurus/Images/
 
 Taurus-linux-default: linux_clean linux
 	@cp -f board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/zImage EVSE/Projects/Taurus/Images/
@@ -174,6 +175,7 @@ CCS-uboot:
 	$(MAKE) -j $(MAKE_JOBS) -C $(TI_SDK_PATH)/board-support/u-boot-* CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F16G08
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/MLO EVSE/Projects/CCS/Images/
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/u-boot.img EVSE/Projects/CCS/Images/
+	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/spl/u-boot-spl.bin EVSE/Projects/CCS/Images/
 
 CCS-linux-default: linux_clean linux
 	@cp -f board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/zImage EVSE/Projects/CCS/Images/
@@ -278,6 +280,7 @@ DM30-uboot:
 	$(MAKE) -j $(MAKE_JOBS) -C $(TI_SDK_PATH)/board-support/u-boot-* CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F16G08
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/MLO EVSE/Projects/DM30/Images/
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/u-boot.img EVSE/Projects/DM30/Images/
+	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/spl/u-boot-spl.bin EVSE/Projects/DM30/Images/
 
 DM30-linux-default: linux_clean linux
 	@cp -f board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/zImage EVSE/Projects/DM30/Images/
@@ -373,6 +376,7 @@ DW30-uboot:
 	$(MAKE) -j $(MAKE_JOBS) -C $(TI_SDK_PATH)/board-support/u-boot-* CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F16G08
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/MLO EVSE/Projects/DW30/Images/
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/u-boot.img EVSE/Projects/DW30/Images/
+	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/spl/u-boot-spl.bin EVSE/Projects/DW30/Images/
 
 DW30-linux-default: linux_clean linux
 	@cp -f board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/zImage EVSE/Projects/DW30/Images/
@@ -472,6 +476,7 @@ DS60-120-uboot:
 	$(MAKE) -j $(MAKE_JOBS) -C $(TI_SDK_PATH)/board-support/u-boot-* CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F16G08
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/MLO EVSE/Projects/DS60-120/Images/
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/u-boot.img EVSE/Projects/DS60-120/Images/
+	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/spl/u-boot-spl.bin EVSE/Projects/DS60-120/Images/
 
 DS60-120-linux-default: linux_clean linux
 	@cp -f board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/zImage EVSE/Projects/DS60-120/Images/
@@ -543,6 +548,7 @@ AW-Regular-uboot:
 	$(MAKE) -j $(MAKE_JOBS) -C $(TI_SDK_PATH)/board-support/u-boot-* CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F8G08
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/MLO EVSE/Projects/AW-Regular/Images/
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/u-boot.img EVSE/Projects/AW-Regular/Images/
+	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/spl/u-boot-spl.bin EVSE/Projects/AW-Regular/Images/
 
 AW-Regular-linux-default: linux_clean linux
 	@cp -f board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/zImage EVSE/Projects/AW-Regular/Images/
@@ -614,6 +620,7 @@ BYTON-GB-uboot:
 	$(MAKE) -j $(MAKE_JOBS) -C $(TI_SDK_PATH)/board-support/u-boot-* CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F16G08
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/MLO EVSE/Projects/BYTON-GB/Images/
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/u-boot.img EVSE/Projects/BYTON-GB/Images/
+	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/spl/u-boot-spl.bin EVSE/Projects/BYTON-GB/Images/
 
 BYTON-GB-linux-default: linux_clean linux
 	@cp -f board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/zImage EVSE/Projects/BYTON-GB/Images/

+ 1 - 1
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[ATE]am335x-evm.dts

@@ -27,7 +27,7 @@
 
 	memory {
 		device_type = "memory";
-		reg = <0x80000000 0x10000000>; /* 256 MB */
+		//reg = <0x80000000 0x10000000>; /* 256 MB */
 		reg = <0x80000000 0x20000000>; /* 512 MB */ /* +++ vern,512MB DDR ,20181030 ---*/
 	};
 

+ 1 - 1
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[CCS]am335x-evm.dts

@@ -27,7 +27,7 @@
 
 	memory {
 		device_type = "memory";
-		reg = <0x80000000 0x10000000>; /* 256 MB */
+		//reg = <0x80000000 0x10000000>; /* 256 MB */
 		reg = <0x80000000 0x20000000>; /* 512 MB */ /* +++ vern,512MB DDR ,20181030 ---*/
 	};
 

+ 1 - 1
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[DD360Audi]am335x-evm.dts

@@ -27,7 +27,7 @@
 
 	memory {
 		device_type = "memory";
-		reg = <0x80000000 0x10000000>; /* 256 MB */
+		//reg = <0x80000000 0x10000000>; /* 256 MB */
 		reg = <0x80000000 0x20000000>; /* 512 MB */ /* +++ vern,512MB DDR ,20181030 ---*/
 	};
 

+ 1 - 1
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[DD360]am335x-evm.dts

@@ -27,7 +27,7 @@
 
 	memory {
 		device_type = "memory";
-		reg = <0x80000000 0x10000000>; /* 256 MB */
+		//reg = <0x80000000 0x10000000>; /* 256 MB */
 		reg = <0x80000000 0x20000000>; /* 512 MB */ /* +++ vern,512MB DDR ,20181030 ---*/
 	};
 

+ 1 - 1
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[DM30]am335x-evm.dts

@@ -27,7 +27,7 @@
 
 	memory {
 		device_type = "memory";
-		reg = <0x80000000 0x10000000>; /* 256 MB */
+		//reg = <0x80000000 0x10000000>; /* 256 MB */
 		reg = <0x80000000 0x20000000>; /* 512 MB */ /* +++ vern,512MB DDR ,20181030 ---*/
 	};
 

+ 1 - 1
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[DO360]am335x-evm.dts

@@ -27,7 +27,7 @@
 
 	memory {
 		device_type = "memory";
-		reg = <0x80000000 0x10000000>; /* 256 MB */
+		//reg = <0x80000000 0x10000000>; /* 256 MB */
 		reg = <0x80000000 0x20000000>; /* 512 MB */ /* +++ vern,512MB DDR ,20181030 ---*/
 	};
 

+ 1 - 1
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[DS60-120-Infy]am335x-evm.dts

@@ -27,7 +27,7 @@
 
 	memory {
 		device_type = "memory";
-		reg = <0x80000000 0x10000000>; /* 256 MB */
+		//reg = <0x80000000 0x10000000>; /* 256 MB */
 		reg = <0x80000000 0x20000000>; /* 512 MB */ /* +++ vern,512MB DDR ,20181030 ---*/
 	};
 

+ 1 - 1
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[DS60-120]am335x-evm.dts

@@ -27,7 +27,7 @@
 
 	memory {
 		device_type = "memory";
-		reg = <0x80000000 0x10000000>; /* 256 MB */
+		//reg = <0x80000000 0x10000000>; /* 256 MB */
 		reg = <0x80000000 0x20000000>; /* 512 MB */ /* +++ vern,512MB DDR ,20181030 ---*/
 	};
 

+ 1 - 1
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[DW30]am335x-evm.dts

@@ -27,7 +27,7 @@
 
 	memory {
 		device_type = "memory";
-		reg = <0x80000000 0x10000000>; /* 256 MB */
+		//reg = <0x80000000 0x10000000>; /* 256 MB */
 		reg = <0x80000000 0x20000000>; /* 512 MB */ /* +++ vern,512MB DDR ,20181030 ---*/
 	};
 

+ 1 - 1
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[PlugIt360]am335x-evm.dts

@@ -27,7 +27,7 @@
 
 	memory {
 		device_type = "memory";
-		reg = <0x80000000 0x10000000>; /* 256 MB */
+		//reg = <0x80000000 0x10000000>; /* 256 MB */
 		reg = <0x80000000 0x20000000>; /* 512 MB */ /* +++ vern,512MB DDR ,20181030 ---*/
 	};
 

+ 1 - 1
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[Taurus]am335x-evm.dts

@@ -27,7 +27,7 @@
 
 	memory {
 		device_type = "memory";
-		reg = <0x80000000 0x10000000>; /* 256 MB */
+		//reg = <0x80000000 0x10000000>; /* 256 MB */
 		reg = <0x80000000 0x20000000>; /* 512 MB */ /* +++ vern,512MB DDR ,20181030 ---*/
 	};
 

+ 1 - 1
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[Zanobe]am335x-evm.dts

@@ -27,7 +27,7 @@
 
 	memory {
 		device_type = "memory";
-		reg = <0x80000000 0x10000000>; /* 256 MB */
+		//reg = <0x80000000 0x10000000>; /* 256 MB */
 		reg = <0x80000000 0x20000000>; /* 512 MB */ /* +++ vern,512MB DDR ,20181030 ---*/
 	};
 

+ 1 - 1
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[e4you]am335x-evm.dts

@@ -27,7 +27,7 @@
 
 	memory {
 		device_type = "memory";
-		reg = <0x80000000 0x10000000>; /* 256 MB */
+		//reg = <0x80000000 0x10000000>; /* 256 MB */
 		reg = <0x80000000 0x20000000>; /* 512 MB */ /* +++ vern,512MB DDR ,20181030 ---*/
 	};