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

2022-07-05 / Simon Xue

Action:
1. [Mod] DAKA IDLE Page can select gun.
2. [Fix] EV Board status code bug.

Files
As the following commit history files

Image Version: V2.12.XX.XXXX.XX
Simon Xue 2 жил өмнө
parent
commit
bce9c8a26e
35 өөрчлөгдсөн 2129 нэмэгдсэн , 125 устгасан
  1. 2 0
      EVSE/Projects/DD360Tcci/Apps/CSU/Ethernet.c
  2. 13 29
      EVSE/Projects/DD360Tcci/Apps/CSU/RFID.c
  3. 42 31
      EVSE/Projects/DD360Tcci/Apps/CSU/main.c
  4. 3 2
      EVSE/Projects/DD360Tcci/Apps/CSU/main.h
  5. 4 0
      EVSE/Projects/DD360Tcci/Apps/Config.h
  6. 2 2
      EVSE/Projects/DD360Tcci/Apps/Makefile
  7. 15 8
      EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.c
  8. 1 1
      EVSE/Projects/DD360Tcci/Apps/ModuleEvComm/AbnormalCCS.c
  9. 1 1
      EVSE/Projects/DD360Tcci/Apps/ModuleEvComm/AbnormalCHA.c
  10. 1 0
      EVSE/Projects/DD360Tcci/Apps/ModuleEvComm/AbnormalGBT.c
  11. 19 17
      EVSE/Projects/DD360Tcci/Apps/ModuleEvComm/Module_EvTxComm.c
  12. 25 4
      EVSE/Projects/DD360Tcci/Apps/ModuleInternalComm/RelayBoard.c
  13. 76 24
      EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.c
  14. 9 1
      EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.h
  15. 14 4
      EVSE/Projects/DD360Tcci/Apps/ModulePrimary/Module_PrimaryComm.c
  16. 25 0
      EVSE/Projects/DD360Tcci/Apps/ReadCmdline.c
  17. 1 1
      EVSE/Projects/DD360Tcci/Apps/ShareMemory/shmMem.c
  18. 1 0
      EVSE/Projects/DD360Tcci/Apps/timeout.h
  19. BIN
      EVSE/Projects/DD360Tcci/Images/ramdisk.gz
  20. BIN
      EVSE/Projects/DD360Tcci/output/FactoryConfig
  21. BIN
      EVSE/Projects/DD360Tcci/output/Module_ChkSysTask
  22. BIN
      EVSE/Projects/DD360Tcci/output/Module_DoComm
  23. BIN
      EVSE/Projects/DD360Tcci/output/Module_EvComm
  24. BIN
      EVSE/Projects/DD360Tcci/output/Module_EventLogging
  25. BIN
      EVSE/Projects/DD360Tcci/output/Module_InternalComm
  26. BIN
      EVSE/Projects/DD360Tcci/output/Module_LcmControl
  27. BIN
      EVSE/Projects/DD360Tcci/output/Module_PrimaryComm
  28. BIN
      EVSE/Projects/DD360Tcci/output/Module_UpdateFW
  29. BIN
      EVSE/Projects/DD360Tcci/output/ReadCmdline
  30. BIN
      EVSE/Projects/DD360Tcci/output/main
  31. 447 0
      EVSE/Projects/DD360UCar/Apps/Module_LcmControl_Wistron/LcmCommandDriver.c
  32. 1179 0
      EVSE/Projects/DD360UCar/Apps/Module_LcmControl_Wistron/Module_LcmControl_Wistron.c
  33. 232 0
      EVSE/Projects/DD360UCar/Apps/Module_LcmControl_Wistron/Module_LcmControl_Wistron.h
  34. 17 0
      EVSE/Projects/DD360UCar/Apps/Module_LcmControl_Wistron/Module_LcmItemList.c
  35. BIN
      EVSE/Projects/DD360UCar/output/Module_LcmWistronControl

+ 2 - 0
EVSE/Projects/DD360Tcci/Apps/CSU/Ethernet.c

@@ -161,6 +161,8 @@ void InitEthernet(void)
     log_info("%s",tmpbuf);
     system(tmpbuf);
 
+    system("/sbin/ifconfig lo up");
+
     //Run DHCP client if enabled
     system("killall udhcpc");
     system("rm -rf /etc/resolv.conf");

+ 13 - 29
EVSE/Projects/DD360Tcci/Apps/CSU/RFID.c

@@ -439,15 +439,6 @@ void RemoteStartCancelPreAuth(int sel_gun)
     memcpy(&ShmDcCommonData->RedeductBill, &ShmDcCommonData->TransactionInfo[sel_gun], sizeof(RecordTransactionInfo));
     memset(&ShmDcCommonData->TransactionInfo[sel_gun], 0x00, sizeof(RecordTransactionInfo));
     ShmDcCommonData->TransactionInfo[sel_gun].LineStatus = ShmDcCommonData->RedeductBill.LineStatus;
-    if (strcmp((char*)ShmDcCommonData->RedeductBill.pCreditCard.CardNo, "") != 0) {
-        log_info("Remote start get Wrong Authorize card:%s, vemData:%s",
-            ShmDcCommonData->RedeductBill.pCreditCard.CardNo,
-            ShmDcCommonData->RedeductBill.pCreditCard.VemData);
-        ShmDcCommonData->RedeductBill.DeductResult = _DEDUCT_PREAUTH;
-        ShmDcCommonData->RedeductBill.IsUpload = FALSE;
-        ShmDcCommonData->RedeductBill.ConnectorID = ShmDcCommonData->ConnectorID[sel_gun];
-        //InsertDeductInfo(sel_gun, &ShmDcCommonData->RedeductBill);
-    }
 }
 
 void CreateRfidFork(void)
@@ -501,7 +492,6 @@ void CreateRfidFork(void)
 			for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
 				pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
 
-
                 // 檢查電樁狀態是否為idle狀態
 				if (pDcChargingInfo->SystemStatus != S_IDLE ) {
 					is_idle = FALSE;
@@ -579,17 +569,16 @@ void CreateRfidFork(void)
         		result = CreditCardPreAuth(fd, PREAUTHMONEY,&pSysConfig->ModelName[0], &ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard);
 
                 pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(sel_gun);
-                if (checkRemoteStart(sel_gun)) {
-                    RemoteStartCancelPreAuth(sel_gun);
-                } else {
-                    if (!ShmDcCommonData->TradeCancel)
-                        StopSystemTimeoutDet();
-                    if (ShmDcCommonData->TradeCancel == FALSE && result > 0) {
-                        pSysInfo->SystemPage = _PAGE_SENSING;
+                {
+                    if (!checkRemoteStart(sel_gun)) {
+                        if (!ShmDcCommonData->TradeCancel)
+                            StopSystemTimeoutDet();
+                        if (ShmDcCommonData->TradeCancel == FALSE && result > 0) {
+                            pSysInfo->SystemPage = _PAGE_SENSING;
+                        }
+                        if (result > 0)
+                            sleep(3);
                     }
-                    if (result > 0)
-                        sleep(3);
-
                     ShmDcCommonData->PreAuth_Result = result;
 
                     //result = 1;
@@ -605,7 +594,7 @@ void CreateRfidFork(void)
                         InsertDeductInfo(ShmDcCommonData->ConnectorID[sel_gun], &ShmDcCommonData->TransactionInfo[sel_gun]);
                         log_info("PreAuth OK");
                     } else if (result < 0) {
-                        if (ShmDcCommonData->TradeCancel == FALSE)
+                        if (ShmDcCommonData->TradeCancel == FALSE && !checkRemoteStart(sel_gun))
                             pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
                         ShmDcCommonData->AuthPass_flag[sel_gun] = FALSE;
                         memset(&ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard, 0, sizeof(TransInfo));
@@ -625,10 +614,7 @@ void CreateRfidFork(void)
                 ShmDcCommonData->RoutineReduct == FALSE) || ShmDcCommonData->Exe_ReDeduct) {
 
                 ReDeductProcess(fd);
-                if (ShmDcCommonData->TaiwanEast)
-                    pSysInfo->SystemPage = _PAGE_IDLE;
-                else
-                    pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+                pSysInfo->SystemPage = _PAGE_IDLE;
                 ShmDcCommonData->CreditCardUpload = FALSE;
                 ShmDcCommonData->Exe_ReDeduct = 0;
             }
@@ -652,10 +638,8 @@ void CreateRfidFork(void)
                 else
                     log_info("CreditCardUnionSettlement FAIL");
                 sleep(90);
-                if (ShmDcCommonData->TaiwanEast)
-                    pSysInfo->SystemPage = _PAGE_IDLE;
-                else
-                    pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+                pSysInfo->SystemPage = _PAGE_IDLE;
+
                 ShmDcCommonData->CreditCardUpload = FALSE;
             }
             if (tm->tm_hour == 16 && tm->tm_min == 0) {

+ 42 - 31
EVSE/Projects/DD360Tcci/Apps/CSU/main.c

@@ -83,7 +83,7 @@ uint8_t bd1_1_status = 0;
 uint8_t bd1_2_status = 0;
 
 char *fwVersion = "V2.12.00.0000.00"; // Phihong version
-char* DebugVersion = "v2.12.00";      // Software debug version
+char* DebugVersion = "v2.12.01";      // Software debug version
 //sqlite3 *localDb;
 bool isDb_ready;
 
@@ -149,7 +149,19 @@ static uint8_t getCurLcmPage(void)
 
 static void systemPageRestoreInit(void)
 {
-    if (ShmDcCommonData->TaiwanEast)
+    int is_idle = TRUE;
+    int gunIndex;
+    for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
+        pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
+        // 檢查電樁狀態是否為idle狀態
+        if ((pDcChargingInfo->SystemStatus >= S_AUTHORIZING &&
+            pDcChargingInfo->SystemStatus <= S_RESERVATION) ||
+            (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
+            pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST0)) {
+            is_idle = FALSE;
+        }
+    }
+    if (is_idle)
         pSysInfo->SystemPage = _PAGE_IDLE;
     else
         pSysInfo->SystemPage = _PAGE_SELECT_GUN;
@@ -242,11 +254,11 @@ void setSelGunWaitToAuthor(uint8_t curSel)
 {
     if (curSel == LEFT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_CONFIRM) {
         ShmSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_ATHOR;
-        log_info("setSelGunWaitToAuthor left");
+        //log_info("setSelGunWaitToAuthor left");
         StopGunInfoTimeoutDet(curSel);
     } else if (curSel == RIGHT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_CONFIRM) {
         ShmSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_ATHOR;
-        log_info("setSelGunWaitToAuthor right");
+        //log_info("setSelGunWaitToAuthor right");
         StopGunInfoTimeoutDet(curSel);
     }
 }
@@ -1550,10 +1562,7 @@ void _DetectPlugInTimeout(uint8_t gunIndex)
 	ShmDcCommonData->PreAuth_Result = 0;
 
     if (pSysInfo->CurGunSelected == gunIndex) {
-        if (ShmDcCommonData->TaiwanEast)
-            pSysInfo->SystemPage = _PAGE_IDLE;
-        else
-            pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+        systemPageRestoreInit();
     }
     StopSystemTimeoutDet();
     ClearDetectPluginFlag(gunIndex);
@@ -1617,7 +1626,7 @@ void _LinkErrorTimeout(uint8_t gunIndex)
 {
 	log_info("*********** _LinkErrorTimeout ***********");
 	setChargerMode(pSysInfo->CurGunSelected, S_IDLE);
-	pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+    systemPageRestoreInit();
 }
 
 //===============================================
@@ -2525,7 +2534,7 @@ void CreateTimeoutFork(void)
             if (pSysInfo->SystemTimeoutFlag != 0)
             log_info("Timeout ***********SystemTimeoutFlag = %d(%d) ********",pSysInfo->SystemTimeoutFlag,
                     GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL);
-                    */
+              */      
             // 系統
             switch (pSysInfo->SystemTimeoutFlag) {
             case Timeout_SelftestChk:
@@ -2538,10 +2547,7 @@ void CreateTimeoutFork(void)
             case Timeout_ReturnViewPage:
                 if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= RETURN_VIEWPAGE_TIMEOUT) {
                     StopSystemTimeoutDet();
-                    if (ShmDcCommonData->TaiwanEast)
-                        pSysInfo->SystemPage = _PAGE_IDLE;
-                    else
-                        pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+                    systemPageRestoreInit();
                 }
             	break;
             case Timeout_Authorizing:
@@ -2572,7 +2578,7 @@ void CreateTimeoutFork(void)
                 if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= AUTHORIZE_FAIL_TIMEOUT) {
                     log_info("Timeout_VerifyFail");
                     StopSystemTimeoutDet();
-                    pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+                    systemPageRestoreInit();
                     setChargerMode(pSysInfo->CurGunSelected, S_IDLE);
                 }
                 break;
@@ -2624,7 +2630,7 @@ void CreateTimeoutFork(void)
             	if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= TCC_ADDLINE_TIMEOUT) {
                     log_info("Timeout_AddLine");
             		StopSystemTimeoutDet();
-            		pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+                    systemPageRestoreInit();
                     ShmDcCommonData->OperateIDLE[pSysInfo->CurGunSelected] = 1;
             	}
             	break;
