|
@@ -20,7 +20,7 @@
|
|
|
#define TMR_IDX_HANDSHAKING 0
|
|
|
#define TMR_IDX_AUTH 1
|
|
|
#define TMR_IDX_LOGPPRINTOUT 2
|
|
|
-#define TMR_IDX_3 3
|
|
|
+#define TMR_IDX_PROFILE_PREPARE 3
|
|
|
#define TMR_IDX_4 4
|
|
|
#define TMR_IDX_5 5
|
|
|
#define TMR_IDX_6 6
|
|
@@ -32,9 +32,11 @@
|
|
|
#define TIMEOUT_SPEC_AUTH 15000
|
|
|
#define TIMEOUT_SPEC_HANDSHAKING_LED 185000
|
|
|
#define TIMEOUT_SPEC_LOGPPRINTOUT 30000
|
|
|
+#define TIMEOUT_SPEC_PROFILE_PREPARE 5000
|
|
|
|
|
|
#define MtdBlockSize 0x600000
|
|
|
|
|
|
+#define DB_FILE "/Storage/ChargeLog/localCgargingRecord.db"
|
|
|
//==========================
|
|
|
// Declare method
|
|
|
//==========================
|
|
@@ -428,22 +430,28 @@ int DB_Open(sqlite3 *db)
|
|
|
{
|
|
|
int result = PASS;
|
|
|
char* errMsg = NULL;
|
|
|
- char* createSql="CREATE TABLE IF NOT EXISTS charging_record("
|
|
|
- "idx integer primary key AUTOINCREMENT, "
|
|
|
- "reservationId text, "
|
|
|
- "transactionId text, "
|
|
|
- "startMethod text, "
|
|
|
- "userId text, "
|
|
|
- "dateTimeStart text, "
|
|
|
- "dateTimeStop text,"
|
|
|
- "socStart text, "
|
|
|
- "socStop text, "
|
|
|
- "chargeEnergy text, "
|
|
|
- "stopReason text"
|
|
|
- ");";
|
|
|
+ char* createRecordSql="CREATE TABLE IF NOT EXISTS charging_record("
|
|
|
+ "idx integer primary key AUTOINCREMENT, "
|
|
|
+ "reservationId text, "
|
|
|
+ "transactionId text, "
|
|
|
+ "startMethod text, "
|
|
|
+ "userId text, "
|
|
|
+ "dateTimeStart text, "
|
|
|
+ "dateTimeStop text,"
|
|
|
+ "socStart text, "
|
|
|
+ "socStop text, "
|
|
|
+ "chargeEnergy text, "
|
|
|
+ "stopReason text"
|
|
|
+ ");";
|
|
|
+
|
|
|
+ char* createCfgSql="CREATE TABLE IF NOT EXISTS `config` ( "
|
|
|
+ "`idx` INTEGER PRIMARY KEY AUTOINCREMENT, "
|
|
|
+ "`item` TEXT NOT NULL, "
|
|
|
+ "`connector` INTEGER NOT NULL, "
|
|
|
+ "`val` TEXT NOT NULL, unique(item,connector) on conflict replace);";
|
|
|
|
|
|
//sqlite3_config(SQLITE_CONFIG_URI, 1);
|
|
|
- if(sqlite3_open("/Storage/ChargeLog/localCgargingRecord.db", &db))
|
|
|
+ if(sqlite3_open(DB_FILE, &db))
|
|
|
{
|
|
|
result = FAIL;
|
|
|
DEBUG_INFO( "Can't open database: %s\r\n", sqlite3_errmsg(db));
|
|
@@ -452,7 +460,8 @@ int DB_Open(sqlite3 *db)
|
|
|
else
|
|
|
{
|
|
|
DEBUG_INFO( "Local charging record database open successfully.\r\n");
|
|
|
- if (sqlite3_exec(db, createSql, 0, 0, &errMsg) != SQLITE_OK)
|
|
|
+
|
|
|
+ if (sqlite3_exec(db, createRecordSql, 0, 0, &errMsg) != SQLITE_OK)
|
|
|
{
|
|
|
result = FAIL;
|
|
|
DEBUG_INFO( "Create local charging record table error message: %s\n", errMsg);
|
|
@@ -461,6 +470,17 @@ int DB_Open(sqlite3 *db)
|
|
|
{
|
|
|
DEBUG_INFO( "Opened local charging record table successfully\n");
|
|
|
}
|
|
|
+
|
|
|
+ if (sqlite3_exec(db, createCfgSql, 0, 0, &errMsg) != SQLITE_OK)
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ DEBUG_INFO( "Create local config table error message: %s\n", errMsg);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_INFO( "Opened local config table successfully\n");
|
|
|
+ }
|
|
|
+
|
|
|
sqlite3_close(db);
|
|
|
}
|
|
|
|
|
@@ -510,6 +530,86 @@ int DB_Insert_Record(sqlite3 *db, int gun_index)
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+int DB_Update_Operactive(sqlite3 *db, uint8_t gun_index, uint8_t isOperactive)
|
|
|
+{
|
|
|
+ uint8_t result = false;
|
|
|
+ char* errMsg = NULL;
|
|
|
+ char sqlStr[1024];
|
|
|
+ srand(time(NULL));
|
|
|
+
|
|
|
+ if(sqlite3_open(DB_FILE, &db))
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ DEBUG_INFO( "Can't open database: %s\r\n", sqlite3_errmsg(db));
|
|
|
+ sqlite3_close(db);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_INFO( "Local charging record database open successfully.\r\n");
|
|
|
+
|
|
|
+ sprintf(sqlStr, "insert or replace into config (item, connector, val) values('isOperactive', %d, %d);", gun_index, isOperactive);
|
|
|
+ DEBUG_INFO("sqlStr= %s\r\n", sqlStr);
|
|
|
+ if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ DEBUG_INFO( "update config error message: %s\n", errMsg);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_INFO("update connector-%d config item isOperactive to %d\r\n", gun_index, isOperactive);
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlite3_close(db);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+int DB_Get_Operactive(sqlite3 *db, uint8_t gun_index)
|
|
|
+{
|
|
|
+ uint8_t result = true;
|
|
|
+ char* errMsg = NULL;
|
|
|
+ char sqlStr[1024];
|
|
|
+ char **rs;
|
|
|
+ int rows, cols;
|
|
|
+
|
|
|
+ sprintf(sqlStr, "select * from config where item='isOperactive' and connector=%d;", gun_index);
|
|
|
+ //DEBUG_INFO("sqlStr= %s\r\n", sqlStr);
|
|
|
+
|
|
|
+ if(sqlite3_open(DB_FILE, &db))
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ DEBUG_INFO( "Can't open database: %s\r\n", sqlite3_errmsg(db));
|
|
|
+ sqlite3_close(db);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_INFO( "Local config query database open successfully.\r\n");
|
|
|
+ sqlite3_get_table(db, sqlStr, &rs, &rows, &cols, &errMsg);
|
|
|
+
|
|
|
+ if(rows>0)
|
|
|
+ {
|
|
|
+ for(int idxRow=1;idxRow<=rows;idxRow++)
|
|
|
+ {
|
|
|
+ if(strcmp(rs[(idxRow*cols)+3], "0") == 0)
|
|
|
+ {
|
|
|
+ result = false;
|
|
|
+ }
|
|
|
+ DEBUG_INFO("Query connector-%d isOperactive: %s\r\n", gun_index, rs[(idxRow*cols)+3]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Query connector-%d fail, set default value to operactive.\r\n", gun_index);
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlite3_free_table(rs);
|
|
|
+ sqlite3_close(db);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
//======================================================
|
|
|
// Peripheral initial
|
|
|
//======================================================
|
|
@@ -942,6 +1042,9 @@ int Initialization()
|
|
|
if(DB_Open(localDb) != PASS)
|
|
|
result = FAIL;
|
|
|
|
|
|
+ for(int gun_index=0;gun_index< AC_QUANTITY;gun_index++)
|
|
|
+ ShmCharger->gun_info[gun_index].isOperactive = DB_Get_Operactive(localDb, gun_index);
|
|
|
+
|
|
|
rfidFd = InitRfidPort();
|
|
|
|
|
|
wtdFd = InitWatchDog();
|
|
@@ -1075,7 +1178,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, "B0.24.00.0000.00");
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "B0.25.00.0000.00");
|
|
|
|
|
|
// Get AC connector type from model name
|
|
|
for(uint8_t idx=0;idx<3;idx++)
|
|
@@ -1637,6 +1740,7 @@ int getScheduleStart(int gun_index)
|
|
|
tmScheduleStart.tm_year -= 1900;
|
|
|
tmScheduleStart.tm_mon -= 1;
|
|
|
tbScheduleStart.time = mktime(&tmScheduleStart);
|
|
|
+ tbScheduleStart.millitm = 0;
|
|
|
|
|
|
result = DiffTimebWithNow(tbScheduleStart)/1000;
|
|
|
|
|
@@ -1949,8 +2053,8 @@ int main(void)
|
|
|
//==========================================
|
|
|
if(ShmOCPP16Data->MsMsg.bits.ResetReq)
|
|
|
{
|
|
|
- if((!isMode(0, SYS_MODE_CHARGING) && !isMode(0, SYS_MODE_TERMINATING) && !isMode(0, SYS_MODE_COMPLETE)) &&
|
|
|
- (AC_QUANTITY>1?(!isMode(1, SYS_MODE_CHARGING) && !isMode(1, SYS_MODE_TERMINATING) && !isMode(1, SYS_MODE_COMPLETE)):true))
|
|
|
+ if((!isMode(0, SYS_MODE_CHARGING) && !isMode(0, SYS_MODE_TERMINATING) && !isMode(0, SYS_MODE_COMPLETE)) &&
|
|
|
+ (AC_QUANTITY>1?(!isMode(1, SYS_MODE_CHARGING) && !isMode(1, SYS_MODE_TERMINATING) && !isMode(0, SYS_MODE_COMPLETE)):true))
|
|
|
{
|
|
|
ShmOCPP16Data->MsMsg.bits.ResetReq = OFF;
|
|
|
sprintf((char*)ShmOCPP16Data->Reset.ResponseStatus, "Accepted");
|
|
@@ -1966,8 +2070,8 @@ int main(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- close(wtdFd);
|
|
|
sleep(5);
|
|
|
+ close(wtdFd);
|
|
|
system("/usr/bin/run_evse_restart.sh");
|
|
|
}
|
|
|
}
|
|
@@ -2052,19 +2156,30 @@ int main(void)
|
|
|
{
|
|
|
if(strcmp((char*)ShmOCPP16Data->ChangeAvailability[gun_index].Type, "Operative") == 0)
|
|
|
{
|
|
|
- if(isMode(gun_index, SYS_MODE_MAINTAIN))
|
|
|
- {
|
|
|
- setChargerMode(gun_index, SYS_MODE_IDLE);
|
|
|
- ShmOCPP16Data->CsMsg.bits[gun_index].ChangeAvailabilityReq = OFF;
|
|
|
- }
|
|
|
+ DB_Update_Operactive(localDb, gun_index, true);
|
|
|
+ ShmCharger->gun_info[gun_index].isOperactive = DB_Get_Operactive(localDb, gun_index);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if(isMode(gun_index, SYS_MODE_IDLE))
|
|
|
- {
|
|
|
- setChargerMode(gun_index, SYS_MODE_MAINTAIN);
|
|
|
- ShmOCPP16Data->CsMsg.bits[gun_index].ChangeAvailabilityReq = OFF;
|
|
|
- }
|
|
|
+ DB_Update_Operactive(localDb, gun_index, false);
|
|
|
+ ShmCharger->gun_info[gun_index].isOperactive = DB_Get_Operactive(localDb, gun_index);
|
|
|
+ }
|
|
|
+
|
|
|
+ ShmOCPP16Data->CsMsg.bits[gun_index].ChangeAvailabilityReq = OFF;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ShmCharger->gun_info[gun_index].isOperactive)
|
|
|
+ {
|
|
|
+ if(isMode(gun_index, SYS_MODE_MAINTAIN))
|
|
|
+ {
|
|
|
+ setChargerMode(gun_index, SYS_MODE_IDLE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(isMode(gun_index, SYS_MODE_IDLE))
|
|
|
+ {
|
|
|
+ setChargerMode(gun_index, SYS_MODE_MAINTAIN);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2073,7 +2188,7 @@ int main(void)
|
|
|
{
|
|
|
ShmOCPP16Data->CsMsg.bits[gun_index].UnlockConnectorReq = OFF;
|
|
|
|
|
|
- sprintf((char*)ShmOCPP16Data->UnlockConnector[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].ResponseStatus, "Unlocked");
|
|
|
+ sprintf((char*)ShmOCPP16Data->UnlockConnector[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].ResponseStatus, "NotSupported");
|
|
|
ShmOCPP16Data->CsMsg.bits[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].UnlockConnectorConf = ON;
|
|
|
|
|
|
ShmCharger->gun_info[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].isUnlockerConnetor = ON;
|
|
@@ -2160,7 +2275,6 @@ int main(void)
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = 0;
|
|
|
ShmCharger->gun_info[gun_index].targetCurrent = 0xFF;
|
|
|
ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ShmCharger->gun_info[gun_index].primaryMcuState.rating_current;
|
|
|
- memset(ShmOCPP16Data->UnlockConnector[gun_index].ResponseStatus, 0x00, ARRAY_SIZE(ShmOCPP16Data->UnlockConnector[gun_index].ResponseStatus));
|
|
|
ShmCharger->gun_info[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].isUnlockerConnetor = OFF;
|
|
|
|
|
|
// Response StopTransactionConf
|
|
@@ -2324,6 +2438,8 @@ int main(void)
|
|
|
(!ShmOCPP16Data->OcppConnStatus && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE)) ||
|
|
|
(!ShmOCPP16Data->OcppConnStatus && (isValidLocalWhiteCard() == PASS) && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_LOCALLIST)))
|
|
|
{
|
|
|
+ memcpy((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
|
|
|
+
|
|
|
DEBUG_INFO("Authorize pass.\r\n");
|
|
|
setSpeaker(ON,SPEAKER_SHORT);
|
|
|
setLedMotion(gun_index,LED_ACTION_RFID_PASS);
|
|
@@ -2369,12 +2485,25 @@ int main(void)
|
|
|
ShmCharger->gun_info[gun_index].isGunPlugged = YES;
|
|
|
}
|
|
|
|
|
|
+ // Unplug charging gun to Idle mode
|
|
|
if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A) && (ShmCharger->gun_info[gun_index].isGunPlugged == YES))
|
|
|
{
|
|
|
DEBUG_INFO("Charging gun is plugged before.\r\n");
|
|
|
setChargerMode(gun_index, SYS_MODE_IDLE);
|
|
|
}
|
|
|
|
|
|
+ // Use RFID card to stop handshaking
|
|
|
+ if((ShmCharger->gun_info[gun_index].rfidReq == ON) && isMatchStartUser(gun_index))
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Use RFID card to stop handshaking.\r\n");
|
|
|
+ setSpeaker(ON,SPEAKER_SHORT);
|
|
|
+ setChargerMode(gun_index, SYS_MODE_IDLE);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
+ }
|
|
|
+
|
|
|
if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > ShmCharger->timeoutSpec.Present_Timeout_Spec)
|
|
|
{
|
|
|
setLedMotion(gun_index, LED_ACTION_HANDSHAKE_FAIL);
|
|
@@ -2395,7 +2524,7 @@ int main(void)
|
|
|
getDateTimeString((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartDateTime);
|
|
|
ShmCharger->gun_info[gun_index].powerConsumption.power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumption.power_consumption;
|
|
|
ShmOCPP16Data->StartTransaction[gun_index].MeterStart = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
|
|
|
- memcpy((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
|
|
|
+ //memcpy((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
|
|
|
|
|
|
memcpy((char*)ShmOCPP16Data->StartTransaction[gun_index].IdTag, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ARRAY_SIZE(ShmOCPP16Data->StartTransaction[gun_index].IdTag));
|
|
|
ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionReq = ON;
|
|
@@ -2410,16 +2539,7 @@ int main(void)
|
|
|
ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
ftime(&startChargingTime[gun_index]);
|
|
|
ftime(&startTime[gun_index][TMR_IDX_LOGPPRINTOUT]);
|
|
|
- }
|
|
|
-
|
|
|
- // Charging profile preparation
|
|
|
- if(!ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileConf)
|
|
|
- {
|
|
|
- ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileReq = ON;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileConf = OFF;
|
|
|
+ ftime(&startTime[gun_index][TMR_IDX_PROFILE_PREPARE]);
|
|
|
}
|
|
|
|
|
|
if((ShmCharger->gun_info[gun_index].rfidReq == ON) ||
|
|
@@ -2446,6 +2566,20 @@ int main(void)
|
|
|
ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionConf = OFF;
|
|
|
}
|
|
|
|
|
|
+ // Charging profile preparation
|
|
|
+ if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_PROFILE_PREPARE]) > TIMEOUT_SPEC_PROFILE_PREPARE)
|
|
|
+ {
|
|
|
+ if(!ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileConf)
|
|
|
+ {
|
|
|
+ ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileReq = ON;
|
|
|
+ ftime(&startTime[gun_index][TMR_IDX_PROFILE_PREPARE]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileConf = OFF;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// Checking profile id > 0 and current time is between charging profile validFrom & validTo
|
|
|
if((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileId>0) &&
|
|
|
(((strlen((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidFrom)>0) && (strlen((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidTo)>0)) ? isProfileValid(gun_index) : ON))
|
|
@@ -2588,6 +2722,7 @@ int main(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+
|
|
|
// Off-line max condition check
|
|
|
if((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) ||
|
|
|
((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_ENABLE) && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy != OFF_POLICY_NOCHARGE)))
|
|
@@ -2722,7 +2857,7 @@ int main(void)
|
|
|
{
|
|
|
if(ShmOCPP16Data->SpMsg.bits.AuthorizeConf ||
|
|
|
(ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) ||
|
|
|
- !ShmOCPP16Data->OcppConnStatus)
|
|
|
+ (!ShmOCPP16Data->OcppConnStatus&&(ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE)))
|
|
|
{
|
|
|
if((strcmp((char*)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted")==0) ||
|
|
|
(ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) ||
|
|
@@ -2842,6 +2977,7 @@ int main(void)
|
|
|
|
|
|
break;
|
|
|
case SYS_MODE_ALARM:
|
|
|
+
|
|
|
if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_CHARGING) ||
|
|
|
(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_TERMINATING))
|
|
|
{
|
|
@@ -2851,7 +2987,7 @@ int main(void)
|
|
|
{
|
|
|
setRelay(gun_index, OFF);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode == 0))
|
|
|
{
|
|
|
if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_CHARGING) ||
|
|
@@ -3002,6 +3138,81 @@ int main(void)
|
|
|
ShmOCPP16Data->CsMsg.bits[gun_index].CancelReservationReq = OFF;
|
|
|
ShmOCPP16Data->CsMsg.bits[gun_index].CancelReservationConf = ON;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // Check is there RFID or back end request start
|
|
|
+ if((ShmCharger->gun_info[gun_index].rfidReq == ON) ||
|
|
|
+ (ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq == ON))
|
|
|
+ {
|
|
|
+ if((ShmCharger->gun_info[gun_index].rfidReq == ON))
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(strcmp((char*)ShmSysConfigAndInfo->SysConfig.UserId, (char*)ShmOCPP16Data->ReserveNow[gun_index].IdTag) == 0)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Start Method in reservation : RFID...\r\n");
|
|
|
+ DEBUG_INFO("Start request User Id : %s\r\n", ShmSysConfigAndInfo->SysConfig.UserId);
|
|
|
+ DEBUG_INFO("Reservation User Id : %s\r\n", ShmOCPP16Data->ReserveNow[gun_index].IdTag);
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod = START_METHOD_RFID;
|
|
|
+ setChargerMode(gun_index, SYS_MODE_AUTHORIZING);
|
|
|
+ }
|
|
|
+
|
|
|
+ ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
+
|
|
|
+ }
|
|
|
+ else if(ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq)
|
|
|
+ {
|
|
|
+ if(strcmp((char*)ShmOCPP16Data->RemoteStartTransaction[gun_index].IdTag, (char*)ShmOCPP16Data->ReserveNow[gun_index].IdTag) == 0)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Start Method in reservation: BACKEND...\r\n");
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod = START_METHOD_BACKEND;
|
|
|
+ memcpy(ShmSysConfigAndInfo->SysConfig.UserId, ShmOCPP16Data->RemoteStartTransaction[gun_index].IdTag, ARRAY_SIZE(ShmOCPP16Data->RemoteStartTransaction[gun_index].IdTag));
|
|
|
+ setChargerMode(gun_index, SYS_MODE_AUTHORIZING);
|
|
|
+ }
|
|
|
+ ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq = OFF;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
break;
|
|
|
case SYS_MODE_BOOKING:
|