|
@@ -23,7 +23,7 @@
|
|
|
#define TMR_IDX_PROFILE_PREPARE 3
|
|
|
#define TMR_IDX_BS_HLC_HANDSHAKE 4
|
|
|
#define TMR_IDX_CCS_HEARTBEAT_COUNT_RESET 5
|
|
|
-#define TMR_IDX_6 6
|
|
|
+#define TMR_IDX_PWN_CHANGE 6
|
|
|
#define TMR_IDX_7 7
|
|
|
#define TMR_IDX_8 8
|
|
|
#define TMR_IDX_9 9
|
|
@@ -37,6 +37,7 @@
|
|
|
#define TIMEOUT_SPEC_EV_READY 30000
|
|
|
#define TIMEOUT_SPEC_CCS_HEARTBEAT_COUNT_RESET 10000
|
|
|
#define TIMEOUT_SPEC_CCS_HANDSHAKE 120000
|
|
|
+#define TIMEOUT_SPEC_PWN_CHANGE 5000
|
|
|
|
|
|
#define MtdBlockSize 0x600000
|
|
|
|
|
@@ -797,10 +798,9 @@ int LoadSysConfigAndInfo(struct SysConfigData *ptr)
|
|
|
fd = open("/dev/mtdblock12", O_RDWR);
|
|
|
if (fd < 0)
|
|
|
{
|
|
|
- free(buf);
|
|
|
-
|
|
|
DEBUG_ERROR("open mtdblock12 (Factory default) NG,rebooting..\r\n");
|
|
|
-
|
|
|
+
|
|
|
+ free(buf);
|
|
|
if(ShmStatusCodeData!=NULL)
|
|
|
{
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed=1;
|
|
@@ -815,10 +815,9 @@ int LoadSysConfigAndInfo(struct SysConfigData *ptr)
|
|
|
close(fd);
|
|
|
if(wrd<MtdBlockSize)
|
|
|
{
|
|
|
- free(buf);
|
|
|
-
|
|
|
DEBUG_ERROR("read factory default SysConfigData data NG,rebooting..\r\n");
|
|
|
-
|
|
|
+
|
|
|
+ free(buf);
|
|
|
if(ShmStatusCodeData!=NULL)
|
|
|
{
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed=1;
|
|
@@ -901,8 +900,8 @@ int StoreUsrConfigData(struct SysConfigData *UsrData)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- DEBUG_ERROR("write /dev/mtdblock10 NG\r\n");
|
|
|
- result = FAIL;
|
|
|
+ DEBUG_ERROR("write /dev/mtdblock10 NG\r\n");
|
|
|
+ result = FAIL;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -914,8 +913,9 @@ int StoreUsrConfigData(struct SysConfigData *UsrData)
|
|
|
else
|
|
|
{
|
|
|
DEBUG_ERROR("alloc BlockSize NG\r\n");
|
|
|
- result = FAIL;
|
|
|
+ result = FAIL;
|
|
|
}
|
|
|
+
|
|
|
if(BufTmp!=NULL)
|
|
|
free(BufTmp);
|
|
|
|
|
@@ -987,14 +987,13 @@ void InitEthernet()
|
|
|
{
|
|
|
if(++cnt_pingDNS_Fail > 3)
|
|
|
{
|
|
|
-
|
|
|
ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet=ON;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet &&
|
|
|
- ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi &&
|
|
|
- ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi)
|
|
|
+ ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi &&
|
|
|
+ ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi)
|
|
|
{
|
|
|
ShmSysConfigAndInfo->SysInfo.InternetConn = OFF;
|
|
|
}
|
|
@@ -1197,7 +1196,7 @@ void get_firmware_version(unsigned char gun_index)
|
|
|
strcpy((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ShmCharger->gun_info[gun_index].ver.Version_FW);
|
|
|
|
|
|
// Get CSU root file system version
|
|
|
- sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "D0.25.00.0000.00");
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "D0.26.00.0000.00");
|
|
|
|
|
|
// Get AC connector type from model name
|
|
|
for(uint8_t idx=0;idx<3;idx++)
|
|
@@ -1685,34 +1684,63 @@ int isReachableInternet()
|
|
|
FILE *fp;
|
|
|
char cmd[256];
|
|
|
char buf[512];
|
|
|
- //char tmp[512];
|
|
|
-
|
|
|
- for(int idx=0;idx<ARRAY_SIZE(valid_Internet);idx++)
|
|
|
+ char tmp[512];
|
|
|
+
|
|
|
+ if(ShmOCPP16Data->OcppConnStatus == PASS)
|
|
|
{
|
|
|
- sprintf(cmd, "ping -c 1 -w 3 -I eth0 %s", valid_Internet[idx]);
|
|
|
+ result = PASS;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ strcpy(cmd, "ifconfig eth0");
|
|
|
fp = popen(cmd, "r");
|
|
|
- if(fp != NULL)
|
|
|
+
|
|
|
+ if (fp != NULL)
|
|
|
{
|
|
|
while(fgets(buf, sizeof(buf), fp) != NULL)
|
|
|
{
|
|
|
- if(strstr(buf, "transmitted") > 0)
|
|
|
+ if (strstr(buf, "inet addr:") > 0)
|
|
|
{
|
|
|
- //sscanf(buf, "%*s%*s%*s%*s%*s%*s%s", tmp);
|
|
|
+ sscanf(buf, "%*s%s", tmp);
|
|
|
+ substr(tmp, tmp, strspn(tmp, "addr:"), strlen(buf)-strspn(tmp, "addr:"));
|
|
|
|
|
|
- if(strstr(buf,"100%") != NULL)
|
|
|
+ if (strcmp(tmp, (char *)ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress) != 0)
|
|
|
{
|
|
|
-
|
|
|
+ strcpy((char *) ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress, tmp);
|
|
|
}
|
|
|
- else
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pclose(fp);
|
|
|
+ memset(buf, 0x00, sizeof(buf));
|
|
|
+
|
|
|
+ for(int idx=0;idx<ARRAY_SIZE(valid_Internet);idx++)
|
|
|
+ {
|
|
|
+ sprintf(cmd, "ping -c 1 -w 3 -I eth0 %s", valid_Internet[idx]);
|
|
|
+ fp = popen(cmd, "r");
|
|
|
+ if(fp != NULL)
|
|
|
+ {
|
|
|
+ while(fgets(buf, sizeof(buf), fp) != NULL)
|
|
|
+ {
|
|
|
+ if(strstr(buf, "transmitted") > 0)
|
|
|
{
|
|
|
- result = PASS;
|
|
|
+ //sscanf(buf, "%*s%*s%*s%*s%*s%*s%s", tmp);
|
|
|
+
|
|
|
+ if(strstr(buf,"100%") != NULL)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = PASS;
|
|
|
+ }
|
|
|
+ //DEBUG_INFO("%s",buf);
|
|
|
+ //DEBUG_INFO("%s\n",tmp);
|
|
|
}
|
|
|
- //DEBUG_INFO("%s",buf);
|
|
|
- //DEBUG_INFO("%s\n",tmp);
|
|
|
}
|
|
|
}
|
|
|
+ pclose(fp);
|
|
|
}
|
|
|
- pclose(fp);
|
|
|
}
|
|
|
|
|
|
return result;
|
|
@@ -1789,7 +1817,6 @@ int getScheduleStart(int gun_index)
|
|
|
struct tm tmScheduleStart;;
|
|
|
struct timeb tbScheduleStart;
|
|
|
|
|
|
-
|
|
|
if((sscanf((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.StartSchedule, "%4d-%2d-%2dT%2d:%2d:%2d", &tmScheduleStart.tm_year, &tmScheduleStart.tm_mon, &tmScheduleStart.tm_mday, &tmScheduleStart.tm_hour, &tmScheduleStart.tm_min, &tmScheduleStart.tm_sec) == 6))
|
|
|
{
|
|
|
tmScheduleStart.tm_year -= 1900;
|
|
@@ -1798,8 +1825,7 @@ int getScheduleStart(int gun_index)
|
|
|
tbScheduleStart.millitm = 0;
|
|
|
|
|
|
result = DiffTimebWithNow(tbScheduleStart)/1000;
|
|
|
-
|
|
|
- DEBUG_INFO("Schedule start compare Now(seconds): %d\r\n", result);
|
|
|
+ //DEBUG_INFO("Schedule start compare Now(seconds): %d\r\n", result);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -1827,7 +1853,7 @@ int getStartSinceToday()
|
|
|
tbStartToday.time = mktime(tmStartToday);
|
|
|
|
|
|
result = DiffTimebWithNow(tbStartToday)/1000;
|
|
|
- DEBUG_INFO("Start today compare Now(seconds): %d\r\n", result);
|
|
|
+ //DEBUG_INFO("Start today compare Now(seconds): %d\r\n", result);
|
|
|
|
|
|
return result;
|
|
|
}
|
|
@@ -1851,8 +1877,7 @@ int getStartSinceWeek()
|
|
|
tbStartWeek.time = mktime(tmStartWeek);
|
|
|
|
|
|
result = DiffTimebWithNow(tbStartWeek)/1000;
|
|
|
-
|
|
|
- DEBUG_INFO("Start week compare Now(seconds): %d\r\n", result);
|
|
|
+ //DEBUG_INFO("Start week compare Now(seconds): %d\r\n", result);
|
|
|
|
|
|
return result;
|
|
|
}
|
|
@@ -1885,7 +1910,7 @@ int getEth0MacAddress()
|
|
|
char buf[512];
|
|
|
char tmp[512];
|
|
|
|
|
|
- strcpy(cmd, "ifconfig");;
|
|
|
+ strcpy(cmd, "ifconfig eth0");
|
|
|
fp = popen(cmd, "r");
|
|
|
if(fp != NULL)
|
|
|
{
|
|
@@ -2435,7 +2460,7 @@ int main(void)
|
|
|
{
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod = START_METHOD_FREE;
|
|
|
memcpy(ShmSysConfigAndInfo->SysConfig.UserId, ShmSysConfigAndInfo->SysConfig.SerialNumber, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.SerialNumber));
|
|
|
- DEBUG_INFO("Start Method : FREE..\r\n");
|
|
|
+ DEBUG_INFO("Start Method : FREE...\r\n");
|
|
|
}
|
|
|
|
|
|
ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
@@ -2455,6 +2480,7 @@ int main(void)
|
|
|
ftime(&startTime[gun_index][TMR_IDX_AUTH]);
|
|
|
if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_RFID)
|
|
|
{
|
|
|
+ memset(ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, 0x00, ARRAY_SIZE(ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status));
|
|
|
switch(ShmSysConfigAndInfo->SysConfig.AuthorisationMode)
|
|
|
{
|
|
|
case AUTH_MODE_ENABLE:
|
|
@@ -2489,7 +2515,7 @@ int main(void)
|
|
|
}
|
|
|
ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_AUTH]) > TIMEOUT_SPEC_AUTH)
|
|
|
{
|
|
|
// Authorization timeout process.
|
|
@@ -2895,6 +2921,11 @@ int main(void)
|
|
|
ftime(&startChargingTime[gun_index]);
|
|
|
ftime(&startTime[gun_index][TMR_IDX_LOGPPRINTOUT]);
|
|
|
ftime(&startTime[gun_index][TMR_IDX_PROFILE_PREPARE]);
|
|
|
+ ftime(&startTime[gun_index][TMR_IDX_PWN_CHANGE]);
|
|
|
+ startTime[gun_index][TMR_IDX_AUTH].time -= TIMEOUT_SPEC_AUTH;
|
|
|
+ ShmOCPP16Data->SpMsg.bits.AuthorizeReq = OFF;
|
|
|
+ ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileId = 0;
|
|
|
+ ShmCharger->gun_info[gun_index].isChargerStopByCondition = NO;
|
|
|
}
|
|
|
switch(ShmCharger->gun_info[gun_index].chargingMode)
|
|
|
{
|
|
@@ -2908,6 +2939,7 @@ int main(void)
|
|
|
{
|
|
|
if(ShmCharger->gun_info[gun_index].rfidReq)
|
|
|
{
|
|
|
+ DEBUG_INFO("Certified in charging mode... \r\n");
|
|
|
// If RFID SN different with start user, it need to authorize ID
|
|
|
if((ShmCharger->gun_info[gun_index].rfidReq == ON) && !isMatchStartUser(gun_index))
|
|
|
{
|
|
@@ -2957,10 +2989,10 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
DEBUG_INFO("End request User Id : %s\r\n", ShmSysConfigAndInfo->SysConfig.UserId);
|
|
|
- DEBUG_INFO("Start method : %d...\r\n ", ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod);
|
|
|
+ DEBUG_INFO("Start method : %d\r\n ", ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod);
|
|
|
|
|
|
if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_RFID) ||
|
|
|
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_BACKEND) ||
|
|
|
+ //(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_BACKEND) ||
|
|
|
(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_BLE))
|
|
|
{
|
|
|
switch(ShmSysConfigAndInfo->SysConfig.AuthorisationMode)
|
|
@@ -2994,6 +3026,11 @@ int main(void)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_BACKEND)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Should be remote stop charger... \r\n");
|
|
|
+ ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -3036,15 +3073,9 @@ int main(void)
|
|
|
{
|
|
|
setLedMotion(gun_index,LED_ACTION_CHARGING);
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption/100);
|
|
|
- //ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption[0] = (ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption/100);
|
|
|
- //ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption[1] = (ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption/100);
|
|
|
- //ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption[2] = (ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption/100);
|
|
|
ftime(&endChargingTime[gun_index]);
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration = DiffTimeb(startChargingTime[gun_index], endChargingTime[gun_index])/1000;
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = ((float)(ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption - ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption_at_start))/100;
|
|
|
- //ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy[0] = ((float)(ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption_at_start))/100;
|
|
|
- //ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy[1] = ((float)(ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption_at_start))/100;
|
|
|
- //ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy[2] = ((float)(ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption_at_start))/100;
|
|
|
|
|
|
// Response StartTransactionConf
|
|
|
if(ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionConf == ON)
|
|
@@ -3067,8 +3098,8 @@ int main(void)
|
|
|
}
|
|
|
|
|
|
// Checking profile id > 0 and current time is between charging profile validFrom & validTo
|
|
|
- if((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileId>0) &&
|
|
|
- (ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileReq != ON) &&
|
|
|
+ if((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileId > 0) &&
|
|
|
+ (ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileReq != ON) &&
|
|
|
(((strlen((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidFrom)>0) && (strlen((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidTo)>0)) ? isProfileValid(gun_index) : ON))
|
|
|
{
|
|
|
// Debug information
|
|
@@ -3107,7 +3138,69 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ else if((mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileKind, "Relative") == PASS))
|
|
|
+ {
|
|
|
+ // Relative profile
|
|
|
+ if(((mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfilePurpose, "TxProfile") == PASS) && (ShmOCPP16Data->SmartChargingProfile[gun_index].TransactionId == ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId)) ||
|
|
|
+ (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfilePurpose, "TxProfile") == FAIL))
|
|
|
+ {
|
|
|
+ // Checking limitation
|
|
|
+ for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
|
|
|
+ {
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
|
|
|
+ (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod > 0)))
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
|
|
|
+ DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // Recurring profile
|
|
|
+ if(((mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfilePurpose, "TxProfile") == PASS) && (ShmOCPP16Data->SmartChargingProfile[gun_index].TransactionId == ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId)) ||
|
|
|
+ (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfilePurpose, "TxProfile") == FAIL))
|
|
|
+ {
|
|
|
+ if((mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].RecurrencyKind, "Daily") == PASS))
|
|
|
+ {
|
|
|
+ // Checking limitation
|
|
|
+ for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
|
|
|
+ {
|
|
|
+ if((getStartSinceToday() > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
|
|
|
+ (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod > 0)))
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
|
|
|
+ DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // Checking limitation
|
|
|
+ for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
|
|
|
+ {
|
|
|
+ if((getStartSinceWeek() > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
|
|
|
+ (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod > 0)))
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
|
|
|
+ DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileId == 0) && (ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileReq != ON))
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].targetCurrent = ShmCharger->gun_info[gun_index].primaryMcuState.rating_current;
|
|
|
+ }
|
|
|
|
|
|
// Determine max charging current to MCU
|
|
|
if(ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent == 0)
|
|
@@ -3115,18 +3208,28 @@ int main(void)
|
|
|
ShmCharger->gun_info[gun_index].targetCurrent = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmCharger->gun_info[gun_index].primaryMcuState.rating_current)?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmCharger->gun_info[gun_index].targetCurrent);
|
|
|
if(ShmCharger->gun_info[gun_index].targetCurrent != ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current)
|
|
|
{
|
|
|
- ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmCharger->gun_info[gun_index].primaryMcuState.rating_current)?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmCharger->gun_info[gun_index].targetCurrent);
|
|
|
- ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
|
|
|
- }
|
|
|
+ if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_PWN_CHANGE]) > TIMEOUT_SPEC_PWN_CHANGE)
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmCharger->gun_info[gun_index].primaryMcuState.rating_current)?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmCharger->gun_info[gun_index].targetCurrent);
|
|
|
+ ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
|
|
|
+ ftime(&startTime[gun_index][TMR_IDX_PWN_CHANGE]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {} }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].targetCurrent = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent)?ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent:ShmCharger->gun_info[gun_index].targetCurrent);
|
|
|
if(ShmCharger->gun_info[gun_index].targetCurrent != ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current)
|
|
|
{
|
|
|
- ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent)?ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent:ShmCharger->gun_info[gun_index].targetCurrent);
|
|
|
- ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
|
|
|
- }
|
|
|
+ if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_PWN_CHANGE]) > TIMEOUT_SPEC_PWN_CHANGE)
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent)?ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent:ShmCharger->gun_info[gun_index].targetCurrent);
|
|
|
+ ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
|
|
|
+ ftime(&startTime[gun_index][TMR_IDX_PWN_CHANGE]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {} }
|
|
|
}
|
|
|
|
|
|
// Debug information
|
|
@@ -3145,16 +3248,23 @@ int main(void)
|
|
|
// On-line max condition check
|
|
|
if((ShmSysConfigAndInfo->SysConfig.MaxChargingDuration > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration*60)))
|
|
|
{
|
|
|
+ setRelay(gun_index, OFF);
|
|
|
+ setRequest(gun_index, OFF);
|
|
|
+ ShmCharger->gun_info[gun_index].isChargerStopByCondition = YES;
|
|
|
setChargerMode(gun_index, SYS_MODE_TERMINATING);
|
|
|
DEBUG_INFO("Connector-%d charging duration(%d) already over max duration(%d) in second.\r\n", gun_index, ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration, (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration*60));
|
|
|
}
|
|
|
else if((ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy >= ((float)ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy)))
|
|
|
{
|
|
|
+ setRelay(gun_index, OFF);
|
|
|
+ setRequest(gun_index, OFF);
|
|
|
+ ShmCharger->gun_info[gun_index].isChargerStopByCondition = YES;
|
|
|
setChargerMode(gun_index, SYS_MODE_TERMINATING);
|
|
|
DEBUG_INFO("Connector-%d charging energy(%.2f) already over max energy(%.2f) in KWH.\r\n", gun_index, ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy, ((float)ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ ShmCharger->gun_info[gun_index].isChargerStopByCondition = NO;
|
|
|
setRelay(gun_index, ON);
|
|
|
}
|
|
|
}
|
|
@@ -3167,16 +3277,26 @@ int main(void)
|
|
|
{
|
|
|
if(((ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration > 0) ? (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration*60)) : (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration*60))))
|
|
|
{
|
|
|
+ setRelay(gun_index, OFF);
|
|
|
+ setRequest(gun_index, OFF);
|
|
|
+ ShmCharger->gun_info[gun_index].isChargerStopByCondition = YES;
|
|
|
+
|
|
|
setChargerMode(gun_index, SYS_MODE_TERMINATING);
|
|
|
DEBUG_INFO("Connector-%d charging duration(%d) already over off-line max duration(%d) in second.\r\n", gun_index, ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration, (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration*60));
|
|
|
}
|
|
|
else if(((ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy > 0) ? (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy >= ((float)ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy)) : (ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy >= ((float)ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy))))
|
|
|
{
|
|
|
+ setRelay(gun_index, OFF);
|
|
|
+ setRequest(gun_index, OFF);
|
|
|
+ ShmCharger->gun_info[gun_index].isChargerStopByCondition = YES;
|
|
|
+
|
|
|
setChargerMode(gun_index, SYS_MODE_TERMINATING);
|
|
|
DEBUG_INFO("Connector-%d charging energy(%.2f) already over off-line max energy(%.2f) in KWH.\r\n", gun_index, ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy, ((float)ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ ShmCharger->gun_info[gun_index].isChargerStopByCondition = NO;
|
|
|
+
|
|
|
setRelay(gun_index, ON);
|
|
|
}
|
|
|
}
|
|
@@ -3573,6 +3693,140 @@ int main(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ // If the charger stops charging, the led should be stoped blink
|
|
|
+ if(!ShmCharger->gun_info[gun_index].primaryMcuState.relay_state)
|
|
|
+ {
|
|
|
+ setLedMotion(gun_index, LED_ACTION_STOP);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ShmCharger->gun_info[gun_index].rfidReq)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Certified in terminating mode... \r\n");
|
|
|
+
|
|
|
+ // If RFID SN different with start user, it need to authorize ID
|
|
|
+ if((ShmCharger->gun_info[gun_index].rfidReq == ON) && !isMatchStartUser(gun_index))
|
|
|
+ {
|
|
|
+ if((DiffTimebWithNow(startTime[gun_index][TMR_IDX_AUTH]) > TIMEOUT_SPEC_AUTH) && !ShmOCPP16Data->SpMsg.bits.AuthorizeReq)
|
|
|
+ {
|
|
|
+ // Request authorization
|
|
|
+ ftime(&startTime[gun_index][TMR_IDX_AUTH]);
|
|
|
+ memset(ShmSysConfigAndInfo->SysConfig.UserId, 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian)
|
|
|
+ {
|
|
|
+ // Big endian
|
|
|
+ switch(rfid.snType)
|
|
|
+ {
|
|
|
+ case RFID_SN_TYPE_6BYTE:
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5]);
|
|
|
+ break;
|
|
|
+ case RFID_SN_TYPE_7BYTE:
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6]);
|
|
|
+ break;
|
|
|
+ case RFID_SN_TYPE_10BYTE:
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6], rfid.currentCard[7], rfid.currentCard[8], rfid.currentCard[9]);
|
|
|
+ break;
|
|
|
+ case RFID_SN_TYPE_4BYTE:
|
|
|
+ default:
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // Little endian
|
|
|
+ switch(rfid.snType)
|
|
|
+ {
|
|
|
+ case RFID_SN_TYPE_6BYTE:
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
|
|
|
+ break;
|
|
|
+ case RFID_SN_TYPE_7BYTE:
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
|
|
|
+ break;
|
|
|
+ case RFID_SN_TYPE_10BYTE:
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[9], rfid.currentCard[8], rfid.currentCard[7], rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
|
|
|
+ break;
|
|
|
+ case RFID_SN_TYPE_4BYTE:
|
|
|
+ default:
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X", rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ DEBUG_INFO("End request User Id : %s... \r\n", ShmSysConfigAndInfo->SysConfig.UserId);
|
|
|
+ DEBUG_INFO("Start method : %d... \r\n ", ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod);
|
|
|
+
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_RFID) ||
|
|
|
+ //(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_BACKEND) ||
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_BLE))
|
|
|
+ {
|
|
|
+ switch(ShmSysConfigAndInfo->SysConfig.AuthorisationMode)
|
|
|
+ {
|
|
|
+ case AUTH_MODE_ENABLE:
|
|
|
+ if(ShmOCPP16Data->OcppConnStatus)
|
|
|
+ {
|
|
|
+ // On line
|
|
|
+ ShmOCPP16Data->SpMsg.bits.AuthorizeReq = ON;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // Off line
|
|
|
+ switch(ShmSysConfigAndInfo->SysConfig.OfflinePolicy)
|
|
|
+ {
|
|
|
+ case OFF_POLICY_LOCALLIST:
|
|
|
+ ShmOCPP16Data->SpMsg.bits.AuthorizeReq = ON;
|
|
|
+ break;
|
|
|
+ case OFF_POLICY_PH_RFID:
|
|
|
+ break;
|
|
|
+ case OFF_POLICY_FREE:
|
|
|
+ break;
|
|
|
+ case OFF_POLICY_NOCHARGE:
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case AUTH_MODE_DISABLE:
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_BACKEND)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Should be remote stop charger... \r\n");
|
|
|
+ ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(ShmOCPP16Data->SpMsg.bits.AuthorizeConf ||
|
|
|
+ (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) ||
|
|
|
+ (!ShmOCPP16Data->OcppConnStatus && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_LOCALLIST)) ||
|
|
|
+ (!ShmOCPP16Data->OcppConnStatus && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE)))
|
|
|
+ {
|
|
|
+ if((strcmp((char*)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted")==0) ||
|
|
|
+ (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) ||
|
|
|
+ (!ShmOCPP16Data->OcppConnStatus && (isValidLocalWhiteCard() == PASS) && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_LOCALLIST)) ||
|
|
|
+ (!ShmOCPP16Data->OcppConnStatus && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE)))
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].isAuthPassEnd = ON;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
+ ShmOCPP16Data->SpMsg.bits.AuthorizeReq = OFF;
|
|
|
+ DEBUG_INFO("Authorize fail... \r\n");
|
|
|
+ setSpeaker(ON,SPEAKER_INTERVAL_3COUNT);
|
|
|
+ setLedMotion(gun_index,LED_ACTION_RFID_FAIL);
|
|
|
+ sleep(3);
|
|
|
+ }
|
|
|
+
|
|
|
+ startTime[gun_index][TMR_IDX_AUTH].time -= TIMEOUT_SPEC_AUTH;
|
|
|
+ ShmOCPP16Data->SpMsg.bits.AuthorizeConf = OFF;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C) &&
|
|
|
(ShmCharger->gun_info[gun_index].rfidReq != ON) &&
|
|
|
(ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop != ON) &&
|
|
@@ -3634,6 +3888,141 @@ int main(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ // If the charger stops charging, the led should be stoped blink
|
|
|
+ if(!ShmCharger->gun_info[gun_index].primaryMcuState.relay_state)
|
|
|
+ {
|
|
|
+ setLedMotion(gun_index, LED_ACTION_STOP);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ShmCharger->gun_info[gun_index].rfidReq)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Certified in terminating mode... \r\n");
|
|
|
+
|
|
|
+ // If RFID SN different with start user, it need to authorize ID
|
|
|
+ if((ShmCharger->gun_info[gun_index].rfidReq == ON) && !isMatchStartUser(gun_index))
|
|
|
+ {
|
|
|
+ if((DiffTimebWithNow(startTime[gun_index][TMR_IDX_AUTH]) > TIMEOUT_SPEC_AUTH) && !ShmOCPP16Data->SpMsg.bits.AuthorizeReq)
|
|
|
+ {
|
|
|
+ // Request authorization
|
|
|
+ ftime(&startTime[gun_index][TMR_IDX_AUTH]);
|
|
|
+ memset(ShmSysConfigAndInfo->SysConfig.UserId, 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian)
|
|
|
+ {
|
|
|
+ // Big endian
|
|
|
+ switch(rfid.snType)
|
|
|
+ {
|
|
|
+ case RFID_SN_TYPE_6BYTE:
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5]);
|
|
|
+ break;
|
|
|
+ case RFID_SN_TYPE_7BYTE:
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6]);
|
|
|
+ break;
|
|
|
+ case RFID_SN_TYPE_10BYTE:
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6], rfid.currentCard[7], rfid.currentCard[8], rfid.currentCard[9]);
|
|
|
+ break;
|
|
|
+ case RFID_SN_TYPE_4BYTE:
|
|
|
+ default:
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // Little endian
|
|
|
+ switch(rfid.snType)
|
|
|
+ {
|
|
|
+ case RFID_SN_TYPE_6BYTE:
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
|
|
|
+ break;
|
|
|
+ case RFID_SN_TYPE_7BYTE:
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
|
|
|
+ break;
|
|
|
+ case RFID_SN_TYPE_10BYTE:
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[9], rfid.currentCard[8], rfid.currentCard[7], rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
|
|
|
+ break;
|
|
|
+ case RFID_SN_TYPE_4BYTE:
|
|
|
+ default:
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X", rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ DEBUG_INFO("End request User Id : %s... \r\n", ShmSysConfigAndInfo->SysConfig.UserId);
|
|
|
+ DEBUG_INFO("Start method : %d... \r\n ", ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod);
|
|
|
+
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_RFID) ||
|
|
|
+ //(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_BACKEND) ||
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_BLE))
|
|
|
+ {
|
|
|
+ switch(ShmSysConfigAndInfo->SysConfig.AuthorisationMode)
|
|
|
+ {
|
|
|
+ case AUTH_MODE_ENABLE:
|
|
|
+ if(ShmOCPP16Data->OcppConnStatus)
|
|
|
+ {
|
|
|
+ // On line
|
|
|
+ ShmOCPP16Data->SpMsg.bits.AuthorizeReq = ON;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // Off line
|
|
|
+ switch(ShmSysConfigAndInfo->SysConfig.OfflinePolicy)
|
|
|
+ {
|
|
|
+ case OFF_POLICY_LOCALLIST:
|
|
|
+ ShmOCPP16Data->SpMsg.bits.AuthorizeReq = ON;
|
|
|
+ break;
|
|
|
+ case OFF_POLICY_PH_RFID:
|
|
|
+ break;
|
|
|
+ case OFF_POLICY_FREE:
|
|
|
+ break;
|
|
|
+ case OFF_POLICY_NOCHARGE:
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case AUTH_MODE_DISABLE:
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_BACKEND)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Should be remote stop charger... \r\n");
|
|
|
+ ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(ShmOCPP16Data->SpMsg.bits.AuthorizeConf ||
|
|
|
+ (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) ||
|
|
|
+ (!ShmOCPP16Data->OcppConnStatus && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_LOCALLIST)) ||
|
|
|
+ (!ShmOCPP16Data->OcppConnStatus && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE)))
|
|
|
+ {
|
|
|
+ if((strcmp((char*)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted")==0) ||
|
|
|
+ (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) ||
|
|
|
+ (!ShmOCPP16Data->OcppConnStatus && (isValidLocalWhiteCard() == PASS) && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_LOCALLIST)) ||
|
|
|
+ (!ShmOCPP16Data->OcppConnStatus && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE)))
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].isAuthPassEnd = ON;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
+ ShmOCPP16Data->SpMsg.bits.AuthorizeReq = OFF;
|
|
|
+ DEBUG_INFO("Authorize fail... \r\n");
|
|
|
+ setSpeaker(ON,SPEAKER_INTERVAL_3COUNT);
|
|
|
+ setLedMotion(gun_index,LED_ACTION_RFID_FAIL);
|
|
|
+ sleep(3);
|
|
|
+ }
|
|
|
+
|
|
|
+ startTime[gun_index][TMR_IDX_AUTH].time -= TIMEOUT_SPEC_AUTH;
|
|
|
+ ShmOCPP16Data->SpMsg.bits.AuthorizeConf = OFF;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C) &&
|
|
|
(ShmCharger->gun_info[gun_index].rfidReq != ON) &&
|
|
|
(ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop != ON) &&
|
|
@@ -3822,7 +4211,7 @@ int main(void)
|
|
|
ShmSysConfigAndInfo->SysInfo.FirmwareUpdate = OFF;
|
|
|
int value = upgrade_check();
|
|
|
|
|
|
- DEBUG_INFO("Local update Value: %d...\r\n",value);
|
|
|
+ DEBUG_INFO("Local update Value: %s... \r\n",((value == PASS)?"Pass": "Fail"));
|
|
|
if(value == PASS)
|
|
|
{
|
|
|
if(ShmStatusCodeData->InfoCode.InfoEvents.bits.CsuFimrwareUpdateFail == ON)
|
|
@@ -3859,7 +4248,7 @@ int main(void)
|
|
|
ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = OFF;
|
|
|
int result = upgrade_check();
|
|
|
|
|
|
- DEBUG_INFO("Remote update Result: %d...\r\n",result);
|
|
|
+ DEBUG_INFO("Remote update Result: %s... \r\n",((result == PASS)?"Pass": "Fail"));
|
|
|
if(result == PASS)
|
|
|
{
|
|
|
if(ShmStatusCodeData->InfoCode.InfoEvents.bits.CsuFimrwareUpdateFail == ON)
|