@@ -2633,14 +2639,14 @@ void CreateTimeoutFork(void)
             	if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= TCC_DONATECOMFIRM_TIMEOUT) {
                     log_info("Timeout_DonateComfirm");
             		StopSystemTimeoutDet();
-            		pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+                    systemPageRestoreInit();
             	}
             	break;
             case Timeout_SelectPayMode:
             	if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= TCC_SELECTPAY_TIMEOUT) {
                     log_info("Timeout_SelectPayMode");
             		StopSystemTimeoutDet();
-            		pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+                    systemPageRestoreInit();
                     ShmDcCommonData->OperateIDLE[pSysInfo->CurGunSelected] = 1;
             	}
             	break;
@@ -2650,7 +2656,15 @@ void CreateTimeoutFork(void)
                     StopSystemTimeoutDet();
                     pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(pSysInfo->CurGunSelected);
                     setChargerMode(pSysInfo->CurGunSelected, MODE_IDLE);
-                    pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+                    systemPageRestoreInit();
+                    ShmDcCommonData->OperateIDLE[pSysInfo->CurGunSelected] = 1;
+                }
+                break;
+            case Timeout_LINEPAYING:
+                if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= TCC_LINEPAYING_TIMEOUT) {
+                    log_info("Timeout_LINEPAYING");
+                    StopSystemTimeoutDet();
+                    systemPageRestoreInit();
                     ShmDcCommonData->OperateIDLE[pSysInfo->CurGunSelected] = 1;
                 }
                 break;
@@ -2675,7 +2689,7 @@ void CreateTimeoutFork(void)
                         ClearAuthorizedFlag();
                         StopGunInfoTimeoutDet(gunIndex);
                         if (pSysInfo->CurGunSelected == gunIndex)
-                            pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+                            systemPageRestoreInit();
                     }
                     break;
                 case Timeout_WaitPlug:
@@ -2772,7 +2786,7 @@ void CreateTimeoutFork(void)
                 	if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= TCC_LINEREGISTER_TIMEOUT) {
                         log_info("Gun[%d] Timeout_LineReigster",gunIndex);
                 		StopGunInfoTimeoutDet(gunIndex);
-                		pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+                        systemPageRestoreInit();
                 		ShmDcCommonData->TransactionInfo[gunIndex].IsDonateInvoice = FALSE;
                         ShmDcCommonData->OperateIDLE[gunIndex] = 1;
                 	}
@@ -3952,10 +3966,7 @@ void ResetIdleData(uint8_t gunIndex)
     if (pSysInfo->SystemPage != _PAGE_SELECT_GUN &&
         pSysInfo->SystemPage != _PAGE_SELECT_PAY &&
         pSysInfo->CurGunSelected == gunIndex) {
-        if (ShmDcCommonData->TaiwanEast)
-            pSysInfo->SystemPage = _PAGE_IDLE;
-        else
-            pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+        systemPageRestoreInit();
     }
 
 }
@@ -4115,6 +4126,7 @@ static void SetGunTypeOTPValue(void)
         Gun2Type = pSysConfig->ModelName[9];
         for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
             pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(i);
+            pDcChargingInfo->deratingByConnOtp.isNeedDerating = GUNOTPDERATING;
             switch (i == 0 ? Gun1Type : Gun2Type) {
                 //CHAdeMo
             case 'J':
@@ -4274,7 +4286,7 @@ int main(void)
     }
     log_info("===== Create DB End ===== ");
 
-    ChangeLcmByIndex(_PAGE_SELECT_GUN);
+    ChangeLcmByIndex(_PAGE_IDLE);
 
     sleep(1);
     //***** 須新增的偵測 *****//
@@ -4282,7 +4294,6 @@ int main(void)
     // 2. ouput fuse - 控制風扇轉速
     CreateRfidFork();
     // Main loop
-    showversion();
 
     CheckFwSlotStatusLog();
     //AdjustChargerCurrent();
@@ -4294,7 +4305,9 @@ int main(void)
 
     CreateWatchdog();
     
-    SetGunTypeOTPValue();
+    //SetGunTypeOTPValue();
+
+    showversion();
 
     for (;;) {
 
@@ -4397,8 +4410,6 @@ int main(void)
                 if (pSysInfo->SystemPage == _PAGE_SELECT_GUN) {
                 	//ShmDcCommonData->LineStatus[gunIndex] = 0;
                 	StopGunInfoTimeoutDet(gunIndex);
-                    if (ShmDcCommonData->TaiwanEast)
-                        StartSystemTimeoutDet(Timeout_ReturnViewPage);
 				}
 
                 if (pSysInfo->CurGunSelected == gunIndex) {
@@ -4563,8 +4574,8 @@ int main(void)
                     if (pSysInfo->OrderCharging != NO_DEFINE) {
                         pSysInfo->OrderCharging = NO_DEFINE;
                         pDcChargingInfo->_SaftyDetect = FALSE;
-                        pDcChargingInfo->Replug_flag = TRUE;
                     }
+                    pDcChargingInfo->Replug_flag = TRUE;
                     StopSystemTimeoutDet();
                     StopGunInfoTimeoutDet(gunIndex);
                     gettimeofday(&pDcChargingInfo->PreChargeTimer, NULL);

+ 3 - 2
EVSE/Projects/DD360Tcci/Apps/CSU/main.h

@@ -27,7 +27,7 @@
 
 #define uSEC_VAL                                (1000000)
 #define SELFTEST_TIMEOUT                        (60)//45
-#define RETURN_VIEWPAGE_TIMEOUT                 (30)
+#define RETURN_VIEWPAGE_TIMEOUT                 (60)
 #define AUTHORIZE_TIMEOUT                       (60)//30
 #define BALANCE_TIMEOUT                         (15)//15
 #define AUTHORIZE_FAIL_TIMEOUT                  (5)
@@ -47,7 +47,7 @@
 #define PRECHARGING_TTIMEOUT                    (60)
 #define PLUGOUTGUN_TIMEOUT                      (10)
 #define TCC_ADDLINE_TIMEOUT						(60)
-#define TCC_LINEREGISTER_TIMEOUT				(60)
+#define TCC_LINEREGISTER_TIMEOUT				(90)
 #define TCC_DONATECOMFIRM_TIMEOUT				(180)
 #define TCC_SELECTPAY_TIMEOUT					(180)
 #define TCC_FINALCOST_TIMEOUT					(60)
@@ -55,6 +55,7 @@
 #define TCC_TRADECANCEL_TIMEOUT                 (60)
 #define TCC_EXITPAGE_TIMEOUT                    (10)
 #define TCC_ISPLUGOUT_TIMEOUT                   (3)
+#define TCC_LINEPAYING_TIMEOUT                  (5)
 
 //#define log_info(format, args...) StoreLogMsg_1("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 //#define log_warn(format, args...) StoreLogMsg_1("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)

+ 4 - 0
EVSE/Projects/DD360Tcci/Apps/Config.h

@@ -95,6 +95,7 @@
 #define WARN_LV_WARN                            (1)
 #define WARN_LV_ER                              (2) //emergency state
 
+#define GUNOTPDERATING                          (1)
 //------------------------------------------------------------------------------
 enum _SYSTEM_STATUS {
     S_BOOTING = 0,
@@ -166,6 +167,7 @@ enum _PAGE_TCC_INDEX {
 	_PAGE_DONATE_RIGHT,
 	_PAGE_STOP_CONFIRM_RIGHT,
 	_PAGE_PAYFAIL,
+    _PAGE_LINEPAYING,
     _PAGE_MAINTAIN = 30,
 };
 enum _SELF_TEST_SEQ {
@@ -497,6 +499,7 @@ typedef struct stPriceBillInfo {
     float EnergyCost;
     float ParkingFee;
     float RemainAmount;
+    uint8_t gunIndex;
 }PriceBillInfo;
 typedef struct StDcCommonInfo {
     uint8_t RebootCount;
@@ -568,6 +571,7 @@ typedef struct StDcCommonInfo {
     int EVDisconnectFlag[2];
     int is_plugout[2];
     GunInfo pGunInfo[2];
+    time_t FanOnTime;
     uint8_t AuthroizeType; // 0: Central   1: eMAID    2: ISO14443 3: ISO15693 4: KeyCode  5: Local    6: MacAddress   7: NoAuthorization
     char QRCodeString[255];
     char DefaultPriceString[255];

+ 2 - 2
EVSE/Projects/DD360Tcci/Apps/Makefile

@@ -137,7 +137,7 @@ PRIMARY_SRC_FILES = $(patsubst %.o, %.c, $(PRIMARY_OBJ_FILES))
 	$(CC) $(CFLAGS) -c $<
 
 #ReadCmdLine
-READCMDLINE_OBJ_FILES = $(COMMON_OBJ_FILES) ReadCmdline.o
+READCMDLINE_OBJ_FILES = $(COMMON_OBJ_FILES) $(DataBaseLib)/DataBase.o ReadCmdline.o
 READCMDLINE_SRC_FILES = $(patsubst %.o, %.c, $(READCMDLINE_OBJ_FILES))
 %.o: %.c
 	$(CC) $(CFLAGS) -c $<
@@ -208,7 +208,7 @@ PsuCommTask:
 	$(CC) -o Module_PsuComm Module_PsuComm.o $(InfypwrPsuComm_A)
 
 ReadCmdlineTask:
-	$(CC) $(DEFINE) $(READCMDLINE_SRC_FILES) $(CFLAGS) $(TFLAGS) $(INC_FLAGS) -o ReadCmdline
+	$(CC) $(DEFINE) $(READCMDLINE_SRC_FILES) $(CFLAGS) $(TFLAGS) $(INC_FLAGS) $(SQLite3_H) $(Lib_SQLite3) -o ReadCmdline
 	#$(CC) $(DEFINE) $(CFLAGS) -c -o ReadCmdline.o ReadCmdline.c
 	#$(CC) -o ReadCmdline ReadCmdline.o
 

+ 15 - 8
EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.c

@@ -642,11 +642,15 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
             break;
 
         case MISC_CMD_BACKEND_STATUS :
-            ShmSelectGunInfo->EthDevStatus.Backend = value;
-            if (ShmSelectGunInfo->EthDevStatus.Backend == 0 ||
-                ShmSelectGunInfo->EthDevStatus.Backend == 2) {
-                log_info("!!!!!!!!!!!!!! Backend Disconnect !!!!!!!!!!!!!!");
+            if (ShmSelectGunInfo->EthDevStatus.Backend != value) {
+                if (value == 0 || value == 2) {
+                    log_info("!!!!!!!!!!!!!! Backend Disconnect !!!!!!!!!!!!!!");
+                } else {
+                    log_info("!!!!!!!!!!!!!! Backend Connect !!!!!!!!!!!!!");
+                }
             }
+            ShmSelectGunInfo->EthDevStatus.Backend = value;
+
             break;
 
         case MISC_CMD_ETHERNET_STATUS :
@@ -838,6 +842,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                 break;
             }
             gMoreInfoReq[plugNum].bits.ChargingBill = YES;
+            ShmDcCommonData->PriceBill.gunIndex = plugNum;
             break;
         default:
             clearMiscCommand();
@@ -1412,11 +1417,13 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
         ShmDcCommonData->Location = atoi(_stationInfo.StationName);
 
         CheckTaiwanEastWest(ShmDcCommonData->Location);
+        /*
         log_info("Station Name: %s, ID: %d, Weather: %d, Temperature: %.1f",
                 _stationInfo.StationName,
                 _stationInfo.StationID,
                 _stationInfo.WeatherID,
                 _stationInfo.Temperature);
+        */
         break;
 
     case REG_DEDUCT_INFO:
@@ -1587,12 +1594,12 @@ static int readRemoteStartNoIDState(int fd)
     return ret;
 }
 
-static int readChargingBill(int fd)
+static int readChargingBill(int fd,int gunID)
 {
     int ret = PASS;
 
     if ((ret = composeSocketData(fd,
-                                ID_REGISTER,
+                                gunID,
                                 OP_READ_DATA,
                                 REG_CHARGING_BILL,
                                 0,
@@ -2287,7 +2294,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
                     if (writeDispenserRequest(fd, gunID, plugNum) == PASS)
                     {
                         gConnectorActReq[plugNum].Value = 0;
-                        log_info("Gun %d CHARGING_CANCEL OK", plugNum);
+                        //log_info("Gun %d CHARGING_CANCEL OK", plugNum);
                         ShmDcCommonData->OperateIDLE[plugNum] = 0;
                         ShmDcCommonData->TransactionInfo[plugNum].LineStatus = _LINE_INIT;
                     }
@@ -2420,7 +2427,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
             if (gMoreInfoReq[plugNum].bits.ChargingBill) {
                 if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
                     DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
-                    if (readChargingBill(fd) == PASS)
+                    if (readChargingBill(fd, gunID) == PASS)
                     {
                         log_info("Need to rededuct Bill");
                         gMoreInfoReq[plugNum].bits.ChargingBill = false;

+ 1 - 1
EVSE/Projects/DD360Tcci/Apps/ModuleEvComm/AbnormalCCS.c

@@ -910,7 +910,7 @@ void ClearAbnormalStatus_CCS(uint8_t gun_index)
             }
         }
     }
-
+    pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gun_index);
     if (strncmp((char *)pDcChargingInfo->EvConnAlarmCode, "", 6) != EQUAL) {
         memcpy(pDcChargingInfo->EvConnAlarmCode, "", 6);
     }

+ 1 - 1
EVSE/Projects/DD360Tcci/Apps/ModuleEvComm/AbnormalCHA.c

@@ -244,7 +244,7 @@ void ClearAbnormalStatus_Chademo(uint8_t gun_index)
             }
         }
     }
-
+    pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gun_index);
     if (strncmp((char *)pDcChargingInfo->EvConnAlarmCode, "", 6) != EQUAL) {
         memcpy(pDcChargingInfo->EvConnAlarmCode, "", 6);
     }

+ 1 - 0
EVSE/Projects/DD360Tcci/Apps/ModuleEvComm/AbnormalGBT.c

@@ -413,6 +413,7 @@ void ClearAbnormalStatus_GB(uint8_t gun_index)
         }
     }
 
+    pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gun_index);
     if (strncmp((char *)pDcChargingInfo->EvConnAlarmCode, "", 6) != EQUAL) {
         memcpy(pDcChargingInfo->EvConnAlarmCode, "", 6);
     }

