|
@@ -41,6 +41,7 @@
|
|
|
#define MtdBlockSize 0x300000
|
|
|
|
|
|
#define DB_FILE "/Storage/ChargeLog/localCgargingRecord.db"
|
|
|
+#define DB_FILE_OCPP_LOCAL "/Storage/OCPP/charger.db"
|
|
|
//==========================
|
|
|
// Declare method
|
|
|
//==========================
|
|
@@ -89,6 +90,7 @@ struct timeb startTime[AC_QUANTITY][10];
|
|
|
struct timeb startChargingTime[AC_QUANTITY];
|
|
|
struct timeb endChargingTime[AC_QUANTITY];
|
|
|
sqlite3 *localDb;
|
|
|
+sqlite3 *ocppDb;
|
|
|
|
|
|
struct SysConfigData SysConfigOrg;
|
|
|
ParsingRatedCur modelnameInfo={0};
|
|
@@ -1576,6 +1578,80 @@ int DB_Open(sqlite3 *db)
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+int DB_Open_OCPP20(sqlite3 *db)
|
|
|
+{
|
|
|
+ int result = PASS;
|
|
|
+ char* errMsg = NULL;
|
|
|
+ char *sqlOcppVariable = "create table if not exists ocpp20_variable (idx integer primary key,"
|
|
|
+ "componentName text NOT NULL ,"
|
|
|
+ "componentInstance text, "
|
|
|
+ "variableName text NOT NULL, "
|
|
|
+ "variableInstance text, "
|
|
|
+ "variableCharacteristicsDataType integer, "
|
|
|
+ "variableCharacteristicsUnit text, "
|
|
|
+ "variableCharacteristicsMaxLimit real,"
|
|
|
+ "variableAttributesType text, "
|
|
|
+ "variableAttributesTypeMutability text, "
|
|
|
+ "variableAttributesTypeValue text, "
|
|
|
+ "variableCharacteristicsMinLimit real,"
|
|
|
+ "unique(componentName, componentInstance,variableName, variableInstance) on conflict replace);";
|
|
|
+
|
|
|
+ //sqlite3_config(SQLITE_CONFIG_URI, 1);
|
|
|
+ if(sqlite3_open(DB_FILE_OCPP_LOCAL, &db))
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ DEBUG_ERROR( "Can't open database: %s\n", sqlite3_errmsg(db));
|
|
|
+ sqlite3_close(db);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_INFO( "OCPP local database open successfully.\n");
|
|
|
+
|
|
|
+ if(sqlite3_exec(db, sqlOcppVariable, 0, 0, &errMsg) != SQLITE_OK)
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ DEBUG_ERROR( "Create OCPP 2.0 variable table error message: %s\n", errMsg);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_INFO( "Create OCPP 2.0 variable table successfully\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlite3_close(db);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+int DB_variableClear(sqlite3 *db)
|
|
|
+{
|
|
|
+ int result = PASS;
|
|
|
+ //char * sqlcleanLocalList = "delete from ocpp20_variable";
|
|
|
+ char * sqlcleanLocalList = "drop table ocpp20_variable";
|
|
|
+ char *errMsg = 0;
|
|
|
+
|
|
|
+ if(sqlite3_open(DB_FILE_OCPP_LOCAL, &db))
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ DEBUG_ERROR( "Can't open database for ocpp 2.0 variable: %s\n", sqlite3_errmsg(db));
|
|
|
+ sqlite3_close(db);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Command: &s\n", sqlcleanLocalList);
|
|
|
+ if(sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("%s\n", errMsg);
|
|
|
+ DEBUG_INFO("Drop table failed.\n");
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
+
|
|
|
+ DEBUG_INFO("Drop table succeed.\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
int DB_Insert_Record(sqlite3 *db, int gun_index)
|
|
|
{
|
|
|
int result = PASS;
|
|
@@ -2461,6 +2537,12 @@ int Initialization()
|
|
|
result = FAIL;
|
|
|
}
|
|
|
|
|
|
+ if(DB_Open_OCPP20(ocppDb) != PASS)
|
|
|
+ {
|
|
|
+ DEBUG_ERROR("OCPP 2.0 configuration variable database initial fail.\n");
|
|
|
+ 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);
|
|
|
|
|
@@ -2649,7 +2731,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, "V0.71.00.0000.00");
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "V0.72.00.0000.00");
|
|
|
|
|
|
// Get AC connector type from model name
|
|
|
for(uint8_t idx=0;idx<3;idx++)
|
|
@@ -4377,7 +4459,15 @@ int main(void)
|
|
|
|
|
|
sleep(5);
|
|
|
system("cd /root;./Module_FactoryConfig -m");
|
|
|
+
|
|
|
+ // OCPP 1.6 Configuration key
|
|
|
system("rm -f /Storage/OCPP/OCPPConfiguration");
|
|
|
+
|
|
|
+ // OCPP 2.O Configuration variable
|
|
|
+ DB_variableClear(ocppDb);
|
|
|
+
|
|
|
+ DEBUG_INFO("Default configuration to factory setting. \n");
|
|
|
+
|
|
|
system("sync");
|
|
|
sleep(5);
|
|
|
system("reboot -f");
|
|
@@ -4567,7 +4657,7 @@ int main(void)
|
|
|
if(strcmp((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") == 0)
|
|
|
{
|
|
|
DEBUG_INFO("URL is empty kill Module_OcppBackend...\n");
|
|
|
- system ("pkill OcppBackend");
|
|
|
+ system("pkill OcppBackend");
|
|
|
}
|
|
|
|
|
|
// If rotate switch equal zero, the system needs to change Debug mode
|
|
@@ -5493,7 +5583,7 @@ int main(void)
|
|
|
if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A))
|
|
|
{
|
|
|
setRequest(gun_index,OFF);
|
|
|
-
|
|
|
+
|
|
|
if(ShmCharger->gun_info[gun_index].isGunUnpluggedBefore != YES)
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].isGunUnpluggedBefore = YES;
|