|
@@ -2,9 +2,9 @@
|
|
|
* Module_Wifi.c
|
|
|
*
|
|
|
* Created on: 2020-01-14
|
|
|
- * Update on: 2020-09-01
|
|
|
+ * Update on: 2020-09-29
|
|
|
* Author: Jerry Wang, Eason Yang, Folus Wen
|
|
|
- * Version: V0.11
|
|
|
+ * Version: V0.12
|
|
|
*
|
|
|
* Issue tracking:
|
|
|
* 1. Set AP mode should be waiting for 30 seconds.
|
|
@@ -258,10 +258,11 @@ void substr(char *dest, const char* src, unsigned int start, unsigned int cnt);
|
|
|
void split(char **arr, char *str, const char *del);
|
|
|
int isValidCheckSum(uint8_t *message);
|
|
|
|
|
|
-char *Support_InterfaceSTA[2] = {"mlan0", "wlan0"};
|
|
|
-char *Support_InterfaceAP[1] = {"uap0"};
|
|
|
-char *valid_Internet[2] = {"8.8.8.8", "180.76.76.76"};
|
|
|
-int protocol_Version [] = {0,6,0};
|
|
|
+char *Support_InterfaceSTA[2] = {"mlan0", "wlan0"};
|
|
|
+char *Support_InterfaceAP[1] = {"uap0"};
|
|
|
+char *valid_Internet[2] = {"8.8.8.8", "180.76.76.76"};
|
|
|
+char *Version_And_Date[2] = {"V0.12","2020-09-29"};
|
|
|
+int protocol_Version [] = {0,7,0};
|
|
|
|
|
|
int StoreLogMsg(const char *fmt, ...)
|
|
|
{
|
|
@@ -937,12 +938,12 @@ int split2int(char *dest, char *src, const char *flag, int base)
|
|
|
|
|
|
uint8_t parseIP(uint8_t *ip)
|
|
|
{
|
|
|
- uint8_t result = FAIL;
|
|
|
- const int8_t flag_dot[1] = {'.'};
|
|
|
+ uint8_t result = false;
|
|
|
+ const char *flag_dot = ".";
|
|
|
int8_t buf[16];
|
|
|
memcpy(buf, ShmSysConfigAndInfo->SysConfig.AthInterface.WifiIpAddress, ARRAY_SIZE(buf));
|
|
|
|
|
|
- if(split2int((char*)ip , (char*)buf, (char*)flag_dot, 10)==4)
|
|
|
+ if(split2int((char*)ip , (char*)buf, flag_dot, 10)==4)
|
|
|
result = PASS;
|
|
|
|
|
|
return result;
|
|
@@ -950,12 +951,12 @@ uint8_t parseIP(uint8_t *ip)
|
|
|
|
|
|
uint8_t parseMAC(uint8_t *mac)
|
|
|
{
|
|
|
- uint8_t result = FAIL;
|
|
|
- const int8_t flag_colon[1] = {':'};
|
|
|
+ uint8_t result = false;
|
|
|
+ const char *flag_colon = ":";
|
|
|
int8_t buf[18];
|
|
|
memcpy(buf, ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMacAddress, ARRAY_SIZE(buf));
|
|
|
|
|
|
- if(split2int((char*)mac , (char*)buf, (char*)flag_colon, 16)==6)
|
|
|
+ if(split2int((char*)mac , (char*)buf, flag_colon, 16)==6)
|
|
|
result = PASS;
|
|
|
|
|
|
return result;
|
|
@@ -1359,12 +1360,12 @@ int cbScheduleSave(void *para, int columnCount, char **columnValue, char **colum
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-uint8_t scheduleSaveToDb(sqlite3 *db, uint8_t gun_index, struct Schedule *schedule)
|
|
|
+int scheduleSaveToDb(sqlite3 *db, uint8_t gun_index, struct Schedule *schedule)
|
|
|
{
|
|
|
- int result = PASS;
|
|
|
- char* errMsg = NULL;
|
|
|
- char sqlStr[512];
|
|
|
- json_object *scheduleObj = json_object_new_object();
|
|
|
+ int result = PASS;
|
|
|
+ char* errMsg = NULL;
|
|
|
+ char sqlStr[512];
|
|
|
+ json_object *scheduleObj = json_object_new_object();
|
|
|
|
|
|
// Save config to local db file
|
|
|
json_object_object_add(scheduleObj, "isEnable", json_object_new_int(schedule->isEnable));
|
|
@@ -1376,8 +1377,8 @@ uint8_t scheduleSaveToDb(sqlite3 *db, uint8_t gun_index, struct Schedule *schedu
|
|
|
json_object_object_add(scheduleObj, "stopTimeMinute", json_object_new_int(schedule->stopTimeMinute));
|
|
|
sprintf((char*)sqlStr, "insert or replace into config (item, connector, val) VALUES('schedule', %d, '%s'); SELECT * from config;", gun_index, json_object_to_json_string(scheduleObj));
|
|
|
|
|
|
- //* Execute SQL statement */
|
|
|
- if(sqlite3_open(DB_FILE_CHARGING, &db))
|
|
|
+ //* Execute SQL statement */
|
|
|
+ if(sqlite3_open(DB_FILE_CHARGING, &db))
|
|
|
{
|
|
|
result = FAIL;
|
|
|
DEBUG_INFO( "Can't open database: %s\n", sqlite3_errmsg(db));
|
|
@@ -1386,10 +1387,10 @@ uint8_t scheduleSaveToDb(sqlite3 *db, uint8_t gun_index, struct Schedule *schedu
|
|
|
else
|
|
|
{
|
|
|
if(sqlite3_exec(db, (char*)sqlStr, cbScheduleSave, 0, &errMsg) != SQLITE_OK)
|
|
|
- {
|
|
|
- DEBUG_INFO("SQL error: %s\n", errMsg);
|
|
|
- result = FAIL;
|
|
|
- }
|
|
|
+ {
|
|
|
+ DEBUG_INFO("SQL error: %s\n", errMsg);
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
sqlite3_close(db);
|
|
|
}
|
|
|
|
|
@@ -1409,7 +1410,7 @@ int cbScheduleLoad(void *para, int columnCount, char **columnValue, char **colum
|
|
|
DEBUG_INFO("Query schedule callback.\n");
|
|
|
for(int i=0; i<columnCount; i++)
|
|
|
{
|
|
|
- DEBUG_INFO("%s = %s\n", columnName[i], columnValue[i] ? columnValue[i] : "NULL");
|
|
|
+ DEBUG_INFO("%s = %s\n", columnName[i], columnValue[i] ? columnValue[i] : "NULL");
|
|
|
}
|
|
|
|
|
|
if((columnCount>0) && !is_error(scheduleObj))
|
|
@@ -1523,16 +1524,16 @@ int cbScheduleLoad(void *para, int columnCount, char **columnValue, char **colum
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-uint8_t scheduleLoadFromDb(sqlite3 *db, uint8_t gun_index)
|
|
|
+int scheduleLoadFromDb(sqlite3 *db, uint8_t gun_index)
|
|
|
{
|
|
|
- int result = PASS;
|
|
|
- char* errMsg = NULL;
|
|
|
- char sqlStr[512];
|
|
|
+ int result = PASS;
|
|
|
+ char* errMsg = NULL;
|
|
|
+ char sqlStr[512];
|
|
|
|
|
|
- sprintf(sqlStr, "select * from config where item='schedule' and connector=%d", gun_index);
|
|
|
+ sprintf(sqlStr, "select * from config where item='schedule' and connector=%d", gun_index);
|
|
|
|
|
|
- //* Execute SQL statement */
|
|
|
- if(sqlite3_open(DB_FILE_CHARGING, &db))
|
|
|
+ //* Execute SQL statement */
|
|
|
+ if(sqlite3_open(DB_FILE_CHARGING, &db))
|
|
|
{
|
|
|
result = FAIL;
|
|
|
DEBUG_INFO( "Can't open database: %s\n", sqlite3_errmsg(db));
|
|
@@ -1541,10 +1542,10 @@ uint8_t scheduleLoadFromDb(sqlite3 *db, uint8_t gun_index)
|
|
|
else
|
|
|
{
|
|
|
if(sqlite3_exec(db, sqlStr, cbScheduleLoad, 0, &errMsg) != SQLITE_OK)
|
|
|
- {
|
|
|
- DEBUG_INFO("SQL error: %s\n", errMsg);
|
|
|
- result = FAIL;
|
|
|
- }
|
|
|
+ {
|
|
|
+ DEBUG_INFO("SQL error: %s\n", errMsg);
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
sqlite3_close(db);
|
|
|
}
|
|
|
|
|
@@ -1986,7 +1987,13 @@ uint8_t startConnectorCharging(uint8_t gun_index)
|
|
|
// AC
|
|
|
if(ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].SystemStatus == SYS_MODE_IDLE)
|
|
|
{
|
|
|
- ShmOCPP16Data->CsMsg.bits[idxAC].RemoteStartTransactionReq = ON;
|
|
|
+ //ShmOCPP16Data->CsMsg.bits[idxAC].RemoteStartTransactionReq = ON;
|
|
|
+
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.isTriggerStart = ON;
|
|
|
+ DEBUG_INFO("AC isTriggerStar : [%d].\n", ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.isTriggerStart);
|
|
|
+ DEBUG_INFO("AC gun_index : [%d].\n", gun_index);
|
|
|
+ DEBUG_INFO("AC idxAC : [%d].\n", idxAC);
|
|
|
+
|
|
|
result = ON;
|
|
|
}
|
|
|
|
|
@@ -2025,8 +2032,14 @@ uint8_t startConnectorCharging(uint8_t gun_index)
|
|
|
// AC
|
|
|
if(ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].SystemStatus == SYS_MODE_IDLE)
|
|
|
{
|
|
|
- ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq = ON;
|
|
|
- DEBUG_INFO("AC : %d...\n", ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq);
|
|
|
+ //ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq = ON;
|
|
|
+ //DEBUG_INFO("AC : %d...\n", ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq);
|
|
|
+
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.isTriggerStart = ON;
|
|
|
+ DEBUG_INFO("AC isTriggerStar : [%d].\n", ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.isTriggerStart);
|
|
|
+ DEBUG_INFO("AC gun_index : [%d].\n", gun_index);
|
|
|
+ DEBUG_INFO("AC idxAC : [%d].\n", idxAC);
|
|
|
+
|
|
|
result = ON;
|
|
|
}
|
|
|
|
|
@@ -2035,8 +2048,14 @@ uint8_t startConnectorCharging(uint8_t gun_index)
|
|
|
// CHAdeMO
|
|
|
if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[idxCHAdeMO].SystemStatus == SYS_MODE_IDLE)
|
|
|
{
|
|
|
- ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq = ON;
|
|
|
- DEBUG_INFO("CHAdeMO : %d...\n", ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq);
|
|
|
+ //ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq = ON;
|
|
|
+ //DEBUG_INFO("CHAdeMO : %d...\n", ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq);
|
|
|
+
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ChademoChargingData[idxCHAdeMO].schedule.isTriggerStart = ON;
|
|
|
+ DEBUG_INFO("CHAdeMO isTriggerStar : [%d].\n", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[idxCHAdeMO].schedule.isTriggerStart);
|
|
|
+ DEBUG_INFO("CHAdeMO gun_index : [%d].\n", gun_index);
|
|
|
+ DEBUG_INFO("CHAdeMO idxCHAdeMO : [%d].\n", idxCHAdeMO);
|
|
|
+
|
|
|
result = ON;
|
|
|
}
|
|
|
|
|
@@ -2046,8 +2065,14 @@ uint8_t startConnectorCharging(uint8_t gun_index)
|
|
|
// CCS
|
|
|
if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[idxCCS].SystemStatus == SYS_MODE_IDLE)
|
|
|
{
|
|
|
- ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq = ON;
|
|
|
- DEBUG_INFO("CCS : %d...\n", ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq);
|
|
|
+ //ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq = ON;
|
|
|
+ //DEBUG_INFO("CCS : %d...\n", ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq);
|
|
|
+
|
|
|
+ ShmSysConfigAndInfo->SysInfo.CcsChargingData[idxCCS].schedule.isTriggerStart = ON;
|
|
|
+ DEBUG_INFO("CCS isTriggerStar : [%d].\n", ShmSysConfigAndInfo->SysInfo.CcsChargingData[idxCCS].schedule.isTriggerStart);
|
|
|
+ DEBUG_INFO("CCS gun_index : [%d].\n", gun_index);
|
|
|
+ DEBUG_INFO("CCS idxCCS : [%d].\n", idxCCS);
|
|
|
+
|
|
|
result = ON;
|
|
|
}
|
|
|
|
|
@@ -2056,8 +2081,14 @@ uint8_t startConnectorCharging(uint8_t gun_index)
|
|
|
// GBT
|
|
|
if(ShmSysConfigAndInfo->SysInfo.GbChargingData[idxGBT].SystemStatus == SYS_MODE_IDLE)
|
|
|
{
|
|
|
- ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq = ON;
|
|
|
- DEBUG_INFO("GBT : %d...\n", ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq);
|
|
|
+ //ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq = ON;
|
|
|
+ //DEBUG_INFO("GBT : %d...\n", ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq);
|
|
|
+
|
|
|
+ ShmSysConfigAndInfo->SysInfo.GbChargingData[idxGBT].schedule.isTriggerStart = ON;
|
|
|
+ DEBUG_INFO("GBT isTriggerStar : [%d].\n", ShmSysConfigAndInfo->SysInfo.GbChargingData[idxGBT].schedule.isTriggerStart);
|
|
|
+ DEBUG_INFO("GBT gun_index : [%d].\n", gun_index);
|
|
|
+ DEBUG_INFO("GBT idxGBT : [%d].\n", idxGBT);
|
|
|
+
|
|
|
result = ON;
|
|
|
}
|
|
|
|
|
@@ -2110,7 +2141,13 @@ uint8_t stopConnectorCharging(uint8_t gun_index)
|
|
|
// AC
|
|
|
if(ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].SystemStatus != SYS_MODE_IDLE)
|
|
|
{
|
|
|
- ShmOCPP16Data->CsMsg.bits[idxAC].RemoteStopTransactionReq = ON;
|
|
|
+ //ShmOCPP16Data->CsMsg.bits[idxAC].RemoteStopTransactionReq = ON;
|
|
|
+
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.isTriggerStop = ON;
|
|
|
+ DEBUG_INFO("AC isTriggerStop : [%d].\n", ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.isTriggerStop);
|
|
|
+ DEBUG_INFO("AC gun_index : [%d].\n", gun_index);
|
|
|
+ DEBUG_INFO("AC idxAC : [%d].\n", idxAC);
|
|
|
+
|
|
|
result = ON;
|
|
|
}
|
|
|
|
|
@@ -2149,7 +2186,13 @@ uint8_t stopConnectorCharging(uint8_t gun_index)
|
|
|
// AC
|
|
|
if(ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].SystemStatus != SYS_MODE_IDLE)
|
|
|
{
|
|
|
- ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq = ON;
|
|
|
+ //ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq = ON;
|
|
|
+
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.isTriggerStop = ON;
|
|
|
+ DEBUG_INFO("AC isTriggerStop : [%d].\n", ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.isTriggerStop);
|
|
|
+ DEBUG_INFO("AC gun_index : [%d].\n", gun_index);
|
|
|
+ DEBUG_INFO("AC idxAC : [%d].\n", idxAC);
|
|
|
+
|
|
|
result = ON;
|
|
|
}
|
|
|
|
|
@@ -2158,7 +2201,13 @@ uint8_t stopConnectorCharging(uint8_t gun_index)
|
|
|
// CHAdeMO
|
|
|
if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[idxCHAdeMO].SystemStatus != SYS_MODE_IDLE)
|
|
|
{
|
|
|
- ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq = ON;
|
|
|
+ //ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq = ON;
|
|
|
+
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ChademoChargingData[idxCHAdeMO].schedule.isTriggerStop = ON;
|
|
|
+ DEBUG_INFO("CHAdeMO isTriggerStop : [%d].\n", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[idxCHAdeMO].schedule.isTriggerStop);
|
|
|
+ DEBUG_INFO("CHAdeMO gun_index : [%d].\n", gun_index);
|
|
|
+ DEBUG_INFO("CHAdeMO idxCHAdeMO : [%d].\n", idxCHAdeMO);
|
|
|
+
|
|
|
result = ON;
|
|
|
}
|
|
|
|
|
@@ -2168,7 +2217,13 @@ uint8_t stopConnectorCharging(uint8_t gun_index)
|
|
|
// CCS
|
|
|
if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[idxCCS].SystemStatus != SYS_MODE_IDLE)
|
|
|
{
|
|
|
- ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq = ON;
|
|
|
+ //ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq = ON;
|
|
|
+
|
|
|
+ ShmSysConfigAndInfo->SysInfo.CcsChargingData[idxCCS].schedule.isTriggerStop = ON;
|
|
|
+ DEBUG_INFO("CCS isTriggerStop : [%d].\n", ShmSysConfigAndInfo->SysInfo.CcsChargingData[idxCCS].schedule.isTriggerStop);
|
|
|
+ DEBUG_INFO("CCS gun_index : [%d].\n", gun_index);
|
|
|
+ DEBUG_INFO("CCS idxCCS : [%d].\n", idxCCS);
|
|
|
+
|
|
|
result = ON;
|
|
|
}
|
|
|
|
|
@@ -2177,7 +2232,13 @@ uint8_t stopConnectorCharging(uint8_t gun_index)
|
|
|
// GBT
|
|
|
if(ShmSysConfigAndInfo->SysInfo.GbChargingData[idxGBT].SystemStatus != SYS_MODE_IDLE)
|
|
|
{
|
|
|
- ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq = ON;
|
|
|
+ //ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq = ON;
|
|
|
+
|
|
|
+ ShmSysConfigAndInfo->SysInfo.GbChargingData[idxGBT].schedule.isTriggerStop = ON;
|
|
|
+ DEBUG_INFO("GBT isTriggerStop : [%d].\n", ShmSysConfigAndInfo->SysInfo.GbChargingData[idxGBT].schedule.isTriggerStop);
|
|
|
+ DEBUG_INFO("GBT gun_index : [%d].\n", gun_index);
|
|
|
+ DEBUG_INFO("GBT idxCCS : [%d].\n", idxGBT);
|
|
|
+
|
|
|
result = ON;
|
|
|
}
|
|
|
|
|
@@ -2190,12 +2251,13 @@ uint8_t stopConnectorCharging(uint8_t gun_index)
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-void setConnectorSchedule(uint8_t gun_index, uint8_t *inputBuffer)
|
|
|
+uint8_t setConnectorSchedule(uint8_t gun_index, uint8_t *inputBuffer)
|
|
|
{
|
|
|
uint8_t idxAC = 0;
|
|
|
uint8_t idxCCS = 0;
|
|
|
uint8_t idxCHAdeMO = 0;
|
|
|
uint8_t idxGBT = 0;
|
|
|
+ uint8_t result = OFF;
|
|
|
uint8_t AC_GUN_IDX = 0;
|
|
|
|
|
|
if(ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'A')
|
|
@@ -2234,9 +2296,15 @@ void setConnectorSchedule(uint8_t gun_index, uint8_t *inputBuffer)
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.stopTimeHour = inputBuffer[15];
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.stopTimeMinute = inputBuffer[16];
|
|
|
|
|
|
- scheduleSaveToDb(localDb, gun_index, &ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule);
|
|
|
+ if(scheduleSaveToDb(localDb, gun_index, &ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule) == PASS)
|
|
|
+ result = ON;
|
|
|
+ else
|
|
|
+ result = OFF;
|
|
|
+
|
|
|
break;
|
|
|
}
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
else if(ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D')
|
|
|
{
|
|
@@ -2271,7 +2339,11 @@ void setConnectorSchedule(uint8_t gun_index, uint8_t *inputBuffer)
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.stopTimeHour = inputBuffer[15];
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.stopTimeMinute = inputBuffer[16];
|
|
|
|
|
|
- scheduleSaveToDb(localDb, gun_index, &ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule);
|
|
|
+ if(scheduleSaveToDb(localDb, gun_index, &ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule) == PASS)
|
|
|
+ result = ON;
|
|
|
+ else
|
|
|
+ result = OFF;
|
|
|
+
|
|
|
break;
|
|
|
case 'J':
|
|
|
ShmSysConfigAndInfo->SysInfo.ChademoChargingData[idxCHAdeMO].schedule.isEnable = inputBuffer[10];
|
|
@@ -2282,7 +2354,11 @@ void setConnectorSchedule(uint8_t gun_index, uint8_t *inputBuffer)
|
|
|
ShmSysConfigAndInfo->SysInfo.ChademoChargingData[idxCHAdeMO].schedule.stopTimeHour = inputBuffer[15];
|
|
|
ShmSysConfigAndInfo->SysInfo.ChademoChargingData[idxCHAdeMO].schedule.stopTimeMinute = inputBuffer[16];
|
|
|
|
|
|
- scheduleSaveToDb(localDb, gun_index, &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[idxCHAdeMO].schedule);
|
|
|
+ if(scheduleSaveToDb(localDb, gun_index, &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[idxCHAdeMO].schedule) == PASS)
|
|
|
+ result = ON;
|
|
|
+ else
|
|
|
+ result = OFF;
|
|
|
+
|
|
|
break;
|
|
|
case 'U':
|
|
|
case 'E':
|
|
@@ -2294,7 +2370,11 @@ void setConnectorSchedule(uint8_t gun_index, uint8_t *inputBuffer)
|
|
|
ShmSysConfigAndInfo->SysInfo.CcsChargingData[idxCCS].schedule.stopTimeHour = inputBuffer[15];
|
|
|
ShmSysConfigAndInfo->SysInfo.CcsChargingData[idxCCS].schedule.stopTimeMinute = inputBuffer[16];
|
|
|
|
|
|
- scheduleSaveToDb(localDb, gun_index, &ShmSysConfigAndInfo->SysInfo.CcsChargingData[idxCCS].schedule);
|
|
|
+ if(scheduleSaveToDb(localDb, gun_index, &ShmSysConfigAndInfo->SysInfo.CcsChargingData[idxCCS].schedule) == PASS)
|
|
|
+ result = ON;
|
|
|
+ else
|
|
|
+ result = OFF;
|
|
|
+
|
|
|
break;
|
|
|
case 'G':
|
|
|
ShmSysConfigAndInfo->SysInfo.GbChargingData[idxGBT].schedule.isEnable = inputBuffer[10];
|
|
@@ -2305,10 +2385,16 @@ void setConnectorSchedule(uint8_t gun_index, uint8_t *inputBuffer)
|
|
|
ShmSysConfigAndInfo->SysInfo.GbChargingData[idxGBT].schedule.stopTimeHour = inputBuffer[15];
|
|
|
ShmSysConfigAndInfo->SysInfo.GbChargingData[idxGBT].schedule.stopTimeMinute = inputBuffer[16];
|
|
|
|
|
|
- scheduleSaveToDb(localDb, gun_index, &ShmSysConfigAndInfo->SysInfo.GbChargingData[idxGBT].schedule);
|
|
|
+ if(scheduleSaveToDb(localDb, gun_index, &ShmSysConfigAndInfo->SysInfo.GbChargingData[idxGBT].schedule) == PASS)
|
|
|
+ result = ON;
|
|
|
+ else
|
|
|
+ result = OFF;
|
|
|
+
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
void getConnectorUser(uint8_t gun_index, uint8_t *outBuffer)
|
|
@@ -2429,8 +2515,16 @@ void checkSchedule()
|
|
|
{
|
|
|
for(int gun_index=0;gun_index<(AC_QUANTITY+CHAdeMO_QUANTITY+CCS_QUANTITY+GB_QUANTITY);gun_index++)
|
|
|
{
|
|
|
+ idxAC = 0;
|
|
|
+ idxCCS = 0;
|
|
|
+ idxCHAdeMO = 0;
|
|
|
+ idxGBT = 0;
|
|
|
+ AC_GUN_IDX = 0;
|
|
|
+
|
|
|
if(ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'A')
|
|
|
{
|
|
|
+ DEBUG_INFO("Schedule gun_index : [%d].\n", gun_index);
|
|
|
+
|
|
|
if(gun_index == 2)
|
|
|
{
|
|
|
AC_GUN_IDX = 0;
|
|
@@ -2444,16 +2538,30 @@ void checkSchedule()
|
|
|
AC_GUN_IDX = 2;
|
|
|
}
|
|
|
|
|
|
+ DEBUG_INFO("Schedule AC_GUN_IDX : [%d].\n", AC_GUN_IDX);
|
|
|
+
|
|
|
for(uint8_t idx=0;idx<AC_GUN_IDX;idx++)
|
|
|
{
|
|
|
switch(ShmSysConfigAndInfo->SysConfig.ModelName[9-idx])
|
|
|
{
|
|
|
case '1' ... '6':
|
|
|
idxAC++;
|
|
|
+
|
|
|
+ //DEBUG_INFO("Schedule idxAC : [%d].\n", idxAC);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ DEBUG_INFO("++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
+ DEBUG_INFO("idxAC : [%d].\n", idxAC);
|
|
|
+ DEBUG_INFO("AC Schedule isEnable : [%d].\n", ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.isEnable);
|
|
|
+ DEBUG_INFO("AC Schedule scheduleMethod : [%d].\n", ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.scheduleMethod);
|
|
|
+ DEBUG_INFO("AC Schedule startTimeHour : [%d] >> tm->tm_hour : [%d].\n", ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.startTimeHour, tm->tm_hour);
|
|
|
+ DEBUG_INFO("AC Schedule startTimeMinute : [%d] >> tm->tm_min : [%d].\n", ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.startTimeMinute, tm->tm_min);
|
|
|
+ DEBUG_INFO("AC Schedule stopTimeHour : [%d] >> tm->tm_hourr : [%d].\n", ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.stopTimeHour, tm->tm_hour);
|
|
|
+ DEBUG_INFO("AC Schedule stopTimeMinute : [%d] >> tm->tm_min : [%d].\n", ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.stopTimeMinute, tm->tm_min);
|
|
|
+ DEBUG_INFO("++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
+
|
|
|
switch(ShmSysConfigAndInfo->SysConfig.ModelName[9-AC_GUN_IDX])
|
|
|
{
|
|
|
case '1' ... '6':
|
|
@@ -2491,6 +2599,7 @@ void checkSchedule()
|
|
|
scheduleSaveToDb(localDb, gun_index, &ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -2519,6 +2628,17 @@ void checkSchedule()
|
|
|
switch(ShmSysConfigAndInfo->SysConfig.ModelName[7+gun_index])
|
|
|
{
|
|
|
case '1' ... '6':
|
|
|
+
|
|
|
+ DEBUG_INFO("++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
+ DEBUG_INFO("idxAC : [%d].\n", idxAC);
|
|
|
+ DEBUG_INFO("AC Schedule isEnable : [%d].\n", ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.isEnable);
|
|
|
+ DEBUG_INFO("AC Schedule scheduleMethod : [%d].\n", ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.scheduleMethod);
|
|
|
+ DEBUG_INFO("AC Schedule startTimeHour : [%d] >> tm->tm_hour : [%d].\n", ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.startTimeHour, tm->tm_hour);
|
|
|
+ DEBUG_INFO("AC Schedule startTimeMinute : [%d] >> tm->tm_min : [%d].\n", ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.startTimeMinute, tm->tm_min);
|
|
|
+ DEBUG_INFO("AC Schedule stopTimeHour : [%d] >> tm->tm_hourr : [%d].\n", ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.stopTimeHour, tm->tm_hour);
|
|
|
+ DEBUG_INFO("AC Schedule stopTimeMinute : [%d] >> tm->tm_min : [%d].\n", ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.stopTimeMinute, tm->tm_min);
|
|
|
+ DEBUG_INFO("++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
+
|
|
|
// AC
|
|
|
// Check schedule start
|
|
|
if((ShmSysConfigAndInfo->SysInfo.AcChargingData[idxAC].schedule.isEnable) &&
|
|
@@ -2557,6 +2677,17 @@ void checkSchedule()
|
|
|
|
|
|
break;
|
|
|
case 'J':
|
|
|
+
|
|
|
+ DEBUG_INFO("++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
+ DEBUG_INFO("idxCHAdeMO : [%d].\n", idxCHAdeMO);
|
|
|
+ DEBUG_INFO("CHAdeMO Schedule isEnable : [%d].\n", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[idxCHAdeMO].schedule.isEnable);
|
|
|
+ DEBUG_INFO("CHAdeMO Schedule scheduleMethod : [%d].\n", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[idxCHAdeMO].schedule.scheduleMethod);
|
|
|
+ DEBUG_INFO("CHAdeMO Schedule startTimeHour : [%d] >> tm->tm_hour : [%d].\n", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[idxCHAdeMO].schedule.startTimeHour, tm->tm_hour);
|
|
|
+ DEBUG_INFO("CHAdeMO Schedule startTimeMinute : [%d] >> tm->tm_min : [%d].\n", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[idxCHAdeMO].schedule.startTimeMinute, tm->tm_min);
|
|
|
+ DEBUG_INFO("CHAdeMO Schedule stopTimeHour : [%d] >> tm->tm_hourr : [%d].\n", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[idxCHAdeMO].schedule.stopTimeHour, tm->tm_hour);
|
|
|
+ DEBUG_INFO("CHAdeMO Schedule stopTimeMinute : [%d] >> tm->tm_min : [%d].\n", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[idxCHAdeMO].schedule.stopTimeMinute, tm->tm_min);
|
|
|
+ DEBUG_INFO("++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
+
|
|
|
// CHAdeMO
|
|
|
// Check schedule start
|
|
|
if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[idxCHAdeMO].schedule.isEnable) &&
|
|
@@ -2596,6 +2727,17 @@ void checkSchedule()
|
|
|
break;
|
|
|
case 'U':
|
|
|
case 'E':
|
|
|
+
|
|
|
+ DEBUG_INFO("++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
+ DEBUG_INFO("idxCCS : [%d].\n", idxCCS);
|
|
|
+ DEBUG_INFO("CCS Schedule isEnable : [%d].\n", ShmSysConfigAndInfo->SysInfo.CcsChargingData[idxCCS].schedule.isEnable);
|
|
|
+ DEBUG_INFO("CCS Schedule scheduleMethod : [%d].\n", ShmSysConfigAndInfo->SysInfo.CcsChargingData[idxCCS].schedule.scheduleMethod);
|
|
|
+ DEBUG_INFO("CCS Schedule startTimeHour : [%d] >> tm->tm_hour : [%d].\n", ShmSysConfigAndInfo->SysInfo.CcsChargingData[idxCCS].schedule.startTimeHour, tm->tm_hour);
|
|
|
+ DEBUG_INFO("CCS Schedule startTimeMinute : [%d] >> tm->tm_min : [%d].\n", ShmSysConfigAndInfo->SysInfo.CcsChargingData[idxCCS].schedule.startTimeMinute, tm->tm_min);
|
|
|
+ DEBUG_INFO("CCS Schedule stopTimeHour : [%d] >> tm->tm_hourr : [%d].\n", ShmSysConfigAndInfo->SysInfo.CcsChargingData[idxCCS].schedule.stopTimeHour, tm->tm_hour);
|
|
|
+ DEBUG_INFO("CCS Schedule stopTimeMinute : [%d] >> tm->tm_min : [%d].\n", ShmSysConfigAndInfo->SysInfo.CcsChargingData[idxCCS].schedule.stopTimeMinute, tm->tm_min);
|
|
|
+ DEBUG_INFO("++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
+
|
|
|
// CCS
|
|
|
// Check schedule start
|
|
|
if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[idxCCS].schedule.isEnable) &&
|
|
@@ -2634,6 +2776,17 @@ void checkSchedule()
|
|
|
|
|
|
break;
|
|
|
case 'G':
|
|
|
+
|
|
|
+ DEBUG_INFO("++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
+ DEBUG_INFO("idxGBT : [%d].\n", idxGBT);
|
|
|
+ DEBUG_INFO("GBT Schedule isEnable : [%d].\n", ShmSysConfigAndInfo->SysInfo.GbChargingData[idxGBT].schedule.isEnable);
|
|
|
+ DEBUG_INFO("GBT Schedule scheduleMethod : [%d].\n", ShmSysConfigAndInfo->SysInfo.GbChargingData[idxGBT].schedule.scheduleMethod);
|
|
|
+ DEBUG_INFO("GBT Schedule startTimeHour : [%d] >> tm->tm_hour : [%d].\n", ShmSysConfigAndInfo->SysInfo.GbChargingData[idxGBT].schedule.startTimeHour, tm->tm_hour);
|
|
|
+ DEBUG_INFO("GBT Schedule startTimeMinute : [%d] >> tm->tm_min : [%d].\n", ShmSysConfigAndInfo->SysInfo.GbChargingData[idxGBT].schedule.startTimeMinute, tm->tm_min);
|
|
|
+ DEBUG_INFO("GBT Schedule stopTimeHour : [%d] >> tm->tm_hourr : [%d].\n", ShmSysConfigAndInfo->SysInfo.GbChargingData[idxGBT].schedule.stopTimeHour, tm->tm_hour);
|
|
|
+ DEBUG_INFO("GBT Schedule stopTimeMinute : [%d] >> tm->tm_min : [%d].\n", ShmSysConfigAndInfo->SysInfo.GbChargingData[idxGBT].schedule.stopTimeMinute, tm->tm_min);
|
|
|
+ DEBUG_INFO("++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
+
|
|
|
// GBT
|
|
|
// Check schedule start
|
|
|
if((ShmSysConfigAndInfo->SysInfo.GbChargingData[idxGBT].schedule.isEnable) &&
|
|
@@ -2883,12 +3036,12 @@ int tcpSocketServerStart(void)
|
|
|
outBuffer[2] = 0x00;
|
|
|
outBuffer[3] = 0x08;
|
|
|
outBuffer[4] = WIFI_CMD_PROTOCOL_VERSION;
|
|
|
- outBuffer[5] = (protocol_Version[0] >> 0x00) & 0xff;
|
|
|
- outBuffer[6] = (protocol_Version[0] >> 0x08) & 0xff;
|
|
|
- outBuffer[7] = (protocol_Version[1] >> 0x00) & 0xff;
|
|
|
- outBuffer[8] = (protocol_Version[1] >> 0x08) & 0xff;
|
|
|
- outBuffer[9] = (protocol_Version[2] >> 0x00) & 0xff;
|
|
|
- outBuffer[10] = (protocol_Version[2] >> 0x08) & 0xff;
|
|
|
+ outBuffer[5] = (protocol_Version[0] >> 0x08) & 0xff;
|
|
|
+ outBuffer[6] = (protocol_Version[0] >> 0x00) & 0xff;
|
|
|
+ outBuffer[7] = (protocol_Version[1] >> 0x08) & 0xff;
|
|
|
+ outBuffer[8] = (protocol_Version[1] >> 0x00) & 0xff;
|
|
|
+ outBuffer[9] = (protocol_Version[2] >> 0x08) & 0xff;
|
|
|
+ outBuffer[10] = (protocol_Version[2] >> 0x00) & 0xff;
|
|
|
outBuffer[11] = chksumCal(outBuffer);
|
|
|
|
|
|
break;
|
|
@@ -3169,7 +3322,7 @@ int tcpSocketServerStart(void)
|
|
|
break;
|
|
|
case WIFI_CMD_GET_SCHEDULE:
|
|
|
DEBUG_INFO("Receive get connector-%02d schedule command.\n", inputBuffer[9]);
|
|
|
- tx_size = 10;
|
|
|
+ tx_size = 14;
|
|
|
outBuffer[0] = 0xff;
|
|
|
outBuffer[1] = 0xff;
|
|
|
outBuffer[2] = 0x00;
|
|
@@ -3177,7 +3330,7 @@ int tcpSocketServerStart(void)
|
|
|
outBuffer[4] = WIFI_CMD_GET_SCHEDULE;
|
|
|
outBuffer[5] = inputBuffer[9];
|
|
|
getConnectorSchedule(inputBuffer[9], outBuffer);
|
|
|
- outBuffer[14] = chksumCal(outBuffer);
|
|
|
+ outBuffer[13] = chksumCal(outBuffer);
|
|
|
|
|
|
break;
|
|
|
case WIFI_CMD_GET_NETWORK_STS:
|
|
@@ -3676,7 +3829,7 @@ int tcpSocketServerStart(void)
|
|
|
DEBUG_INFO("Schedule stop hour: %d.\n", inputBuffer[15]);
|
|
|
DEBUG_INFO("Schedule stop minute: %d.\n", inputBuffer[16]);
|
|
|
|
|
|
- setConnectorSchedule(inputBuffer[9], inputBuffer);
|
|
|
+ //setConnectorSchedule(inputBuffer[9], inputBuffer);
|
|
|
|
|
|
tx_size = 7;
|
|
|
outBuffer[0] = 0xff;
|
|
@@ -3684,7 +3837,7 @@ int tcpSocketServerStart(void)
|
|
|
outBuffer[2] = 0x00;
|
|
|
outBuffer[3] = 0x03;
|
|
|
outBuffer[4] = WIFI_CMD_SET_SCHEDULE;
|
|
|
- outBuffer[5] = 0x01;
|
|
|
+ outBuffer[5] = (setConnectorSchedule(inputBuffer[9], inputBuffer)?0x01:0x00);
|
|
|
outBuffer[6] = chksumCal(outBuffer);
|
|
|
|
|
|
break;
|
|
@@ -3847,7 +4000,8 @@ int tcpSocketServerStart(void)
|
|
|
|
|
|
break;
|
|
|
case WIFI_CMD_SET_WIFI_NETMASK:
|
|
|
- DEBUG_INFO("Receive set wifi submake command.\n"); DEBUG_INFO("Submask adress: %d.%d.%d.%d\n", inputBuffer[9], inputBuffer[10], inputBuffer[11], inputBuffer[12]);
|
|
|
+ DEBUG_INFO("Receive set wifi submake command.\n");
|
|
|
+ DEBUG_INFO("Submask adress: %d.%d.%d.%d\n", inputBuffer[9], inputBuffer[10], inputBuffer[11], inputBuffer[12]);
|
|
|
memset(SysConfigTemporarily.AthInterface.WifiSubmaskAddress, 0x00, ARRAY_SIZE(SysConfigTemporarily.AthInterface.WifiSubmaskAddress));
|
|
|
memcpy(SysConfigTemporarily.AthInterface.WifiSubmaskAddress, &inputBuffer[9], (((inputBuffer[2] << 8) | inputBuffer[3])-6));
|
|
|
DEBUG_INFO("Submask adress: %s\n", SysConfigTemporarily.AthInterface.WifiSubmaskAddress);
|
|
@@ -4607,6 +4761,11 @@ int main(void)
|
|
|
sleep(5);
|
|
|
system("ifconfig wlan0 up");
|
|
|
#endif
|
|
|
+
|
|
|
+ DEBUG_INFO("========================================\n");
|
|
|
+ DEBUG_INFO("Latest Firmware Version : [ %s ].\n", Version_And_Date[0]);
|
|
|
+ DEBUG_INFO("Latest Upgrade Date : [ %s ].\n", Version_And_Date[1]);
|
|
|
+ DEBUG_INFO("========================================\n");
|
|
|
|
|
|
DEBUG_INFO("=================[State 0]===================\n");
|
|
|
for(;;)
|