+ 19 - 17
EVSE/Projects/DD360Tcci/Apps/ModuleEvComm/Module_EvTxComm.c

@@ -328,29 +328,29 @@ void checkEachGunTypeOTP(int gunIndex, uint8_t Type, int derate_idx, struct DERA
 {
     struct ChargingInfoData* pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
     deratingByConnOtp->deratingIndex = derate_idx;
-    float pwr;
+    /*
+    log_info("RealMaxCurrent:[%.1f], AvailableChargingCurrent:[%.1f], BatteryTargetCurrent:[%.1f]",
+        pDcChargingInfo->RealMaxCurrent,
+        pDcChargingInfo->AvailableChargingCurrent,
+        pDcChargingInfo->EvBatterytargetCurrent);
+
+    log_info("RealMaxPower:[%.1f], AvailableChargingPower:[%.1f], BatteryTargetPower:[%.1f]",
+        pDcChargingInfo->RealMaxPower,
+        pDcChargingInfo->AvailableChargingPower,
+        pDcChargingInfo->EvBatterytargetVoltage * pDcChargingInfo->EvBatterytargetCurrent);
+    */
     switch (Type) {
-        // Derate by power
     case 'S':
-        if (pDcChargingInfo->RealMaxPower > deratingByConnOtp->deratingTargetRate[derate_idx]) {
-            pwr = pDcChargingInfo->EvBatterytargetCurrent * pDcChargingInfo->EvBatterytargetVoltage;
-
-            if (pwr > deratingByConnOtp->deratingTargetRate[derate_idx]) {
-                pDcChargingInfo->RealMaxPower *= deratingByConnOtp->deratingTargetRate[derate_idx];;
-            } else {
-                pDcChargingInfo->RealMaxPower = pwr;
-            }
+        // Derate by power
+        if (pDcChargingInfo->RealMaxPower > pDcChargingInfo->AvailableChargingPower) {
+            pDcChargingInfo->RealMaxPower = pDcChargingInfo->AvailableChargingPower * deratingByConnOtp->deratingTargetRate[derate_idx];
             log_info("Max Power derating to %.1f", pDcChargingInfo->RealMaxPower);
         }
         break;
-        // Derate by current
     default:
+        // Derate by current
         if (pDcChargingInfo->RealMaxCurrent > deratingByConnOtp->deratingTargetCurrent[derate_idx]) {
-            if (pDcChargingInfo->EvBatterytargetCurrent > deratingByConnOtp->deratingTargetCurrent[derate_idx]) {
-                pDcChargingInfo->RealMaxCurrent = deratingByConnOtp->deratingTargetCurrent[derate_idx];
-            } else {
-                pDcChargingInfo->RealMaxCurrent = pDcChargingInfo->EvBatterytargetCurrent;
-            }
+            pDcChargingInfo->RealMaxCurrent = deratingByConnOtp->deratingTargetCurrent[derate_idx];
             log_info("Max Current derating to %.1f", pDcChargingInfo->RealMaxCurrent);
         }
     }
@@ -376,8 +376,10 @@ static void CheckGunTypeOTP(void)
             } else {
                 derate_idx = 0;
             }
+            if (derate_idx != 0) {
+                checkEachGunTypeOTP(i, GunType, derate_idx, &pDcChargingInfo->deratingByConnOtp);
+            }
         }
-        checkEachGunTypeOTP(i, GunType, derate_idx, &pDcChargingInfo->deratingByConnOtp);
     }
 }
 static void SetPresentChargingOutputCap(void)

+ 25 - 4
EVSE/Projects/DD360Tcci/Apps/ModuleInternalComm/RelayBoard.c

@@ -1245,6 +1245,26 @@ static void GetFanSpeedByFunction(void)
         return;
     }
 
+    int gunIndex;
+    struct ChargingInfoData* pDcChargingInfo = NULL;
+    for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
+        pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
+        if ((pDcChargingInfo->SystemStatus > S_AUTHORIZING && pDcChargingInfo->SystemStatus < S_TERMINATING) ||
+            (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 && pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
+            ShmDcCommonData->FanOnTime = time((time_t*)NULL);
+            if (ShmFanModuleData->SetFan1Speed == 0) {
+                ShmFanModuleData->SetFan1Speed = 7000;
+                log_info("Set Fan speed 7000");
+            }
+        }
+    }
+
+    if ((time((time_t*)NULL) - ShmDcCommonData->FanOnTime) >= 600 &&
+        ShmFanModuleData->SetFan1Speed == 7000) {
+        ShmFanModuleData->SetFan1Speed = 0;
+        log_info("Close fan");
+    }
+
     // 風控修改 :
     // ******************************************************* //
     //
@@ -1253,7 +1273,7 @@ static void GetFanSpeedByFunction(void)
     //       當前樁最大功率 KW         45
     //
     // ******************************************************* //
-
+    /*
     // 當前樁最大功率 KW : ShmPsuData->SystemAvailablePower
     uint32_t _maxPower = ShmPsuData->SystemAvailablePower;
     // 當前PSU輸出總 KW & PSU Temp :
@@ -1302,6 +1322,7 @@ static void GetFanSpeedByFunction(void)
     if (ShmFanModuleData->TestFanSpeed < 0) {
         ShmFanModuleData->TestFanSpeed = 0;
     }
+    */
 //
 //  printf("power = %f \n", power);
 //  printf("_maxPower = %d \n", _maxPower);
@@ -1403,16 +1424,16 @@ static void fanBoardPorcess(void)
 
         if (GetTimeoutValue(gFanBoardRunTimer) / 1000 >= 1000) {
             //GetPsuTempForFanSpeed();
-            GetFanSpeedByFunction();
+            //GetFanSpeedByFunction();
             GetFanSpeed();
             pSysInfo->SystemFanRotaSpeed = _setFanSpeed;
             gettimeofday(&gFanBoardRunTimer, NULL);
-
+            /*
             ShmFanModuleData->SetFan1Speed = ShmFanModuleData->TestFanSpeed;
             ShmFanModuleData->SetFan2Speed = ShmFanModuleData->TestFanSpeed;
             ShmFanModuleData->SetFan3Speed = ShmFanModuleData->TestFanSpeed;
             ShmFanModuleData->SetFan4Speed = ShmFanModuleData->TestFanSpeed;
-
+            */
             //log_info("set fan = %d ", ShmFanModuleData->SetFan1Speed);
             SetFanModuleSpeed();
         }

+ 76 - 24
EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.c

@@ -313,10 +313,12 @@ void TradeRunning(uint8_t _run)
         ChangeDisplay2Value(_Icon_CountDownBG, 0);
         ChangeDisplay2Value(_Icon_CancelCntDownTen, 0);
         ChangeDisplay2Value(_Icon_CancelCntDownDigits, 0);
+        ChangeDisplay2Value(_Icon_PreAuthWord, _TCC_PreAuthWord);
     }
     else {
         ChangeDisplay2Value(_Icon_PreAuth, _TCC_TradeCancelString);
         ChangeDisplay2Value(_Icon_Ani_Dot, 0);
+        ChangeDisplay2Value(_Icon_PreAuthWord, 0);
         ChangeDisplay2Value(_Icon_CountDownBG, _TCC_TradeCancelFrame);
         if (pSysInfo->SystemTimeoutFlag == Timeout_TradeCancel) {
             unsigned long _time = TCC_TRADECANCEL_TIMEOUT-(GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL);
@@ -327,9 +329,29 @@ void TradeRunning(uint8_t _run)
     }
 }
 
+static void systemPageRestoreInit(void)
+{
+    int is_idle = TRUE;
+    int gunIndex;
+    for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
+        pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
+        // 檢查電樁狀態是否為idle狀態
+        if ((pDcChargingInfo->SystemStatus >= S_AUTHORIZING &&
+            pDcChargingInfo->SystemStatus <= S_RESERVATION) ||
+            (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
+                pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST0)) {
+            is_idle = FALSE;
+        }
+    }
+    if (is_idle)
+        pSysInfo->SystemPage = _PAGE_IDLE;
+    else
+        pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+}
+
 void CheckIdlePress()
 {
-    pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+    systemPageRestoreInit();
     log_info("IDLE Enter Select Gun Page");
 }
 void CheckReturnPress()
@@ -371,8 +393,9 @@ void CheckReturnPress()
             ShmDcCommonData->PreAuth_Result = 0;
         }
         StopSystemTimeoutDet();
-        pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+
         pDcChargingInfo->SystemStatus = S_IDLE;
+        systemPageRestoreInit();
 		strcpy((char *)pSysConfig->UserId, "");
 		return;
 	}
@@ -380,17 +403,14 @@ void CheckReturnPress()
 	if ( pSysInfo->SystemPage == _PAGE_EXIT ) {
         StopGunInfoTimeoutDet(pSysInfo->CurGunSelected);
 		pDcChargingInfo->SystemStatus = S_IDLE;
-        if (ShmDcCommonData->TaiwanEast)
-            pSysInfo->SystemPage = _PAGE_IDLE;
-        else
-            pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+
 		return;
 	}
 
     if (pSysInfo->SystemPage == _PAGE_AUTHORIZE)
         pSysInfo->SystemPage = _PAGE_SELECT_PAY;
     else
-        pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+        systemPageRestoreInit();
 }
 void CheckStopPress()
 {
@@ -454,6 +474,8 @@ void CheckPayCreditCard()
     //ShmDcCommonData->LineStatus[pSysInfo->CurGunSelected] = 0;
     // 使用者進入線上支付,禁止使用者使用刷卡機
     if (ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].LineStatus == _LINE_PAY_OPERATE) {
+        pSysInfo->SystemPage = _PAGE_LINEPAYING;
+        StartSystemTimeoutDet(Timeout_LINEPAYING);
         log_info("Some one operate LINE PAY");
         return;
     }
