|
@@ -34,6 +34,7 @@
|
|
|
#include <time.h>
|
|
|
#include <ctype.h>
|
|
|
#include <ifaddrs.h>
|
|
|
+#include <sqlite3.h>
|
|
|
#include "define.h"
|
|
|
|
|
|
#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
@@ -78,8 +79,14 @@
|
|
|
#define UBLOX
|
|
|
//#define MT7601U
|
|
|
|
|
|
+#define DB_FILE "/Storage/ChargeLog/puk_pin_list.db"
|
|
|
+
|
|
|
enum WIFI_COMMAND
|
|
|
{
|
|
|
+ WIFI_CMD_LOGIN_SIGNIN = 0x01,
|
|
|
+ WIFI_CMD_LOGIN_AUTH_PUK = 0x02,
|
|
|
+ WIFI_CMD_LOGIN_GET_USER_ID = 0x03,
|
|
|
+
|
|
|
WIFI_CMD_GET_MODEL_NAME = 0x0d,
|
|
|
WIFI_CMD_GET_SERIAL_NNUMBER = 0x0e,
|
|
|
WIFI_CMD_GET_SYSTEM_TIME = 0x0f,
|
|
@@ -149,6 +156,13 @@ enum WIFI_COMMAND
|
|
|
|
|
|
};
|
|
|
|
|
|
+enum LOGIN_ROLE
|
|
|
+{
|
|
|
+ ROLE_UNKNOWN = 0x00,
|
|
|
+ ROLE_MANAGER = 0x01,
|
|
|
+ ROLE_USER = 0x02
|
|
|
+};
|
|
|
+
|
|
|
struct interface_info
|
|
|
{
|
|
|
int ipType;
|
|
@@ -178,6 +192,13 @@ struct auth_info
|
|
|
unsigned char passwd[256];
|
|
|
}Wifi_A;
|
|
|
|
|
|
+struct WIFI_LOGIN_INFO
|
|
|
+{
|
|
|
+ uint8_t puk[8];
|
|
|
+ uint8_t loginRole;
|
|
|
+ uint8_t loginId[32];
|
|
|
+}wifi_login_info;
|
|
|
+
|
|
|
struct SysConfigAndInfo *ShmSysConfigAndInfo;
|
|
|
struct StatusCodeData *ShmStatusCodeData;
|
|
|
struct OCPP16Data *ShmOCPP16Data;
|
|
@@ -198,6 +219,7 @@ int isSetWPA_OK = false;
|
|
|
int cnt_pingDNS_Fail;
|
|
|
int cnt_getAP_Fail;
|
|
|
int cnt_getIP_Fail;
|
|
|
+sqlite3 *localDb;
|
|
|
|
|
|
void trim(char *s);
|
|
|
int mystrcmp(char *p1,char *p2);
|
|
@@ -887,8 +909,8 @@ int udpSocketServerStart(void)
|
|
|
|
|
|
outBuffer[0] = 0xff;
|
|
|
outBuffer[1] = 0xff;
|
|
|
- outBuffer[2] = (0x1a << 0x08) & 0xff;
|
|
|
- outBuffer[3] = 0x1a;
|
|
|
+ outBuffer[2] = (0x25 << 0x08) & 0xff;
|
|
|
+ outBuffer[3] = 0x25 & 0xff;
|
|
|
outBuffer[4] = 0x00;
|
|
|
if(parseIP(ip)==PASS)
|
|
|
{
|
|
@@ -942,9 +964,306 @@ int udpSocketServerStart(void)
|
|
|
return FAIL;
|
|
|
}
|
|
|
|
|
|
+//===============================================
|
|
|
+// SQLite3 related routine
|
|
|
+//===============================================
|
|
|
+int DB_Open(sqlite3 *db)
|
|
|
+{
|
|
|
+ int result = PASS;
|
|
|
+ char* errMsg = NULL;
|
|
|
+ char* createSql="CREATE TABLE IF NOT EXISTS list("
|
|
|
+ "idx integer primary key AUTOINCREMENT, "
|
|
|
+ "list_type text, "
|
|
|
+ "code text, "
|
|
|
+ "user_id text, "
|
|
|
+ "isReg text"
|
|
|
+ ");";
|
|
|
+
|
|
|
+ //sqlite3_config(SQLITE_CONFIG_URI, 1);
|
|
|
+ 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 puk/pin list database open successfully.\r\n");
|
|
|
+ if (sqlite3_exec(db, createSql, 0, 0, &errMsg) != SQLITE_OK)
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ DEBUG_INFO( "Create puk/pin list table error message: %s\n", errMsg);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_INFO( "Opened puk/pin list table successfully\n");
|
|
|
+ }
|
|
|
+ sqlite3_close(db);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+uint8_t isPukReg(sqlite3 *db)
|
|
|
+{
|
|
|
+ uint8_t result = false;
|
|
|
+ char* errMsg = NULL;
|
|
|
+ char sqlStr[1024];
|
|
|
+ char **rs;
|
|
|
+ int rows, cols;
|
|
|
+
|
|
|
+ sprintf(sqlStr, "select * from list where list_type='puk';");
|
|
|
+ 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 puk/pin list database open successfully.\r\n");
|
|
|
+ sqlite3_get_table(db, sqlStr, &rs, &rows, &cols, &errMsg);
|
|
|
+
|
|
|
+ if(rows>0)
|
|
|
+ result = true;
|
|
|
+
|
|
|
+ sqlite3_free_table(rs);
|
|
|
+ sqlite3_close(db);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+uint8_t PukReg(sqlite3 *db)
|
|
|
+{
|
|
|
+ uint8_t result = false;
|
|
|
+ char* errMsg = NULL;
|
|
|
+ char sqlStr[1024];
|
|
|
+
|
|
|
+ sprintf(sqlStr, "insert into list(list_type, code, user_id, isReg) "
|
|
|
+ "values('puk', '%s', '%s', '1');",
|
|
|
+ wifi_login_info.puk,
|
|
|
+ wifi_login_info.loginId);
|
|
|
+ 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 puk/pin list database open successfully.\r\n");
|
|
|
+ if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ DEBUG_INFO( "Insert puk/pin list error message: %s\n", errMsg);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_INFO( "Insert puk/pin list successfully\n");
|
|
|
+ }
|
|
|
+ sqlite3_close(db);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+uint8_t isPinGen(sqlite3 *db)
|
|
|
+{
|
|
|
+ uint8_t result = false;
|
|
|
+ char* errMsg = NULL;
|
|
|
+ char sqlStr[1024];
|
|
|
+ char **rs;
|
|
|
+ int rows, cols;
|
|
|
+
|
|
|
+ sprintf(sqlStr, "select * from list where list_type='pin';");
|
|
|
+ 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 puk/pin list database open successfully.\r\n");
|
|
|
+ sqlite3_get_table(db, sqlStr, &rs, &rows, &cols, &errMsg);
|
|
|
+
|
|
|
+ if(rows>0)
|
|
|
+ result = true;
|
|
|
+
|
|
|
+ sqlite3_free_table(rs);
|
|
|
+ sqlite3_close(db);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+uint8_t PinGen(sqlite3 *db)
|
|
|
+{
|
|
|
+ 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 puk/pin list database open successfully.\r\n");
|
|
|
+
|
|
|
+ sprintf(sqlStr, "delete from list where list_type='pin';");
|
|
|
+ DEBUG_INFO("sqlStr= %s\r\n", sqlStr);
|
|
|
+ if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ DEBUG_INFO( "Delete puk/pin list error message: %s\n", errMsg);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ for(int idxList=0;idxList<20;idxList++)
|
|
|
+ {
|
|
|
+ sprintf(sqlStr, "insert into list(list_type, code, user_id, isReg) "
|
|
|
+ "values('pin', '%06X', '', '0');", (rand() % 0xffffff));
|
|
|
+ DEBUG_INFO("sqlStr= %s\r\n", sqlStr);
|
|
|
+
|
|
|
+ if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ DEBUG_INFO( "Insert puk/pin list error message: %s\n", errMsg);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_INFO( "Insert puk/pin list successfully\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlite3_close(db);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+uint8_t isValidPin(sqlite3 *db, uint8_t *pinCode)
|
|
|
+{
|
|
|
+ uint8_t result = false;
|
|
|
+ char* errMsg = NULL;
|
|
|
+ char sqlStr[1024];
|
|
|
+ char **rs;
|
|
|
+ int rows, cols;
|
|
|
+
|
|
|
+ sprintf(sqlStr, "select * from list where list_type='pin' and code='%s';", pinCode);
|
|
|
+ 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 puk/pin list database open successfully.\r\n");
|
|
|
+ sqlite3_get_table(db, sqlStr, &rs, &rows, &cols, &errMsg);
|
|
|
+
|
|
|
+ if(rows>0)
|
|
|
+ result = true;
|
|
|
+
|
|
|
+ sqlite3_free_table(rs);
|
|
|
+ sqlite3_close(db);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+uint8_t loginValid(sqlite3 *db)
|
|
|
+{
|
|
|
+ uint8_t result = ROLE_UNKNOWN;
|
|
|
+ char* errMsg = NULL;
|
|
|
+ char sqlStr[1024];
|
|
|
+ char **rs;
|
|
|
+ int rows, cols;
|
|
|
+
|
|
|
+ sprintf(sqlStr, "select * from list where user_id='%s';", wifi_login_info.loginId);
|
|
|
+ DEBUG_INFO("sqlStr= %s\r\n", sqlStr);
|
|
|
+ DEBUG_INFO("Login id: %s\r\n", wifi_login_info.loginId);
|
|
|
+
|
|
|
+ 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 puk/pin list database open successfully.\r\n");
|
|
|
+ sqlite3_get_table(db, sqlStr, &rs, &rows, &cols, &errMsg);
|
|
|
+
|
|
|
+ for(int idxRow=0;idxRow<rows;idxRow++)
|
|
|
+ {
|
|
|
+ if(strcmp(rs[(idxRow*cols)+1], "puk") == 0)
|
|
|
+ {
|
|
|
+ result = ROLE_MANAGER;
|
|
|
+ DEBUG_INFO("Login role: Manager\r\n");
|
|
|
+ }
|
|
|
+ else if(strcmp(rs[(idxRow*cols)+1], "pin") == 0)
|
|
|
+ {
|
|
|
+ result = ROLE_USER;
|
|
|
+ DEBUG_INFO("Login role: User\r\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlite3_free_table(rs);
|
|
|
+ sqlite3_close(db);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
//==========================================
|
|
|
// TCP socket server routine
|
|
|
//==========================================
|
|
|
+uint32_t stm32crc(uint32_t *ptr, uint32_t len)
|
|
|
+{
|
|
|
+ uint32_t xbit, data;
|
|
|
+ uint32_t crc32 = 0xFFFFFFFF;
|
|
|
+ const uint32_t polynomial = 0x04c11db7;
|
|
|
+
|
|
|
+ for(uint8_t i = 0; i < len; i ++)
|
|
|
+ {
|
|
|
+ xbit = 1 << 31;
|
|
|
+ data = ptr[i];
|
|
|
+
|
|
|
+ for (uint32_t bits = 0; bits < 32; bits++)
|
|
|
+ {
|
|
|
+ if (crc32 & 0x80000000)
|
|
|
+ {
|
|
|
+ crc32 <<= 1;
|
|
|
+ crc32 ^= polynomial;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ crc32 <<= 1;
|
|
|
+
|
|
|
+ if (data & xbit)
|
|
|
+ crc32 ^= polynomial;
|
|
|
+
|
|
|
+ xbit >>= 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return crc32;
|
|
|
+}
|
|
|
+
|
|
|
int isValidCheckSum(uint8_t *message)
|
|
|
{
|
|
|
uint8_t chksum=0;
|
|
@@ -1398,6 +1717,138 @@ int tcpSocketServerStart(void)
|
|
|
|
|
|
switch(inputBuffer[8])
|
|
|
{
|
|
|
+ case WIFI_CMD_LOGIN_SIGNIN:
|
|
|
+ memset(&wifi_login_info.loginId[0], 0x00, ARRAY_SIZE(wifi_login_info.loginId));
|
|
|
+ memcpy((char*)&wifi_login_info.loginId[0], (char*)&inputBuffer[9], (((inputBuffer[2] << 8)| inputBuffer[3])-6));
|
|
|
+ wifi_login_info.loginRole = loginValid(localDb);
|
|
|
+ DEBUG_INFO("Login user id: %s\r\n", wifi_login_info.loginId);
|
|
|
+ DEBUG_INFO("User id: %d\r\n", wifi_login_info.loginRole);
|
|
|
+
|
|
|
+ tx_size = 7;
|
|
|
+ outBuffer[0] = 0xff;
|
|
|
+ outBuffer[1] = 0xff;
|
|
|
+ outBuffer[2] = 0x00;
|
|
|
+ outBuffer[3] = 0x03;
|
|
|
+ outBuffer[4] = WIFI_CMD_LOGIN_SIGNIN;
|
|
|
+ switch(wifi_login_info.loginRole)
|
|
|
+ {
|
|
|
+ case ROLE_MANAGER:
|
|
|
+ case ROLE_USER:
|
|
|
+ // Login success
|
|
|
+ outBuffer[5] = 0x02;
|
|
|
+ break;
|
|
|
+ case ROLE_UNKNOWN:
|
|
|
+ default:
|
|
|
+ if(!isPukReg(localDb))
|
|
|
+ {
|
|
|
+ // Login fail, PUK never be registered
|
|
|
+ outBuffer[5] = 0x01;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // Login fail
|
|
|
+ outBuffer[5] = 0x00;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ outBuffer[6] = chksumCal(outBuffer);
|
|
|
+
|
|
|
+ break;
|
|
|
+ case WIFI_CMD_LOGIN_AUTH_PUK:
|
|
|
+ if(!isPukReg(localDb))
|
|
|
+ {
|
|
|
+ // PUK never be registered
|
|
|
+ if((wifi_login_info.puk[0] == inputBuffer[9]) &&
|
|
|
+ (wifi_login_info.puk[1] == inputBuffer[10]) &&
|
|
|
+ (wifi_login_info.puk[2] == inputBuffer[11]) &&
|
|
|
+ (wifi_login_info.puk[3] == inputBuffer[12]) &&
|
|
|
+ (wifi_login_info.puk[4] == inputBuffer[13]) &&
|
|
|
+ (wifi_login_info.puk[5] == inputBuffer[14]) &&
|
|
|
+ (wifi_login_info.puk[6] == inputBuffer[15]) &&
|
|
|
+ (wifi_login_info.puk[7] == inputBuffer[16]))
|
|
|
+ {
|
|
|
+ // PUK valid success
|
|
|
+ if(PukReg(localDb))
|
|
|
+ {
|
|
|
+ // PUK registered success
|
|
|
+ tx_size = 7 + strlen((char*)wifi_login_info.loginId);
|
|
|
+ outBuffer[0] = 0xff;
|
|
|
+ outBuffer[1] = 0xff;
|
|
|
+ outBuffer[2] = ((0x03 + strlen((char*)wifi_login_info.loginId))>>8)&0xff;
|
|
|
+ outBuffer[3] = (0x03 + strlen((char*)wifi_login_info.loginId)) & 0xff;
|
|
|
+ outBuffer[4] = WIFI_CMD_LOGIN_AUTH_PUK;
|
|
|
+ outBuffer[5] = 0x01;
|
|
|
+ memcpy(&outBuffer[6], wifi_login_info.loginId, strlen((char*)wifi_login_info.loginId));
|
|
|
+ outBuffer[6+strlen((char*)wifi_login_info.loginId)] = chksumCal(outBuffer);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // PUK registered fail
|
|
|
+ tx_size = 7;
|
|
|
+ outBuffer[0] = 0xff;
|
|
|
+ outBuffer[1] = 0xff;
|
|
|
+ outBuffer[2] = 0x00;
|
|
|
+ outBuffer[3] = 0x03;
|
|
|
+ outBuffer[4] = WIFI_CMD_LOGIN_AUTH_PUK;
|
|
|
+ outBuffer[5] = 0x00;
|
|
|
+ outBuffer[6] = chksumCal(outBuffer);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // PUK valid fail
|
|
|
+ tx_size = 7;
|
|
|
+ outBuffer[0] = 0xff;
|
|
|
+ outBuffer[1] = 0xff;
|
|
|
+ outBuffer[2] = 0x00;
|
|
|
+ outBuffer[3] = 0x03;
|
|
|
+ outBuffer[4] = WIFI_CMD_LOGIN_AUTH_PUK;
|
|
|
+ outBuffer[5] = 0x00;
|
|
|
+ outBuffer[6] = chksumCal(outBuffer);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // PUK already be registered
|
|
|
+ tx_size = 7;
|
|
|
+ outBuffer[0] = 0xff;
|
|
|
+ outBuffer[1] = 0xff;
|
|
|
+ outBuffer[2] = 0x00;
|
|
|
+ outBuffer[3] = 0x03;
|
|
|
+ outBuffer[4] = WIFI_CMD_LOGIN_AUTH_PUK;
|
|
|
+ outBuffer[5] = 0x02;
|
|
|
+ outBuffer[6] = chksumCal(outBuffer);
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ case WIFI_CMD_LOGIN_GET_USER_ID:
|
|
|
+ if(wifi_login_info.loginRole != ROLE_UNKNOWN)
|
|
|
+ {
|
|
|
+ // Login role is Manager or User
|
|
|
+ tx_size = 7 + strlen((char*)wifi_login_info.loginId);
|
|
|
+ outBuffer[0] = 0xff;
|
|
|
+ outBuffer[1] = 0xff;
|
|
|
+ outBuffer[2] = ((0x03 + strlen((char*)wifi_login_info.loginId))>>8)&0xff;
|
|
|
+ outBuffer[3] = (0x03 + strlen((char*)wifi_login_info.loginId)) & 0xff;
|
|
|
+ outBuffer[4] = WIFI_CMD_LOGIN_GET_USER_ID;
|
|
|
+ outBuffer[5] = 0x01;
|
|
|
+ memcpy(&outBuffer[6], wifi_login_info.loginId, strlen((char*)wifi_login_info.loginId));
|
|
|
+ outBuffer[6+strlen((char*)wifi_login_info.loginId)] = chksumCal(outBuffer);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // Login role is Unknown
|
|
|
+ tx_size = 7;
|
|
|
+ outBuffer[0] = 0xff;
|
|
|
+ outBuffer[1] = 0xff;
|
|
|
+ outBuffer[2] = 0x00;
|
|
|
+ outBuffer[3] = 0x03;
|
|
|
+ outBuffer[4] = WIFI_CMD_LOGIN_GET_USER_ID;
|
|
|
+ outBuffer[5] = 0x00;
|
|
|
+ outBuffer[6] = chksumCal(outBuffer);
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
case WIFI_CMD_GET_MODEL_NAME:
|
|
|
tx_size = 70;
|
|
|
outBuffer[0] = 0xff;
|
|
@@ -2206,6 +2657,9 @@ int tcpSocketServerStart(void)
|
|
|
if(read_size == 0)
|
|
|
{
|
|
|
DEBUG_INFO("Client disconnected.\r\n");
|
|
|
+ wifi_login_info.loginRole = ROLE_UNKNOWN;
|
|
|
+ memset(&wifi_login_info.loginId[0], 0x00, ARRAY_SIZE(wifi_login_info.loginId));
|
|
|
+
|
|
|
fflush(stdout);
|
|
|
}
|
|
|
else if(read_size == -1)
|
|
@@ -2650,9 +3104,8 @@ int main(void)
|
|
|
|
|
|
if(InitShareMemory() == FAIL)
|
|
|
{
|
|
|
- #ifdef SystemLogMessage
|
|
|
DEBUG_ERROR("InitShareMemory NG\n");
|
|
|
- #endif
|
|
|
+
|
|
|
if(ShmStatusCodeData!=NULL)
|
|
|
{
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=ON;
|
|
@@ -2661,6 +3114,20 @@ int main(void)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+ // Local database initial
|
|
|
+ if(DB_Open(localDb) != PASS)
|
|
|
+ {
|
|
|
+ DEBUG_ERROR("Puk pin list local db initial fail.\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ // Wifi login info initial & PUK generate
|
|
|
+ wifi_login_info.loginRole = ROLE_UNKNOWN;
|
|
|
+ memset(&wifi_login_info.loginId[0], 0x00, ARRAY_SIZE(wifi_login_info.loginId));
|
|
|
+ memset(&wifi_login_info.puk[0], 0x00, ARRAY_SIZE(wifi_login_info.puk));
|
|
|
+ sprintf((char*)wifi_login_info.puk, "%08X", ~stm32crc((uint32_t*)&ShmSysConfigAndInfo->SysConfig.SystemId[0], (ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.SystemId)>>2)));
|
|
|
+ DEBUG_INFO("System ID: %s\r\n", ShmSysConfigAndInfo->SysConfig.SystemId);
|
|
|
+ DEBUG_INFO("EVSE PUK: %s\r\n", wifi_login_info.puk);
|
|
|
+
|
|
|
// UDP socket server start
|
|
|
pid = fork();
|
|
|
if(pid == 0)
|