@@ -498,13 +520,13 @@ void CheckTouchPress(short id)
         	if(pSysInfo->CurGunSelected != LEFT_GUN_NUM) {
         		pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
                 if (pDcChargingInfo->SystemStatus == S_RESERVATION) {
-                    pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+                    systemPageRestoreInit();
                     log_info("Can't select Reservation Gun");
                     break;
                 }
         		pSysInfo->CurGunSelected = LEFT_GUN_NUM;
                 if(pDcChargingInfo->SystemStatus == S_IDLE) {
-                	pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+                    systemPageRestoreInit();
                 }
 				log_info("LCM left Gun down...............................%x %x %x",
 						pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
@@ -513,8 +535,6 @@ void CheckTouchPress(short id)
         	if (pSysInfo->SystemPage == _PAGE_CHARGING || pSysInfo->SystemPage == _PAGE_COMPLETE ||
         			pSysInfo->SystemPage == _PAGE_PAYFAIL) {
 				StopSystemTimeoutDet();
-                if (ShmDcCommonData->TaiwanEast)
-                    StartSystemTimeoutDet(Timeout_ReturnViewPage);
         	}
             break;
         case _Touch_Show_Right:
@@ -526,13 +546,13 @@ void CheckTouchPress(short id)
 			if(pSysInfo->CurGunSelected != RIGHT_GUN_NUM) {
 				pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
                 if (pDcChargingInfo->SystemStatus == S_RESERVATION) {
-                    pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+                    systemPageRestoreInit();
                     log_info("Can't select Reservation Gun");
                     break;
                 }
 				pSysInfo->CurGunSelected = RIGHT_GUN_NUM;
 	            if(pDcChargingInfo->SystemStatus == S_IDLE) {
-	            	pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+                    systemPageRestoreInit();
 	            }
 				log_info("LCM Right Gun down...............................%x %x %x",
 						pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
@@ -541,8 +561,6 @@ void CheckTouchPress(short id)
         	if (pSysInfo->SystemPage == _PAGE_CHARGING || pSysInfo->SystemPage == _PAGE_COMPLETE ||
         			pSysInfo->SystemPage == _PAGE_PAYFAIL) {
 				StopSystemTimeoutDet();
-                if (ShmDcCommonData->TaiwanEast)
-                    StartSystemTimeoutDet(Timeout_ReturnViewPage);
         	}
             break;
         case _Touch_Return:
@@ -605,7 +623,9 @@ void CheckLCMPressed()
         	}
             switch (pSysInfo->SystemPage) {
             case _PAGE_IDLE:
-				CheckTouchPress(_Touch_IDLE);
+				//CheckTouchPress(_Touch_IDLE);
+                CheckTouchPress(_Touch_Select_Left);
+                CheckTouchPress(_Touch_Select_Right);
                 break;
             case _PAGE_SELECT_GUN:
 				CheckTouchPress(_Touch_Select_Left);
@@ -804,10 +824,10 @@ void ChangeCurPage()
             break;
         }
         _currentPage = pSysInfo->PageIndex;
-        /*
-        if (pSysInfo->PageIndex != _PAGE_IDLE)
-            log_info("Gun[%d] Chagne LCM Page:%d",pSysInfo->CurGunSelected, pSysInfo->PageIndex);
-        */    
+        
+        //if (pSysInfo->PageIndex != _PAGE_IDLE)
+        //log_info("Gun[%d] Chagne LCM Page:%d",pSysInfo->CurGunSelected, pSysInfo->PageIndex);
+            
         ChangeToOtherPage(pSysInfo->PageIndex);
     }
 }
@@ -1221,6 +1241,33 @@ void ShowAuthorizeCountDown()
         log_info("Not get Line Register Count Down");
     }
 }
+void changeGunType()
+{
+    pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(LEFT_GUN_NUM);
+    if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
+        pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
+        ChangeDisplay2Value(_Icon_Select_Left, _TCC_IDLE_LEFT_CCS1);
+
+    } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
+        pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
+        ChangeDisplay2Value(_Icon_Select_Left, _TCC_IDLE_LEFT_CCS2);
+    } else if (pDcChargingInfo->Type == _Type_Chademo) {
+        ChangeDisplay2Value(_Icon_Select_Left, _TCC_IDLE_LEFT_CHAdeMo);
+    }
+
+    // Set Right Gun
+    pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(RIGHT_GUN_NUM);
+    if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
+        pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
+        ChangeDisplay2Value(_Icon_Select_Right, _TCC_IDLE_RIGHT_CCS1);
+
+    } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
+        pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
+        ChangeDisplay2Value(_Icon_Select_Right, _TCC_IDLE_RIGHT_CCS2);
+    } else if (pDcChargingInfo->Type == _Type_Chademo) {
+        ChangeDisplay2Value(_Icon_Select_Right, _TCC_IDLE_RIGHT_CHAdeMo);
+    }
+}
 int old_money = 0;
 int ClearQR_flag[2];
 void ProcessPageInfo()
@@ -1229,14 +1276,18 @@ void ProcessPageInfo()
         pSysInfo->SystemPage = _PAGE_PAYING;
     }
     // Show Gun Working and Type
+    
     if (pSysInfo->SystemPage == _PAGE_IDLE) {
     	changeWeatherValue(ShmDcCommonData->WeatherID);
     	changeWeekValue(0);
     	changeDegreeValue((int)ShmDcCommonData->Temperature);
     	changeDateValue(&ShmDcCommonData->PresentTime[0]);
-    	changeLocationValue(1001);
+    	changeLocationValue(1000);
+        changeGunType();
+        ClearQR_flag[pSysInfo->CurGunSelected] = FALSE;
     	return;
     }
+    
     if (pSysInfo->SystemPage == _PAGE_MAINTAIN) {
 
         pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
@@ -1274,7 +1325,8 @@ void ProcessPageInfo()
 
             switch (pSysInfo->SystemPage) {
             case _PAGE_IDLE:
-                StopSystemTimeoutDet();
+                ShowSelectGun();
+                ClearQR_flag[i] = FALSE;
             	break;
             case _PAGE_SELECT_PAY:
             	if (ShmDcCommonData->TransactionInfo[i].IsDonateInvoice == TRUE) {
@@ -1351,8 +1403,8 @@ void ProcessPageInfo()
                 	ChangeTimeValue(0);
                 }
                 ChangeBattMapAndValue(pDcChargingInfo->EvBatterySoc);
-                if (ShmDcCommonData->TaiwanEast)
-                    StartSystemTimeoutDet(Timeout_ReturnViewPage);
+                
+                StartSystemTimeoutDet(Timeout_ReturnViewPage);
                 break;
             case _PAGE_COMPLETE:
             case _PAGE_PAYFAIL:

+ 9 - 1
EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.h

@@ -105,6 +105,8 @@
 #define _Icon_AuthCntDownTen    0x106A
 #define _Icon_AuthCntDownDigits 0x106C
 #define _Icon_Uploading         0x1070
+#define _Icon_DAKAWelcome       0x1072
+#define _Icon_PreAuthWord       0x1074
 
 #define _String_Date			0x3000
 #define _String_Tempture		0x3010
@@ -330,7 +332,7 @@ enum _TCC_ICON_LIST_ {
 	_TCC_SelectPayMode,
 	_TCC_CreditCard_Wifi,
 	_TCC_CreditCard_Frame,
-	_TCC_iCash,
+	_TCC_PreAuthWord,
 	_TCC_LinePay,
 	_TCC_CardSensing_Frame,
 	_TCC_PreAuth,
@@ -370,6 +372,12 @@ enum _TCC_ICON_LIST_ {
 	_TCC_SecondSense,
 	_TCC_CntDownNumber0,
 	_TCC_Uploading = 323,
+	_TCC_IDLE_LEFT_CCS1,
+	_TCC_IDLE_LEFT_CCS2,
+	_TCC_IDLE_LEFT_CHAdeMo,
+	_TCC_IDLE_RIGHT_CCS1,
+	_TCC_IDLE_RIGHT_CCS2,
+	_TCC_IDLE_RIGHT_CHAdeMo,
 };
 
 

+ 14 - 4
EVSE/Projects/DD360Tcci/Apps/ModulePrimary/Module_PrimaryComm.c

@@ -188,16 +188,20 @@ static void checkChillerStatus(Gpio_out *gpio)
     struct ChargingInfoData *pDcChargingInfo = NULL;
     static ChillerInfo fChillerInfo[2] = {0}, *pChillerInfo = NULL;
     static ChillerInfo _chiller;
+    struct FanModuleData* ShmFanModuleData = (struct FanModuleData*)GetShmFanModuleData();
+    DcCommonInfo* ShmDcCommonData = (DcCommonInfo*)GetShmDcCommonData();
     Gpio_out *pGpio = (Gpio_out *)gpio;
 
-    if ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
-            (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0)) {
+    if ((strncmp((char*)&pSysConfig->ModelName[7], "V", 1) == 0) ||
+        (strncmp((char*)&pSysConfig->ModelName[7], "F", 1) == 0)) {
         chillerCount++;
+        ShmDcCommonData->pGunInfo[0].withChiller = TRUE;
     }
 
-    if ((strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
-            (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0)) {
+    if ((strncmp((char*)&pSysConfig->ModelName[9], "V", 1) == 0) ||
+        (strncmp((char*)&pSysConfig->ModelName[9], "F", 1) == 0)) {
         chillerCount++;
+        ShmDcCommonData->pGunInfo[1].withChiller = TRUE;
     }
 
     if (chillerCount == 0) {
@@ -206,6 +210,8 @@ static void checkChillerStatus(Gpio_out *gpio)
     }
 
     for (gunIndex = 0; gunIndex < chillerCount; gunIndex++) {
+        if (!ShmDcCommonData->pGunInfo[gunIndex].withChiller)
+            continue;
         pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
         pChillerInfo = (ChillerInfo *)&fChillerInfo[gunIndex];
 
@@ -223,11 +229,13 @@ static void checkChillerStatus(Gpio_out *gpio)
                 if ((time((time_t *)NULL) - pChillerInfo->ChillerOnTime) >= 600)
                 {
                     pChillerInfo->ChillerSwitch = NO;
+                    ShmFanModuleData->SetFan1Speed = 0;
                 }
             }
             else
             {
                 pChillerInfo->ChillerSwitch = NO;
+                ShmFanModuleData->SetFan1Speed = 0;
             }
         }
 /*
@@ -260,6 +268,8 @@ static void checkChillerStatus(Gpio_out *gpio)
         if(pChillerInfo->ChillerSwitch == YES)
         {
             _chillerNeedOn = YES;
+            ShmFanModuleData->SetFan1Speed = 7000;
+
         }
     }
     if (ShmDcCommonData->DebugFlag == YES) 

+ 25 - 0
EVSE/Projects/DD360Tcci/Apps/ReadCmdline.c

@@ -43,6 +43,7 @@
 #include "./SelectGun/SelectGun.h"
 #include "Config.h"
 #include "./CSU/main.h"
+#include "./DataBase/DataBase.h"
 
 //------------------------------------------------------------------------------
 #define CMD_KEY_WAIT                                (1)
@@ -544,6 +545,19 @@ void showlcmtest()
         printf("LCM Test off\n");
 
 }
+
+void setbilltest(char* v1,char* v2)
+{
+    int Txid = atoi(v1);
+    float amount = atof(v2);
+    if (Txid != 0 && amount > 0) {
+        printf("Set Transcation ID:%d, amount:%.1f\n", Txid, amount);
+        UpdateRedeuctBill(Txid, amount);
+    } else {
+        printf("Bill Error Data\n");
+    }
+}
+
 void SetFanSpeed(char *v1)
 {
     int speed = atoi(v1);
@@ -1294,6 +1308,8 @@ int main(void)
                      "       preauth                           : Credit Card PreAuth\n"
                      "       preauthcancel                     : Credit Card PreAuth Cancel\n"
                      "       tccdev                            : print TCC dev QR Code\n"
+                     "       lcmtest                           : Only For LCM Demo\n"
+                     "       billtest                          : Rededuct Transcation id amount\n"
                      "\r\n";
 
     if (CreateAllCsuShareMemory() == FAIL) {
@@ -1482,6 +1498,15 @@ int main(void)
             writeTccdev();
         } else if (strcmp(newString[0], "lcmtest") == 0) { 
             showlcmtest();
+        } else if (strcmp(newString[0], "billtest") == 0) {
+            if (strcmp(newString[1], "-1") == 0 ||
+                strcmp(newString[1], "") == 0 ||
+                strcmp(newString[2], "-1") == 0 ||
+                strcmp(newString[2], "") == 0) {
+                printf("Input cmd fail ------  billtest [txid] [aount]\n");
+                continue;
+            }
+            setbilltest(newString[1], newString[2]);
         } else {
             printf("%s\n", usageMsg);
         }

+ 1 - 1
EVSE/Projects/DD360Tcci/Apps/ShareMemory/shmMem.c

@@ -515,7 +515,7 @@ void InitialShareMemoryInfo(void)
     memset(pSysInfo->FanModuleFwRev, 0, ARRAY_SIZE(pSysInfo->FanModuleFwRev));
     memset(pSysInfo->RelayModuleFwRev, 0, ARRAY_SIZE(pSysInfo->RelayModuleFwRev));
 
-    pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+    pSysInfo->SystemPage = _PAGE_IDLE;
 
     pSysInfo->MainChargingMode = _MAIN_CHARGING_MODE_MAX;
     pSysInfo->ReAssignedFlag = _REASSIGNED_NONE;

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

@@ -63,6 +63,7 @@ enum Timeout_flag {
     Timeout_ExitPage               = 26,
     Timeout_isPlugout              = 27,
     Timeout_TradeCancel            = 28,
+    Timeout_LINEPAYING             = 29,
 };
 
 //------------------------------------------------------------------------------

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


BIN
EVSE/Projects/DD360Tcci/output/FactoryConfig


BIN
EVSE/Projects/DD360Tcci/output/Module_ChkSysTask


BIN
EVSE/Projects/DD360Tcci/output/Module_DoComm


BIN
EVSE/Projects/DD360Tcci/output/Module_EvComm


BIN
EVSE/Projects/DD360Tcci/output/Module_EventLogging


BIN
EVSE/Projects/DD360Tcci/output/Module_InternalComm


BIN
EVSE/Projects/DD360Tcci/output/Module_LcmControl


BIN
EVSE/Projects/DD360Tcci/output/Module_PrimaryComm


BIN
EVSE/Projects/DD360Tcci/output/Module_UpdateFW


BIN
EVSE/Projects/DD360Tcci/output/ReadCmdline


BIN
EVSE/Projects/DD360Tcci/output/main


+ 447 - 0
EVSE/Projects/DD360UCar/Apps/Module_LcmControl_Wistron/LcmCommandDriver.c

@@ -0,0 +1,447 @@
+/*
+ * LcmCommandDriver.c
+ *
+ *  Created on: 2022/3/31
+ *      Author: folus
+ */
+
+#include "Module_LcmControl_Wistron.h"
+
+/**
+ *
+ * @param mosq
+ * @param topic
+ * @param outputStr
+ * @return
+ */
+int publish_data(struct mosquitto *mosq, char *topic, char *outputStr)
+{
+	int result;
+
+	result = mosquitto_publish(mosq, NULL, topic, strlen(outputStr), outputStr, QOS_ENSURE_BROKER, RETAIN_NO);
+
+	if(result != MOSQ_ERR_SUCCESS)DEBUG_ERROR("Publish %s error publishing: %s\n", topic, mosquitto_strerror(result));
+
+	return (result != MOSQ_ERR_SUCCESS)?FAIL:PASS;
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_profile(struct mosquitto *mosq, char *parameter, char *value)
+{
+	json_object *payload = json_object_new_object();
+	char outputStr[2048]={0};
+
+	json_object_object_add(payload, parameter, json_object_new_string(value));
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/profile", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_upgrade(struct mosquitto *mosq, char *otaType, char *url, char *checksum, char *verInfo)
+{
+	json_object *payload = json_object_new_object();
+	char outputStr[2048]={0};
+
+	json_object_object_add(payload, "task_name", json_object_new_string(otaType));
+
+	if((strstr(otaType, OTA_TYPE_APK) != NULL) || (strstr(otaType, OTA_TYPE_UI) != NULL))
+		json_object_object_add(payload, "ftp server", json_object_new_string(url));
+
+	if(strstr(otaType, OTA_TYPE_UI) != NULL)
+	{
+		json_object_object_add(payload, "file_checksum", json_object_new_string(checksum));
+		json_object_object_add(payload, "version_info", json_object_new_string(verInfo));
+	}
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/command", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_restart(struct mosquitto *mosq, uint8_t isHardReset)
+{
+	json_object *payload = json_object_new_object();
+	char outputStr[2048]={0};
+
+	json_object_object_add(payload, "task_name", json_object_new_string(isHardReset?"restart":"reset"));
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/command", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_power_saving(struct mosquitto *mosq, uint8_t isSleep)
+{
+	if(isSleep)
+	{
+		json_object *payload = json_object_new_object();
+		char outputStr[2048]={0};
+
+		json_object_object_add(payload, "task_name", json_object_new_string("power_saving"));
+		json_object_object_add(payload, "mode", json_object_new_string(isSleep?"1":"0"));
+
+		sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+		json_object_put(payload);
+
+		return publish_data(mosq, "client/command", outputStr);
+	}
+	else
+	{
+		char cmd[64];
+		sprintf(cmd, "/usr/sbin/ether-wake -i eth0 %s", clientInfo.macAddr);
+		system(cmd);
+
+		return PASS;
+	}
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_back_dimming(struct mosquitto *mosq, uint8_t lightLevel)
+{
+	json_object *payload = json_object_new_object();
+	char outputStr[2048]={0};
+	char buf[8];
+
+	json_object_object_add(payload, "task_name", json_object_new_string("backlight"));
+
+	sprintf(buf, "%d", lightLevel);
+	json_object_object_add(payload, "brightness", json_object_new_string(buf));
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/command", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_audio_volume(struct mosquitto *mosq, uint8_t volume)
+{
+	json_object *payload = json_object_new_object();
+	char outputStr[2048]={0};
+	char buf[8];
+
+	json_object_object_add(payload, "task_name", json_object_new_string("audio_volume"));
+
+	sprintf(buf, "%d", volume);
+	json_object_object_add(payload, "volume", json_object_new_string(buf));
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/command", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_trigger_report_status(struct mosquitto *mosq)
+{
+	json_object *payload = json_object_new_object();
+	char outputStr[2048]={0};
+
+	json_object_object_add(payload, "task_name", json_object_new_string("report_status"));
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/command", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_timesync(struct mosquitto *mosq)
+{
+	char outputStr[64]={0};
+	time_t CurrentTime;
+	struct tm *tm;
+	struct timeval tv;
+
+	CurrentTime = time(NULL);
+	tm=localtime(&CurrentTime);
+	gettimeofday(&tv, NULL); // get microseconds, 10^-6
+
+	sprintf(outputStr,"%04d-%02d-%02dT%02d:%02d:%02d+00:00", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec);
+
+	return publish_data(mosq, "client/timesync", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_textview_add(struct mosquitto *mosq, Text_List *textList, uint8_t listCount)
+{
+	json_object *payload = json_object_new_array();
+	char outputStr[2048]={0};
+
+	for(int idx=0;idx<listCount;idx++)
+	{
+		json_object *textview = json_object_new_object();
+		char buf[32];
+
+		sprintf(buf, "%d", textList[idx].textviewIndex);
+		json_object_object_add(textview, "textviewIndex", json_object_new_string(buf));
+
+		json_object_object_add(textview, "textString", json_object_new_string(textList[idx].textString));
+		json_object_object_add(textview, "textFont", json_object_new_string(textList[idx].textFont));
+		json_object_object_add(textview, "textStyle", json_object_new_string(textList[idx].textStyle));
+
+		sprintf(buf, "%d", textList[idx].textSize);
+		json_object_object_add(textview, "textSize", json_object_new_string(buf));
+		sprintf(buf, "%d", textList[idx].layout_x);
+		json_object_object_add(textview, "layout_x", json_object_new_string(buf));
+		sprintf(buf, "%d", textList[idx].layout_y);
+		json_object_object_add(textview, "layout_y", json_object_new_string(buf));
+
+		json_object_array_add(payload, textview);
+	}
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/layout/textview", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_imageview_add(struct mosquitto *mosq, Image_List *imageList, uint8_t listCount)
+{
+	json_object *payload = json_object_new_array();
+	char outputStr[2048]={0};
+
+	for(int idx=0;idx<listCount;idx++)
+	{
+		json_object *imageview = json_object_new_object();
+		char buf[32];
+
+		sprintf(buf, "%d", imageList[idx].imageviewIndex);
+		json_object_object_add(imageview, "imageviewIndex", json_object_new_string(buf));
+
+		sprintf(buf, "%d", imageList[idx].imgsrc_addr);
+		json_object_object_add(imageview, "imgsrc_addr", json_object_new_string(buf));
+
+		sprintf(buf, "%d", imageList[idx].layout_x);
+		json_object_object_add(imageview, "layout_x", json_object_new_string(buf));
+
+		sprintf(buf, "%d", imageList[idx].layout_y);
+		json_object_object_add(imageview, "layout_y", json_object_new_string(buf));
+
+		sprintf(buf, "%d", imageList[idx].width);
+		json_object_object_add(imageview, "width", json_object_new_string(buf));
+
+		sprintf(buf, "%d", imageList[idx].height);
+		json_object_object_add(imageview, "height", json_object_new_string(buf));
+
+		json_object_array_add(payload, imageview);
+	}
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/layout/imageview", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_videoview_add(struct mosquitto *mosq, Video_List *videoList, uint8_t listCount)
+{
+	json_object *payload = json_object_new_array();
+	char outputStr[2048]={0};
+
+	for(int idx=0;idx<listCount;idx++)
+	{
+		json_object *imageview = json_object_new_object();
+		char buf[32];
+
+		sprintf(buf, "%d", videoList[idx].videoviewIndex);
+		json_object_object_add(imageview, "videoviewIndex", json_object_new_string(buf));
+
+		sprintf(buf, "%d", videoList[idx].videosrc_addr);
+		json_object_object_add(imageview, "videoSrc_addr", json_object_new_string(buf));
+
+		sprintf(buf, "%d", videoList[idx].layout_x);
+		json_object_object_add(imageview, "layout_x", json_object_new_string(buf));
+
+		sprintf(buf, "%d", videoList[idx].layout_y);
+		json_object_object_add(imageview, "layout_y", json_object_new_string(buf));
+
+		sprintf(buf, "%d", videoList[idx].width);
+		json_object_object_add(imageview, "width", json_object_new_string(buf));
+
+		sprintf(buf, "%d", videoList[idx].height);
+		json_object_object_add(imageview, "height", json_object_new_string(buf));
+
+		json_object_array_add(payload, imageview);
+	}
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/layout/videoview", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_qrcodeimage_add(struct mosquitto *mosq, QrCode_List *qrCodeList, uint8_t listCount)
+{
+	json_object *payload = json_object_new_array();
+	char outputStr[2048]={0};
+
+	for(int idx=0;idx<listCount;idx++)
+	{
+		json_object *qrcodeImage = json_object_new_object();
+		char buf[32];
+
+		sprintf(buf, "%d", qrCodeList[idx].qrCodeIndex);
+		json_object_object_add(qrcodeImage, "qrCodeIndex", json_object_new_string(buf));
+
+		sprintf(buf, "%s", qrCodeList[idx].qrCodeContent);
+		json_object_object_add(qrcodeImage, "qrCodeContent", json_object_new_string(buf));
+
+		sprintf(buf, "%s", qrCodeList[idx].errorCorrection);
+		json_object_object_add(qrcodeImage, "errorCorrection", json_object_new_string(buf));
+
+		sprintf(buf, "%d", qrCodeList[idx].layout_x);
+		json_object_object_add(qrcodeImage, "layout_x", json_object_new_string(buf));
+
+		sprintf(buf, "%d", qrCodeList[idx].layout_y);
+		json_object_object_add(qrcodeImage, "layout_y", json_object_new_string(buf));
+
+		sprintf(buf, "%d", qrCodeList[idx].width);
+		json_object_object_add(qrcodeImage, "width", json_object_new_string(buf));
+
+		sprintf(buf, "%d", qrCodeList[idx].height);
+		json_object_object_add(qrcodeImage, "height", json_object_new_string(buf));
+
+		json_object_array_add(payload, qrcodeImage);
+	}
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/layout/qrcodeview", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_view_remove(struct mosquitto *mosq, Text_List *textList, uint8_t textListCount,
+												Image_List *imageList, uint8_t imageListCount,
+												Video_List *videoList, uint8_t videoListCount,
+												QrCode_List *qrCodeList, uint8_t qrCodeListCount)
+{
+	json_object *payload = json_object_new_object();
+	json_object *text = json_object_new_array();
+	json_object *image = json_object_new_array();
+	json_object *video = json_object_new_array();
+	json_object *qrCode = json_object_new_array();
+
+	char outputStr[2048]={0};
+
+	// Remove text view
+	for(int idx=0;idx<textListCount;idx++)
+	{
+		json_object *textview = json_object_new_object();
+		char buf[8];
+		sprintf(buf, "%d", textList[idx].textviewIndex);
+		json_object_object_add(textview, "textviewIndex", json_object_new_string(buf));
+
+		json_object_array_add(text, textview);
+	}
+	json_object_object_add(payload, "rm_textview_list", text);
+
+	// Remove image view
+	for(int idx=0;idx<imageListCount;idx++)
+	{
+		json_object *imageview = json_object_new_object();
+		char buf[8];
+		sprintf(buf, "%d", imageList[idx].imageviewIndex);
+		json_object_object_add(imageview, "imageviewIndex", json_object_new_string(buf));
+
+		json_object_array_add(image, imageview);
+	}
+	json_object_object_add(payload, "rm_imageview_list", image);
+
+	// Remove video view
+	for(int idx=0;idx<videoListCount;idx++)
+	{
+		json_object *videoview = json_object_new_object();
+		char buf[8];
+		sprintf(buf, "%d", videoList[idx].videoviewIndex);
+		json_object_object_add(videoview, "videoviewIndex", json_object_new_string(buf));
+
+		json_object_array_add(video, videoview);
+	}
+	json_object_object_add(payload, "rm_videoview_list", video);
+
+	// Remove qrCode view
+	for(int idx=0;idx<qrCodeListCount;idx++)
+	{
+		json_object *qrCodeview = json_object_new_object();
+		char buf[8];
+		sprintf(buf, "%d", qrCodeList[idx].qrCodeIndex);
+		json_object_object_add(qrCodeview, "qrCodeIndex", json_object_new_string(buf));
+
+		json_object_array_add(qrCode, qrCodeview);
+	}
+	json_object_object_add(payload, "rm_qrcode_list", qrCode);
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/layout/remove", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_clear_screen(struct mosquitto *mosq)
+{
+	json_object *payload = json_object_new_object();
+	char outputStr[2048]={0};
+
+	json_object_object_add(payload, "task_name", json_object_new_string("clear_screen"));
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/command", outputStr);
+}
+
+

+ 1179 - 0
EVSE/Projects/DD360UCar/Apps/Module_LcmControl_Wistron/Module_LcmControl_Wistron.c

@@ -0,0 +1,1179 @@
+/*
+ * Module_LcmControl_Wistron.c
+ *
+ *  Created on: 2021/11/6
+ *      Author: folus
+ */
+
+#include "Module_LcmControl_Wistron.h"
+#include "../Log/log.h"
+#include "../ShareMemory/shmMem.h"
+#include "../Define/define.h"
+#include "../Config.h"
+#include "../SelectGun/SelectGun.h"
+#include "main.h"
+
+struct SysConfigAndInfo			*ShmSysConfigAndInfo;
+struct StatusCodeData 			*ShmStatusCodeData;
+struct OCPP16Data				*ShmOCPP16Data;
+struct OCPP20Data				*ShmOCPP20Data;
+
+//ParsingRatedCur modelnameInfo	= {0};
+uint8_t gunType[4] 				= {0};
+
+struct timespec					timer[TMR_IDX_CNT];
+
+/**
+ *
+ * @param fmt
+ * @return
+ */
+/*
+int StoreLogMsg(const char *fmt, ...)
+{
+	char Buf[4096+256];
+	char buffer[4096];
+	time_t CurrentTime;
+	struct tm *tm;
+	struct timeval tv;
+	va_list args;
+
+	va_start(args, fmt);
+	int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
+	va_end(args);
+
+	memset(Buf,0,sizeof(Buf));
+	CurrentTime = time(NULL);
+	tm=localtime(&CurrentTime);
+	gettimeofday(&tv, NULL); // get microseconds, 10^-6
+
+	sprintf(Buf,"echo -n \'[%04d.%02d.%02d %02d:%02d:%02d.%03ld]%s\' >>  /Storage/SystemLog/[%04d.%02d]Module_LcmControl_Wistron_Log",
+			tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,(tv.tv_usec/1000),
+			buffer,
+			tm->tm_year+1900,tm->tm_mon+1);
+
+#ifdef SystemLogMessage
+	system((const char*)Buf);
+#endif
+
+#ifdef ConsloePrintLog
+	printf("[%04d.%02d.%02d %02d:%02d:%02d.%03ld]%s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,(tv.tv_usec/1000), buffer);
+#endif
+
+	return rc;
+}
+*/
+/**
+ *
+ * @param data
+ * @param length
+ * @return
+ */
+uint32_t crc32(uint8_t *data, uint32_t length)
+{
+	uint32_t crc=0xFFFFFFFF;
+
+	for(size_t i=0;i<length;i++)
+	{
+		char ch=data[i];
+		for(size_t j=0;j<8;j++)
+		{
+			uint32_t b=(ch^crc)&1;
+
+			crc>>=1;
+
+			if(b) crc=crc^0xEDB88320;
+
+			ch>>=1;
+		}
+	}
+
+	return ~crc;
+}
+
+/**
+ *
+ * @param filename
+ * @return
+ */
+uint32_t getFileCrc32(char *filename)
+{
+	uint32_t result = 0;
+
+	int fd = open(filename, O_RDONLY);
+    if(fd < 0)
+    {
+        DEBUG_ERROR("Can not open file %s\n", filename);
+    }
+    else
+    {
+    	struct stat st;
+		stat(filename, &st);
+		uint8_t *data;
+		data = malloc(st.st_size);
+
+		if(read(fd,data,st.st_size) == st.st_size)
+		{
+			result = crc32(data, st.st_size);
+			close(fd);
+		} else {
+			DEBUG_ERROR("Read file Error %d\n", st.st_size);
+		}
+
+		free(data);
+    }
+
+	return result;
+}
+
+/**
+ *
+ * @param timer
+ */
+void refreshStartTimer(struct timespec *timer)
+{
+	clock_gettime(CLOCK_MONOTONIC, timer);
+}
+
+/**
+ *
+ * @param timer
+ * @return
+ */
+int getDiffSecNow(struct timespec timer)
+{
+	struct timespec timerNow;
+
+	clock_gettime(CLOCK_MONOTONIC, &timerNow);
+
+	return (int)((((unsigned long)(timerNow.tv_sec - timer.tv_sec) * 1000) + ((unsigned long)((timerNow.tv_nsec / 1000000) - (timer.tv_nsec / 1000000))))/1000);
+}
+
+/**
+ *
+ * @return
+ */
+/*
+int InitShareMemory()
+{
+	int result = PASS;
+	int MeterSMId;
+
+	//Initial ShmSysConfigAndInfo
+	if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
+    {
+		DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
+		result = FAIL;
+	}
+    else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+    {
+    	DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
+    	result = FAIL;
+   	}
+    else
+    {}
+
+   	// Initial ShmStatusCodeData
+   	if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
+    {
+   		DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
+   		result = FAIL;
+	}
+    else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+    {
+    	DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
+    	result = FAIL;
+   	}
+    else
+    {}
+
+	// Initial ShmOCPP16Data
+	if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data), 0777)) < 0)
+	{
+		DEBUG_ERROR("shmget ShmOCPP16Data NG\n");
+		result = FAIL;
+	}
+	else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+	{
+		DEBUG_ERROR("shmat ShmOCPP16Data NG\n");
+		result = FAIL;
+	}
+	else
+	{}
+
+	// Initial ShmOCPP20Data
+	if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
+	{
+		DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
+		result = FAIL;
+	}
+	else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+	{
+		DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
+		result = FAIL;
+	}
+	else
+	{}
+
+	// Parsing model name to get related info about charger
+	if(RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo) != -1)
+	{
+		DEBUG_INFO("Model name rated power: %d\n", modelnameInfo.ratedPower);
+		if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
+		   ((ShmSysConfigAndInfo->SysConfig.ModelName[1]=='B') ||
+			(ShmSysConfigAndInfo->SysConfig.ModelName[1]=='K') ||
+			(ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O'))
+		   ) // 'D' means DC
+		{
+			// DO series
+			for(int gun_index=0; gun_index<GENERAL_GUN_QUANTITY ; gun_index++)
+			{
+				gunType[gun_index] = GUN_TYPE_DO;
+
+				switch(modelnameInfo.ParsingInfo[gun_index].GunType)
+				{
+					case Gun_Type_Chademo:
+						DEBUG_INFO("Gun-%02d type: Cabinet CHAdeMO\n", gun_index);
+						break;
+					case Gun_Type_CCS_2:
+						DEBUG_INFO("Gun-%02d type: Cabinet CCS\n", gun_index);
+						break;
+					case Gun_Type_GB:
+						DEBUG_INFO("Gun-%02d type: Cabinet GBT\n", gun_index);
+						break;
+					case Gun_Type_AC:
+						DEBUG_INFO("Gun-%02d type: Cabinet AC\n", gun_index);
+						break;
+					default:
+						DEBUG_WARN("Gun-%02d type: Cabinet unknown\n", gun_index);
+						break;
+				}
+			}
+		}
+		else
+		{
+			for(int gun_index=0;gun_index<modelnameInfo.GetGunCount;gun_index++)
+			{
+				switch(modelnameInfo.ParsingInfo[gun_index].GunType)
+				{
+					case Gun_Type_Chademo:
+						gunType[gun_index] = GUN_TYPE_CHAdeMO;
+						DEBUG_INFO("Gun-%02d type: CHAdeMO\n", gun_index);
+						break;
+					case Gun_Type_CCS_2:
+						gunType[gun_index] = GUN_TYPE_CCS;
+						DEBUG_INFO("Gun-%02d type: CCS\n", gun_index);
+						break;
+					case Gun_Type_GB:
+						gunType[gun_index] = GUN_TYPE_GBT;
+						DEBUG_INFO("Gun-%02d type: GBT\n", gun_index);
+						break;
+					case Gun_Type_AC:
+						gunType[gun_index] = GUN_TYPE_AC;
+						DEBUG_INFO("Gun-%02d type: AC\n", gun_index);
+						break;
+					default:
+						DEBUG_WARN("Gun-%02d type: Unknown\n", gun_index);
+						break;
+				}
+			}
+		}
+	}
+	else
+	{
+		DEBUG_ERROR("Model name parsing fail.\n");
+		result = FAIL;
+	}
+
+	// Initial all timer
+	for(uint8_t idxTmr=0;idxTmr<TMR_IDX_CNT;idxTmr++)
+	{
+		refreshStartTimer(&timer[idxTmr]);
+	}
+
+    return result;
+}
+*/
+/**
+ *
+ * @param mosq
+ * @param userdata
+ * @param msg
+ * @return
+ */
+int on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_message *msg)
+{
+	json_object *payload;
+
+	payload = json_tokener_parse(msg->payload);
+	if(!is_error(payload))
+	{
+		/*
+		 *	TODO:
+		 *		1. Process message depend on receive topic
+		 *		2. Message maybe could define as JSON format
+		 */
+		if(strstr(msg->topic, "client/connect"))
+		{
+			sprintf((char*)clientInfo.verHW, "%s", json_object_get_string(json_object_object_get(payload, "HW_version")));
+			sprintf((char*)clientInfo.verFW_OS, "%s", json_object_get_string(json_object_object_get(payload, "FW_version_OS")));
+			sprintf((char*)clientInfo.verFW_APK, "%s", json_object_get_string(json_object_object_get(payload, "FW_version_APK")));
+			sprintf((char*)clientInfo.verFW_UI, "%s", json_object_get_string(json_object_object_get(payload, "FW_version_UI")));
+			sprintf((char*)clientInfo.macAddr, "%s", json_object_get_string(json_object_object_get(payload, "MAC_addr")));
+			sprintf((char*)clientInfo.orientation, "%s", json_object_get_string(json_object_object_get(payload, "Orientation")));
+
+			DEBUG_INFO("HW_version: %s\n", clientInfo.verHW);
+			DEBUG_INFO("FW_version_OS: %s\n", clientInfo.verFW_OS);
+			DEBUG_INFO("FW_version_APK: %s\n", clientInfo.verFW_APK);
+			DEBUG_INFO("FW_version_UI: %s\n", clientInfo.verFW_UI);
+			DEBUG_INFO("MAC_addr: %s\n", clientInfo.macAddr);
+			DEBUG_INFO("Orientation: %s\n", clientInfo.orientation);
+		}
+		else if(strstr(msg->topic, "client/touch"))
+		{
+			if(json_object_object_get(payload, "touchlist") != NULL)
+			{
+				for(int idx=0;idx<json_object_array_length(json_object_object_get(payload, "touchlist"));idx++)
+				{
+					DEBUG_INFO("Touch point-%d(%s-%s)=> x: %s, y: %s\n", idx,
+																  json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(payload, "touchlist"), idx), "obj_type")),
+																  json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(payload, "touchlist"), idx), "obj_onClick")),
+																  json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(payload, "touchlist"), idx), "touch_point_x")),
+																  json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(payload, "touchlist"), idx), "touch_point_y")));
+				}
+			}
+		}
+		else if(strstr(msg->topic, "client/info"))
+		{
+			if(json_object_object_get(payload, "status") != NULL)
+			{
+				switch(atoi(json_object_get_string(json_object_object_get(payload, "status"))))
+				{
+					case 1:
+						DEBUG_INFO("Status normal.\n");
+						break;
+					case 2:
+						DEBUG_INFO("Status downloading.\n");
+						break;
+					case 3:
+						DEBUG_INFO("Status uploading.\n");
+						break;
+					case 4:
+						DEBUG_INFO("Status reboot.\n");
+						break;
+					case 5:
+						DEBUG_INFO("Status reset.\n");
+						break;
+					case 6:
+						DEBUG_INFO("Status sleep.\n");
+						break;
+					case 255:
+						DEBUG_INFO("Status fault.\n");
+						break;
+					default:
+						DEBUG_INFO("Unknown status.\n");
+						break;
+				}
+			}
+
+			if(json_object_object_get(payload, "temperature") != NULL)
+			{
+				DEBUG_INFO("Temperature: %s.\n", json_object_get_string(json_object_object_get(payload, "temperature")));
+			}
+
+			if(json_object_object_get(payload, "cpu_temperatue") != NULL)
+			{
+				DEBUG_INFO("CPU temperature: %s.\n", json_object_get_string(json_object_object_get(payload, "cpu_temperatue")));
+			}
+		}
+		else if(strstr(msg->topic, "client/profile") ||
+				strstr(msg->topic, "client/command") ||
+				strstr(msg->topic, "client/timesync") ||
+				strstr(msg->topic, "client/layout/textview") ||
+				strstr(msg->topic, "client/layout/imageview") ||
+				strstr(msg->topic, "client/layout/videoview") ||
+				strstr(msg->topic, "client/layout/remove"))
+		{
+			// Skip topic publish from CSU
+		}
+		else
+		{
+			DEBUG_INFO("Unknown topic: %s\n", msg->topic);
+			DEBUG_INFO("Unknown payload: %s\n", msg->payload);
+		}
+	}
+	else
+	{
+		DEBUG_WARN("Payload is not JSON format.\n");
+	}
+	json_object_put(payload);
+
+	return 0;
+}
+
+/**
+ *
+ * @param mosq
+ * @param obj
+ * @param reason_code
+ */
+void on_connect(struct mosquitto *mosq, void *obj, int reason_code)
+{
+	DEBUG_INFO("on_connect: %s\n", mosquitto_connack_string(reason_code));
+	if(reason_code != 0)mosquitto_disconnect(mosq);
+}
+
+/**
+ *
+ * @param mosq
+ * @param obj
+ * @param reason_code
+ */
+void on_disconnect(struct mosquitto *mosq, void *obj, int reason_code)
+{
+	DEBUG_INFO("on_disconnect: %s\n", mosquitto_connack_string(reason_code));
+	if(reason_code != 0)mosquitto_disconnect(mosq);
+}
+
+/**
+ *
+ * @param mosq
+ * @param obj
+ * @param mid
+ */
+void on_publish(struct mosquitto *mosq, void *obj, int mid)
+{}
+
+//==========================================================================
+// Page routine
+//==========================================================================
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Booting(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Idle(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Authorizing(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Preparing(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Charging(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Terminating(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Complete(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Reservation(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Maintain(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Update(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_AlarmFault(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Unknown(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+//==========================================================================
+// Command publish sample routine
+//==========================================================================
+/**
+ *
+ * @param mosq
+ */
+int publish_profile_sample(struct mosquitto *mosq)
+{
+	return publish_profile(mosq, PROFILE_CONNECT_TIMEOUT, "10000");
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_upgrade_sample(struct mosquitto *mosq)
+{
+	char url[300];
+	char chkCrc32[16];
+
+	sprintf(url, "ftp://ftpuser:ftppasswd@%s/mnt/img.zip", BROKER_ADDRESS);
+	sprintf(chkCrc32, "0x%08X", getFileCrc32("/mnt/img.zip"));
+	DEBUG_INFO("image file crc32: %s\n", chkCrc32);
+	DEBUG_INFO("url : %s\n", url);
+	return publish_upgrade(mosq, OTA_TYPE_APK, url, chkCrc32, "V0.01");
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_restart_sample(struct mosquitto *mosq)
+{
+	return publish_restart(mosq, FALSE);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_power_saving_sample(struct mosquitto *mosq)
+{
+	return publish_power_saving(mosq, TRUE);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_back_dimming_sample(struct mosquitto *mosq)
+{
+	int i;
+	for (i = 0; i <= BRIGHTNESS_LEVEL_AUTO; i++) {
+		publish_back_dimming(mosq, i);
+		sleep(3);
+	}
+	return publish_back_dimming(mosq, BRIGHTNESS_LEVEL_AUTO);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_timesync_sample(struct mosquitto *mosq)
+{
+	return publish_timesync(mosq);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_textview_add_sample(struct mosquitto *mosq)
+{
+	Text_List textList[2] = {0};
+
+	for(int idx=0;idx<ARRAY_SIZE(textList);idx++)
+	{
+		if (idx == 0) {
+			textList[idx].layout_x = 10;//(rand()%800+100);
+			textList[idx].layout_y = 10;//(rand()%800+100);
+		} else {
+			textList[idx].layout_x = (rand() % 800 + 100);;//(rand()%800+100);
+			textList[idx].layout_y = (rand() % 800 + 100);;//(rand()%800+100);
+		}
+		textList[idx].textviewIndex = idx;
+		sprintf(textList[idx].textString, "%08d", (rand() % 99999999 + 10000000));
+		sprintf(textList[idx].textFont, FONT_ARIAL);
+		sprintf(textList[idx].textStyle, FONT_STYLE_NORMAL);
+		textList[idx].textSize = FONT_SIZE_20PX;
+	}
+
+	return publish_textview_add(mosq, textList, ARRAY_SIZE(textList));
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_imageview_add_sample(struct mosquitto *mosq)
+{
+	Image_List imageList[15] = {0};
+
+	for(int idx=0;idx<ARRAY_SIZE(imageList);idx++)
+	{
+		imageList[idx].imageviewIndex = idx;
+		imageList[idx].imgsrc_addr = idx;
+		imageList[idx].layout_x = (rand()%800+100);
+		imageList[idx].layout_y = (rand()%800+100);
+		imageList[idx].width = (rand()%100+150);
+		imageList[idx].height = (rand()%100+150);
+
+	}
+
+	return publish_imageview_add(mosq, imageList, ARRAY_SIZE(imageList));
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_videoview_add_sample(struct mosquitto *mosq)
+{
+	Video_List videoList[2] = {0};
+
+	for(int idx=0;idx<ARRAY_SIZE(videoList);idx++)
+	{
+		videoList[idx].videoviewIndex = idx;
+		videoList[idx].videosrc_addr = 11;//(rand()%10+0);
+		videoList[idx].layout_x = 100;//(rand()%800+100);
+		videoList[idx].layout_y = 100;//(rand()%800+100);
+		videoList[idx].width = 900;//(rand()%800+100);
+		videoList[idx].height = 600;//(rand()%800+100);
+	}
+
+	return publish_videoview_add(mosq, videoList, ARRAY_SIZE(videoList));
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_qr_code_image(struct mosquitto *mosq)
+{
+	QrCode_List qrCodeList[2] = {0};
+
+	for(int idx=0;idx<ARRAY_SIZE(qrCodeList);idx++)
+	{
+		qrCodeList[idx].qrCodeIndex = idx;
+		sprintf((char*)qrCodeList[idx].qrCodeContent, "djsalkdjskjslkdjsalkdjslkdjsalkdjsal");
+		sprintf((char*)qrCodeList[idx].errorCorrection, "M");
+		qrCodeList[idx].layout_x = 100;//(rand()%800+100);
+		qrCodeList[idx].layout_y = 100;//(rand()%800+100);
+		qrCodeList[idx].width = (rand()%800+100);
+		qrCodeList[idx].height = (rand()%800+100);
+	}
+
+	return publish_qrcodeimage_add(mosq, qrCodeList, ARRAY_SIZE(qrCodeList));
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_view_remove_sample(struct mosquitto *mosq)
+{
+	Text_List textList[2] = {0};
+	Image_List imageList[2] = {0};
+	Video_List videoList[2] = {0};
+	QrCode_List qrCodeList[2] = {0};
+
+	// Remove text view
+	for(int idx=0;idx<ARRAY_SIZE(textList);idx++)
+	{
+		textList[idx].textviewIndex = idx;
+	}
+
+	// Remove image view
+	for(int idx=0;idx<ARRAY_SIZE(imageList);idx++)
+	{
+		imageList[idx].imageviewIndex = idx;
+	}
+
+	// Remove video view
+	for(int idx=0;idx<ARRAY_SIZE(videoList);idx++)
+	{
+		videoList[idx].videoviewIndex = idx;
+	}
+
+	// Remove qrCode view
+	for(int idx=0;idx<ARRAY_SIZE(qrCodeList);idx++)
+	{
+		qrCodeList[idx].qrCodeIndex = idx;
+	}
+
+	return publish_view_remove(mosq, textList, ARRAY_SIZE(textList), imageList, ARRAY_SIZE(imageList), videoList, ARRAY_SIZE(videoList), qrCodeList, ARRAY_SIZE(qrCodeList));
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_clear_screen_sample(struct mosquitto *mosq)
+{
+	return publish_clear_screen(mosq);
+}
+
+/**
+ *
+ * @param mosq
+ * @return
+ */
+int publish_audio_volume_sample(struct mosquitto *mosq)
+{
+	return publish_audio_volume(mosq, 50);
+}
+
+/**
+ *
+ * @param mosq
+ * @return
+ */
+int publish_trigger_report_status_sample(struct mosquitto *mosq)
+{
+	return publish_trigger_report_status(mosq);
+}
+
+/**
+ *
+ * @return
+ */
+int main(void)
+{
+	struct mosquitto *mosq;
+	int result;
+
+	//===========================================
+	// Initial share memory
+	//===========================================
+	if(CreateAllCsuShareMemory() == FAIL)
+	{
+		DEBUG_ERROR("CreateAllCsuShareMemory NG\n");
+
+		sleep(5);
+		return FAIL;
+	}
+	else
+	{
+		DEBUG_INFO("Share memory initial OK.\n");
+	}
+
+	MappingGunChargingInfo("LCM Wistron Control Task");
+
+	//===========================================
+	// Start mosquitto broker
+	//===========================================
+	system("killall mosquitto");
+	sleep(1);
+	system("/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf -d");
+	DEBUG_INFO("Broker target: %s:%d\n", BROKER_ADDRESS, BROKER_PORT);
+
+	//===========================================
+	// Initialize mosquitto library
+	//===========================================
+	mosquitto_lib_init();
+
+	//===========================================
+	// Initialize subscriber callback
+	//===========================================
+	if(fork())
+	{
+		DEBUG_INFO("Initialize subscribe callback function.\n");
+		result = mosquitto_subscribe_callback(on_message,
+											  NULL,
+											  "client/#",
+											  QOS_ENSURE_BROKER,
+											  BROKER_ADDRESS,
+											  BROKER_PORT,
+											  NULL,
+											  TIMEOUT_KEEPALIVE,
+											  true,
+											  LOGIN_USER,
+											  LOGIN_PASSWD,
+											  NULL,
+											  NULL);
+		if(result)DEBUG_ERROR("Subscribe initialization error: %s\n", mosquitto_strerror(result));
+
+		return -1;
+	}
+
+	//===========================================
+	// Initialize publisher client instance
+	//===========================================
+	DEBUG_INFO("Initialize publisher from host side.\n");
+	mosq = mosquitto_new(NULL, true, NULL);
+	if(mosq == NULL)
+	{
+		DEBUG_ERROR("Publisher initialization error: Out of memory.\n");
+		return -1;
+	}
+	mosquitto_connect_callback_set(mosq, on_connect);
+	mosquitto_disconnect_callback_set(mosq, on_disconnect);
+	mosquitto_publish_callback_set(mosq, on_publish);
+
+	//===========================================
+	// Publisher connect to broker
+	//===========================================
+	DEBUG_INFO("Publisher connect to broker.\n");
+	result = mosquitto_connect(mosq, BROKER_ADDRESS, BROKER_PORT, TIMEOUT_KEEPALIVE);
+	if(result != MOSQ_ERR_SUCCESS)
+	{
+		mosquitto_destroy(mosq);
+		DEBUG_ERROR("Connect broker error: %s\n", mosquitto_strerror(result));
+		return -1;
+	}
+
+	//===========================================
+	// Publisher start loop
+	//===========================================
+	DEBUG_INFO("Publisher loop start.\n");
+	result = mosquitto_loop_start(mosq);
+	if(result != MOSQ_ERR_SUCCESS)
+	{
+		mosquitto_destroy(mosq);
+		DEBUG_ERROR("MQTT loop start initialization error: %s\n", mosquitto_strerror(result));
+		return -1;
+	}
+
+	DEBUG_INFO("Module_LcmControl_Wistron initialized.\n");
+	system("ifconfig lo up&");
+	//===========================================
+	// Main loop
+	//===========================================
+	for(;;)
+	{
+#ifndef TEST_MODE
+		struct ChargingInfoData *targetChargingInfoData;
+		uint8_t tempIndex;
+		static struct PREVIOUS_DATA
+		{
+			uint8_t gun_selected;
+			uint8_t SystemStatus;
+		}previousData;
+
+		// Get selected gun info
+		switch(gunType[ShmSysConfigAndInfo->SysInfo.CurGunSelected])
+		{
+			case GUN_TYPE_CHAdeMO:
+				if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
+				{
+					tempIndex = ((ShmSysConfigAndInfo->SysInfo.CurGunSelected==2) ? 1: 0);
+				}
+				else
+				{
+					tempIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
+				}
+
+				for (int index = 0; index < CHAdeMO_QUANTITY; index++)
+				{
+					if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
+					{
+						targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index];
+					}
+				}
+				break;
+
+			case GUN_TYPE_CCS:
+				if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
+				{
+					tempIndex = ((ShmSysConfigAndInfo->SysInfo.CurGunSelected==2) ? 1: 0);
+				}
+				else
+				{
+					tempIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
+				}
+
+				for (int index = 0; index < CCS_QUANTITY; index++)
+				{
+					if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
+					{
+						targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[index];
+					}
+				}
+				break;
+
+			case GUN_TYPE_GBT:
+				if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
+				{
+					tempIndex = ((ShmSysConfigAndInfo->SysInfo.CurGunSelected==2) ? 1: 0);
+				}
+				else
+				{
+					tempIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
+				}
+
+				for (int index = 0; index < GB_QUANTITY; index++)
+				{
+					if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
+					{
+						targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.GbChargingData[index];
+					}
+				}
+				break;
+
+			case GUN_TYPE_DO:
+				tempIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
+
+				for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
+				{
+					if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
+					{
+						targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData;
+					}
+				}
+				break;
+
+			case GUN_TYPE_AC:
+				if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
+				{
+					tempIndex = 2;
+				}
+				else
+				{
+					tempIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
+				}
+
+				for (int index = 0; index < AC_QUANTITY; index++)
+				{
+					if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
+					{
+						targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.AcChargingData[index];
+					}
+				}
+
+				break;
+
+			case GUN_TYPE_UNKNOWN:
+			default:
+				break;
+		}
+
+		// If selected gun or system status changed, clear page all content
+		if((previousData.gun_selected != ShmSysConfigAndInfo->SysInfo.CurGunSelected) ||
+		   (previousData.SystemStatus != targetChargingInfoData->SystemStatus))
+		{
+			publish_clear_screen(mosq);
+			previousData.gun_selected = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
+			previousData.SystemStatus = targetChargingInfoData->SystemStatus;
+		}
+
+		// Display page content depend on selected gun system status
+		switch(targetChargingInfoData->SystemStatus)
+		{
+			case SYS_MODE_BOOTING:
+				page_Booting(targetChargingInfoData);
+
+				break;
+
+			case SYS_MODE_IDLE:
+				page_Idle(targetChargingInfoData);
+
+				break;
+
+			case SYS_MODE_AUTHORIZING:
+				page_Authorizing(targetChargingInfoData);
+
+				break;
+
+			case SYS_MODE_PREPARING:
+				page_Preparing(targetChargingInfoData);
+				break;
+
+			case SYS_MODE_CHARGING:
+				page_Charging(targetChargingInfoData);
+				break;
+
+			case SYS_MODE_TERMINATING:
+				page_Terminating(targetChargingInfoData);
+				break;
+
+			case SYS_MODE_COMPLETE:
+				page_Complete(targetChargingInfoData);
+				break;
+
+			case SYS_MODE_RESERVATION:
+				page_Reservation(targetChargingInfoData);
+				break;
+
+			case SYS_MODE_MAINTAIN:
+				page_Maintain(targetChargingInfoData);
+				break;
+
+			case SYS_MODE_UPDATE:
+				page_Update(targetChargingInfoData);
+				break;
+
+			case SYS_MODE_ALARM:
+			case SYS_MODE_FAULT:
+				page_AlarmFault(targetChargingInfoData);
+				break;
+
+			default:
+				page_Unknown(targetChargingInfoData);
+				break;
+		}
+#else
+		// For test command
+		char cmd[128];
+
+		system("clear");
+		memset(cmd, 0x00, ARRAY_SIZE(cmd));
+		printf("\n ===== main menu ==================================");
+		printf("\n  1: publish_profile_sample.");
+		printf("\n  2: publish_upgrade_sample.");
+		printf("\n  3: publish_restart_sample.");
+		printf("\n  4: publish_power_saving_sample.");
+		printf("\n  5: publish_back_dimming_sample.");
+		printf("\n  6: publish_timesync.");
+		printf("\n  7: publish_textview_add_sample.");
+		printf("\n  8: publish_imageview_add_sample.");
+		printf("\n  9: publish_videoview_add_sample.");
+		printf("\n  10: publish_view_remove_sample.");
+		printf("\n  11: publish_clear_screen.");
+		printf("\n  12: publish_audio_volume.");
+		printf("\n  13: publish_trigger_report_status.");
+		printf("\n  14: publish_qr_code_image.");
+		printf("\n ==================================================");
+		printf("\n  Please input item to test: ");
+		scanf("%s", &cmd[0]);
+
+		switch(atoi(cmd))
+		{
+			case 1:
+				publish_profile_sample(mosq);
+				break;
+			case 2:
+				publish_upgrade_sample(mosq);
+				break;
+			case 3:
+				publish_restart_sample(mosq);
+				break;
+			case 4:
+				publish_power_saving_sample(mosq);
+				break;
+			case 5:
+				publish_back_dimming_sample(mosq);
+				break;
+			case 6:
+				publish_timesync_sample(mosq);
+				break;
+			case 7:
+				publish_textview_add_sample(mosq);
+				break;
+			case 8:
+				publish_imageview_add_sample(mosq);
+				break;
+			case 9:
+				publish_videoview_add_sample(mosq);
+				break;
+			case 10:
+				publish_view_remove_sample(mosq);
+				break;
+			case 11:
+				publish_clear_screen_sample(mosq);
+				break;
+			case 12:
+				publish_audio_volume_sample(mosq);
+				break;
+			case 13:
+				publish_trigger_report_status_sample(mosq);
+				break;
+			case 14:
+				publish_qr_code_image(mosq);
+				break;
+		}
+#endif
+
+		usleep(500000);
+	}
+
+	mosquitto_lib_cleanup();
+
+	return -1;
+}

+ 232 - 0
EVSE/Projects/DD360UCar/Apps/Module_LcmControl_Wistron/Module_LcmControl_Wistron.h

@@ -0,0 +1,232 @@
+/*
+ * Module_MqttClient.h
+ *
+ *  Created on: 2021/11/6
+ *      Author: folus
+ */
+
+#ifndef MODULE_MQTTCLIENT_H_
+#define MODULE_MQTTCLIENT_H_
+#include    <sys/types.h>
+#include    <sys/stat.h>
+#include 	<sys/time.h>
+#include 	<sys/timeb.h>
+#include 	<sys/types.h>
+#include 	<sys/ioctl.h>
+#include 	<sys/socket.h>
+#include 	<sys/ipc.h>
+#include 	<sys/shm.h>
+#include 	<sys/mman.h>
+#include 	<linux/wireless.h>
+#include 	<arpa/inet.h>
+#include 	<netinet/in.h>
+#include	<dirent.h>
+#include 	<sys/prctl.h>
+#include 	<unistd.h>
+#include 	<stdarg.h>
+#include    <stdio.h>
+#include    <stdlib.h>
+#include    <unistd.h>
+#include    <fcntl.h>
+#include    <termios.h>
+#include    <errno.h>
+#include 	<errno.h>
+#include 	<string.h>
+#include	<time.h>
+#include	<ctype.h>
+#include 	<ifaddrs.h>
+#include	<stdbool.h>
+#include	<stddef.h>
+#include	<stdint.h>
+#include 	<signal.h>
+#include	"json-c/json.h"
+#include 	"mosquitto.h"
+
+#define TEST_MODE
+
+#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
+#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
+#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
+
+enum TIMER_IDX
+{
+	TMR_IDX_0=0,
+	TMR_IDX_1,
+	TMR_IDX_2,
+	TMR_IDX_3,
+	TMR_IDX_4,
+	TMR_IDX_5,
+	TMR_IDX_CNT
+};
+
+enum GUN_TYPE
+{
+	GUN_TYPE_UNKNOWN=0,
+	GUN_TYPE_CHAdeMO,
+	GUN_TYPE_CCS,
+	GUN_TYPE_GBT,
+	GUN_TYPE_DO,
+	GUN_TYPE_AC
+};
+
+enum SWITCH_STS
+{
+	OFF=0,
+	ON
+};
+
+enum BOOLEAN_STS
+{
+	NO=0,
+	YES
+};
+
+enum QOS_TYPE
+{
+	QOS_ONLY_TX=0,
+	QOS_ENSURE_BROKER,
+	QOS_ENSURE_SUBSCRIBE
+};
+
+enum RETAIN_TYPE
+{
+	RETAIN_NO=0,
+	RETAIN_YES
+};
+
+typedef struct TEXT_LIST
+{
+	uint16_t	textviewIndex;
+	char		textString[256];
+	char		textFont[32];
+	char		textStyle[32];
+	uint8_t		textSize;
+	uint16_t	layout_x;
+	uint16_t	layout_y;
+
+}Text_List;
+
+typedef struct IMAGE_LIST
+{
+	uint16_t	imageviewIndex;
+	uint16_t	imgsrc_addr;
+	uint16_t	layout_x;
+	uint16_t	layout_y;
+	uint16_t	width;
+	uint16_t	height;
+
+}Image_List;
+
+typedef struct VIDEO_LIST
+{
+	uint16_t	videoviewIndex;
+	uint16_t	videosrc_addr;
+	uint16_t	layout_x;
+	uint16_t	layout_y;
+	uint16_t	width;
+	uint16_t	height;
+
+}Video_List;
+
+typedef struct QRCODE_LIST
+{
+	uint16_t	qrCodeIndex;
+	int8_t		qrCodeContent[512];
+	int8_t		errorCorrection[8];
+	uint16_t	layout_x;
+	uint16_t	layout_y;
+	uint16_t	width;
+	uint16_t	height;
+
+}QrCode_List;
+
+#define ARRAY_SIZE(A)				(sizeof(A) / sizeof(A[0]))
+#define is_error(ptr) 				((unsigned long)ptr > (unsigned long)-4000L)
+
+#define BROKER_PORT					1883
+#define BROKER_ADDRESS				"192.168.0.10"
+#define TIMEOUT_KEEPALIVE			60
+#define LOGIN_USER					NULL
+#define LOGIN_PASSWD				NULL
+
+#define PASS						1
+#define FAIL						-1
+
+
+#define PROFILE_CONNECT_TIMEOUT		"connect_timeout"
+
+#define OTA_TYPE_UI					"ota_ui"
+#define OTA_TYPE_APK				"ota_apk"
+#define OTA_TYPE_SDCARD				"ota_sdcard"
+
+#define FONT_STYLE_NORMAL			"normal"
+#define FONT_STYLE_BOLD				"bold"
+#define FONT_STYLE_ITALIC			"italic"
+#define FONT_STYLE_BOLD_ITALIC		"bold_italic"
+
+#define FONT_ARIAL					"Arial"
+#define FON_MS                      "·L³n¥¿¶ÂÅé"
+
+enum BRIGHTNESS_LEVEL
+{
+	BRIGHTNESS_LEVEL_0=0,
+	BRIGHTNESS_LEVEL_1,
+	BRIGHTNESS_LEVEL_2,
+	BRIGHTNESS_LEVEL_3,
+	BRIGHTNESS_LEVEL_4,
+	BRIGHTNESS_LEVEL_5,
+	BRIGHTNESS_LEVEL_6,
+	BRIGHTNESS_LEVEL_7,
+	BRIGHTNESS_LEVEL_8,
+	BRIGHTNESS_LEVEL_9,
+	BRIGHTNESS_LEVEL_10,
+	BRIGHTNESS_LEVEL_11,
+	BRIGHTNESS_LEVEL_AUTO,
+};
+
+enum FONT_SIZE
+{
+	FONT_SIZE_8PX=8,
+	FONT_SIZE_10PX=10,
+	FONT_SIZE_12PX=12,
+	FONT_SIZE_14PX=14,
+	FONT_SIZE_16PX=16,
+	FONT_SIZE_20PX=20,
+	FONT_SIZE_24PX=24,
+	FONT_SIZE_34PX=34,
+	FONT_SIZE_48PX=48,
+	FONT_SIZE_60PX=60,
+	FONT_SIZE_96PX=96,
+};
+
+struct ClientInfo
+{
+	int8_t verHW[32];
+	int8_t verFW_OS[32];
+	int8_t verFW_APK[32];
+	int8_t verFW_UI[32];
+	int8_t macAddr[32];
+	int8_t orientation[32];
+}clientInfo;
+
+extern int StoreLogMsg(const char *fmt, ...);
+extern int publish_data(struct mosquitto *mosq, char *topic, char *outputStr);
+extern int publish_profile(struct mosquitto *mosq, char *parameter, char *value);
+extern int publish_upgrade(struct mosquitto *mosq, char *otaType, char *url, char *checksum, char *verInfo);
+extern int publish_restart(struct mosquitto *mosq, uint8_t isHardReset);
+extern int publish_power_saving(struct mosquitto *mosq, uint8_t isSleep);
+extern int publish_back_dimming(struct mosquitto *mosq, uint8_t lightLevel);
+extern int publish_timesync(struct mosquitto *mosq);
+extern int publish_textview_add(struct mosquitto *mosq, Text_List *textList, uint8_t listCount);
+extern int publish_imageview_add(struct mosquitto *mosq, Image_List *imageList, uint8_t listCount);
+extern int publish_videoview_add(struct mosquitto *mosq, Video_List *videoList, uint8_t listCount);
+extern int publish_qrcodeimage_add(struct mosquitto *mosq, QrCode_List *qrCodeList, uint8_t listCount);
+extern int publish_view_remove(struct mosquitto *mosq, Text_List *textList, uint8_t textListCount,
+													   Image_List *imageList, uint8_t imageListCount,
+													   Video_List *videoList, uint8_t videoListCount,
+													   QrCode_List *qrCodeList, uint8_t qrCodeListCount);
+extern int publish_clear_screen(struct mosquitto *mosq);
+extern int publish_audio_volume(struct mosquitto *mosq, uint8_t volume);
+extern int publish_trigger_report_status(struct mosquitto *mosq);
+
+#endif /* MODULE_MQTTCLIENT_H_ */

+ 17 - 0
EVSE/Projects/DD360UCar/Apps/Module_LcmControl_Wistron/Module_LcmItemList.c

@@ -0,0 +1,17 @@
+/*
+ * Module_LcmItemList.c
+ *
+ *  Created on: 2022/3/31
+ *      Author: folus
+ */
+#include "Module_LcmControl_Wistron.h"
+
+void showbackground(Image_List* imageList, int idx)
+{
+	imageList->imageviewIndex = idx;
+	imageList->imgsrc_addr = _background;
+	imageList->layout_x = 0;
+	imageList->layout_y = 607;
+	imageList->width = 1080;
+	imageList->height = 1313;
+}

BIN
EVSE/Projects/DD360UCar/output/Module_LcmWistronControl