backup
This commit is contained in:
parent
802dc495f7
commit
5a26c600ee
|
@ -0,0 +1,4 @@
|
||||||
|
build/.build/
|
||||||
|
build/debug/
|
||||||
|
build/release/
|
||||||
|
build/*.so
|
|
@ -1395,6 +1395,7 @@ static void __uvMsgSendTestProc(void *pParams)
|
||||||
|
|
||||||
static void __uvMsgRecvProc(void *pParams)
|
static void __uvMsgRecvProc(void *pParams)
|
||||||
{
|
{
|
||||||
|
|
||||||
while(TRUE)
|
while(TRUE)
|
||||||
{
|
{
|
||||||
PDBUS_MSG_PACK pMsg = DBusGetMessage();
|
PDBUS_MSG_PACK pMsg = DBusGetMessage();
|
||||||
|
@ -1667,6 +1668,40 @@ static void __dlTestThread(void* p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void uvTimerTestCb(uv_timer_t* pTimer)
|
||||||
|
{
|
||||||
|
LOG_EX(LOG_Debug, "Timer On(%d)...............\n", pTimer->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __uvThreadTimerV2(uv_loop_t *pLoop)
|
||||||
|
{
|
||||||
|
static uv_timer_t uvTimer;
|
||||||
|
|
||||||
|
uv_timer_init(pLoop, &uvTimer);
|
||||||
|
LOG_EX(LOG_Debug, "Timer Begin\n");
|
||||||
|
uvTimer.data = (intptr_t*)1;
|
||||||
|
uv_timer_start(&uvTimer, uvTimerTestCb, 3000, 0);
|
||||||
|
|
||||||
|
sleep(10);
|
||||||
|
|
||||||
|
LOG_EX(LOG_Debug, "Timer Stop\n");
|
||||||
|
uv_timer_stop(&uvTimer);
|
||||||
|
|
||||||
|
LOG_EX(LOG_Debug, "Timer Begin\n");
|
||||||
|
uvTimer.data = (intptr_t*)2;
|
||||||
|
uv_update_time(pLoop);
|
||||||
|
uv_timer_start(&uvTimer, uvTimerTestCb, 6000, 0);
|
||||||
|
|
||||||
|
sleep(3);
|
||||||
|
LOG_EX(LOG_Debug, "Timer Stop\n");
|
||||||
|
uv_timer_stop(&uvTimer);
|
||||||
|
|
||||||
|
LOG_EX(LOG_Debug, "Timer Begin\n");
|
||||||
|
uvTimer.data = (intptr_t*)3;
|
||||||
|
uv_update_time(pLoop);
|
||||||
|
uv_timer_start(&uvTimer, uvTimerTestCb, 12000, 0);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i, j, ret = 0;
|
int i, j, ret = 0;
|
||||||
|
@ -1675,7 +1710,11 @@ int main(int argc, char **argv)
|
||||||
uv_loop_t* pLoop = GetDBusDefaultLoop();
|
uv_loop_t* pLoop = GetDBusDefaultLoop();
|
||||||
int modIdx = -1;
|
int modIdx = -1;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
#if 1
|
||||||
|
i = GetServerModeFromCC(PUBLISH_MODE, &ret);
|
||||||
|
|
||||||
|
fprintf(stdout, "Read ServerMode = %d, errno = %d\n", i, ret);
|
||||||
|
#endif
|
||||||
#if 0
|
#if 0
|
||||||
FILE* pFile = fopen("/mnt/UDISK/time.txt", "w+");
|
FILE* pFile = fopen("/mnt/UDISK/time.txt", "w+");
|
||||||
|
|
||||||
|
@ -1745,6 +1784,8 @@ int main(int argc, char **argv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//__uvThreadTimerV2(pLoop);
|
||||||
|
|
||||||
//test_task_new(__uvThreadTest, NULL);
|
//test_task_new(__uvThreadTest, NULL);
|
||||||
|
|
||||||
//DumpCurServerAddr("Default");
|
//DumpCurServerAddr("Default");
|
||||||
|
@ -1777,7 +1818,7 @@ int main(int argc, char **argv)
|
||||||
DumpCurServerAddr("PUBLISH_MODE");
|
DumpCurServerAddr("PUBLISH_MODE");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//test_task_new(__uvMsgRecvProc, NULL);
|
//test_task_new(__uvThreadTimerV2, pLoop);
|
||||||
|
|
||||||
//HttpPostLogFile("{}");
|
//HttpPostLogFile("{}");
|
||||||
|
|
||||||
|
@ -1899,13 +1940,13 @@ int main(int argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
#if 0
|
#if 0
|
||||||
struct tm localTime;
|
struct tm localTime;
|
||||||
time_t timeStamp = time((time_t*)NULL) + 10;
|
time_t timeStamp = time((time_t*)NULL) + 30;
|
||||||
localtime_r(&timeStamp, &localTime);
|
localtime_r(&timeStamp, &localTime);
|
||||||
|
|
||||||
AlarmTimerAdd(2018-1900, 6-1, 26,
|
AlarmTimerAdd(2018-1900, 7-1, 19,
|
||||||
localTime.tm_hour, localTime.tm_min, localTime.tm_sec,
|
localTime.tm_hour, localTime.tm_min, localTime.tm_sec,
|
||||||
0,
|
0,
|
||||||
REPEAT_MODE_MONTH_LAST_DAY,
|
3,
|
||||||
__onAlarmCb, 0, NULL, NULL);
|
__onAlarmCb, 0, NULL, NULL);
|
||||||
#endif
|
#endif
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -72,6 +72,78 @@ void InitCfgToCfgFile(config_t* pCfg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CfgGetIntValueV2(const char* pTags, int defValue, int* pErr)
|
||||||
|
{
|
||||||
|
char* pSvrMode = NULL;
|
||||||
|
char cmdBuf[MAX_PATH];
|
||||||
|
int iValue = defValue;
|
||||||
|
|
||||||
|
memset(cmdBuf, 0, MAX_PATH);
|
||||||
|
|
||||||
|
sprintf(cmdBuf, "cat %s | grep %s | awk '{print $3}' | cut -d \";\" -f 1",
|
||||||
|
DEVICE_CFG_FILE,
|
||||||
|
pTags);
|
||||||
|
|
||||||
|
GetShellExecResult(cmdBuf, &pSvrMode);
|
||||||
|
|
||||||
|
if(pSvrMode == NULL)
|
||||||
|
{
|
||||||
|
if(pErr)
|
||||||
|
{
|
||||||
|
*pErr = -ERR_NO_ITEMS;
|
||||||
|
}
|
||||||
|
return defValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
iValue = strtol(pSvrMode, NULL, 10);
|
||||||
|
free(pSvrMode);
|
||||||
|
|
||||||
|
if(errno == EINVAL || errno == ERANGE)
|
||||||
|
{
|
||||||
|
if(pErr)
|
||||||
|
{
|
||||||
|
*pErr = -ERR_STR_CONVERT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return defValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pErr)
|
||||||
|
{
|
||||||
|
*pErr = 0;
|
||||||
|
}
|
||||||
|
return iValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CfgGetIntValueV1(const char* pTags, int defValue, int* pErr)
|
||||||
|
{
|
||||||
|
int iValue = defValue;
|
||||||
|
|
||||||
|
if(pTags == NULL || strlen(pTags) == 0)
|
||||||
|
{
|
||||||
|
if(pErr)
|
||||||
|
{
|
||||||
|
*pErr = -ERR_INPUT_PARAMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return defValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!config_lookup_int(&g_cfgInfo, pTags, &iValue))
|
||||||
|
{
|
||||||
|
if(pErr)
|
||||||
|
{
|
||||||
|
*pErr = -ERR_READ_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return defValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pErr = 0;
|
||||||
|
|
||||||
|
return iValue;
|
||||||
|
}
|
||||||
|
|
||||||
int CfgGetIntValue(const char* pTags, int defValue)
|
int CfgGetIntValue(const char* pTags, int defValue)
|
||||||
{
|
{
|
||||||
int iValue = defValue;
|
int iValue = defValue;
|
||||||
|
|
|
@ -1073,7 +1073,7 @@ int InetHttpUploadFileSync(const char *pURL, const char* pPath, void* pAttachInf
|
||||||
|
|
||||||
if(ret != CURLE_OK)
|
if(ret != CURLE_OK)
|
||||||
{
|
{
|
||||||
LOG_EX(LOG_Error, "Upload %s File %s Error %s\n", pURL, pPath, curl_easy_strerror(ret));
|
LOG_EX(LOG_Error, "Upload %s File %s Error %s(%d)\n", pURL, pPath, curl_easy_strerror(ret), ret);
|
||||||
rc = -ERR_NETWORK_SEND;
|
rc = -ERR_NETWORK_SEND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -21,6 +21,7 @@ const char* g_ServerModeStr[] =
|
||||||
"DEV_MODE",
|
"DEV_MODE",
|
||||||
"TEST_MODE",
|
"TEST_MODE",
|
||||||
"PUBLISH_MODE",
|
"PUBLISH_MODE",
|
||||||
|
"PUBLISH_PREBUILD",
|
||||||
"UNKNOWN_MODE"
|
"UNKNOWN_MODE"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -46,11 +47,13 @@ const char* g_VoiceKeyMap[VOICE_MAX][MAX_MODE] = {
|
||||||
"vbox-dev",
|
"vbox-dev",
|
||||||
"vbox-dev",
|
"vbox-dev",
|
||||||
"vbox-online",
|
"vbox-online",
|
||||||
|
"vbox-online",
|
||||||
},
|
},
|
||||||
{ // VOICE_APP_SECRET
|
{ // VOICE_APP_SECRET
|
||||||
"b1ec33c03df80ea3035bc9ccaa4af09c",
|
"b1ec33c03df80ea3035bc9ccaa4af09c",
|
||||||
"b1ec33c03df80ea3035bc9ccaa4af09c",
|
"b1ec33c03df80ea3035bc9ccaa4af09c",
|
||||||
"8714d6de1c83f21dda5fc9a905a59ac1",
|
"8714d6de1c83f21dda5fc9a905a59ac1",
|
||||||
|
"8714d6de1c83f21dda5fc9a905a59ac1",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,41 +62,49 @@ const char* g_ServerAddr[MAX_MODULE][MAX_MODE] = {
|
||||||
"2e37bc56a9b7ec3f6b8f41f60b81eb92",
|
"2e37bc56a9b7ec3f6b8f41f60b81eb92",
|
||||||
"2e37bc56a9b7ec3f6b8f41f60b81eb92",
|
"2e37bc56a9b7ec3f6b8f41f60b81eb92",
|
||||||
"dbb00213c23ea3709aae12ceb4c4e54e",
|
"dbb00213c23ea3709aae12ceb4c4e54e",
|
||||||
|
"7fc939cdb26ec2fa343b7c47a0617190",
|
||||||
},
|
},
|
||||||
{ // VOICE_MODULE
|
{ // VOICE_MODULE
|
||||||
"ws://vbox-test.netease.com/netty/websocket",
|
"ws://vbox-test.netease.com/netty/websocket",
|
||||||
"ws://vbox-test.netease.com/netty3/websocket",
|
"ws://vbox-test.netease.com/netty3/websocket",
|
||||||
"wss://vbox-asr.3.163.com/websocket",
|
"wss://vbox-asr.3.163.com/websocket",
|
||||||
|
"ws://vbox-test.netease.com/asr/websocket",
|
||||||
},
|
},
|
||||||
{ // VOICE_AI_MODULE
|
{ // VOICE_AI_MODULE
|
||||||
"http://api.multimedia.netease.com/imgtest/yqbot31_8686/",
|
"http://api.multimedia.netease.com/imgtest/yqbot31_8686/",
|
||||||
"http://api.multimedia.netease.com/imgtest/yqbot29_8686/",
|
"http://api.multimedia.netease.com/imgtest/yqbot29_8686/",
|
||||||
"https://vbox-smart.3.163.com/ ",
|
"https://vbox-smart.3.163.com/ ",
|
||||||
|
"http://api.multimedia.netease.com/imgtest/yqbot30_8888/",
|
||||||
},
|
},
|
||||||
{ // SERVER_MODULE
|
{ // SERVER_MODULE
|
||||||
"http://api.multimedia.netease.com/imgtest/yqbot27_7677/",
|
"http://api.multimedia.netease.com/imgtest/yqbot27_7677/",
|
||||||
"http://api.multimedia.netease.com/imgtest/yqbot31_7676/",
|
"http://api.multimedia.netease.com/imgtest/yqbot31_7676/",
|
||||||
"https://vbox-server.3.163.com/",
|
"https://vbox-server.3.163.com/",
|
||||||
|
"http://api.multimedia.netease.com/imgtest/yqbot22_7678/",
|
||||||
},
|
},
|
||||||
{ // LOG_MODULE
|
{ // LOG_MODULE
|
||||||
"http://vbox-log-test.netease.com/logCollectDev/vbox/logCollect/uploadLog",
|
"http://vbox-log-test.netease.com/logCollectDev/vbox/logCollect/uploadLog",
|
||||||
"http://vbox-log-test.netease.com/logCollect/vbox/logCollect/uploadLog",
|
"http://vbox-log-test.netease.com/logCollect/vbox/logCollect/uploadLog",
|
||||||
"https://vbox-log.3.163.com/vbox/logCollect/uploadLog",
|
"https://vbox-log.3.163.com/vbox/logCollect/uploadLog",
|
||||||
|
"http://vbox-log-test.netease.com/logCollectOnline/vbox/logCollect/uploadLog",
|
||||||
},
|
},
|
||||||
{ // MARK_POINT_MODULE
|
{ // MARK_POINT_MODULE
|
||||||
"http://vbox-log-test.netease.com/buriedDev/vbox/log/add",
|
"http://vbox-log-test.netease.com/buriedDev/vbox/log/add",
|
||||||
"http://vbox-log-test.netease.com/buriedTest/vbox/log/add",
|
"http://vbox-log-test.netease.com/buriedTest/vbox/log/add",
|
||||||
"https://vbox-log.3.163.com/vbox/log/add",
|
"https://vbox-log.3.163.com/vbox/log/add",
|
||||||
|
"http://vbox-log-test.netease.com/buriedOnline/vbox/log/add",
|
||||||
},
|
},
|
||||||
{ // TTS_MODULE
|
{ // TTS_MODULE
|
||||||
"http://api.openai.netease.com/vbox-tts-dev/vbox/tts/transform",
|
"http://api.openai.netease.com/vbox-tts-dev/vbox/tts/transform",
|
||||||
"http://api.openai.netease.com/vbox-tts-test/vbox/tts/transform",
|
"http://api.openai.netease.com/vbox-tts-test/vbox/tts/transform",
|
||||||
"https://vbox-tts.3.163.com/vbox/tts/transform",
|
"https://vbox-tts.3.163.com/vbox/tts/transform",
|
||||||
|
"http://api.openai.netease.com/vbox-tts-online/vbox/tts/transform",
|
||||||
},
|
},
|
||||||
{ // DC_MODULE
|
{ // DC_MODULE
|
||||||
"http://api.multimedia.netease.com/imgtest/yqbot27_7677/vbox/uploadFile",
|
"http://api.multimedia.netease.com/imgtest/yqbot27_7677/vbox/uploadFile",
|
||||||
"http://api.multimedia.netease.com/imgtest/yqbot31_7676/vbox/uploadFile",
|
"http://api.multimedia.netease.com/imgtest/yqbot31_7676/vbox/uploadFile",
|
||||||
"https://vbox-server.3.163.com/vbox/uploadFile",
|
"https://vbox-server.3.163.com/vbox/uploadFile",
|
||||||
|
"http://api.multimedia.netease.com/imgtest/yqbot22_7678/vbox/uploadFile",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -587,6 +587,8 @@ static int DBusOnMsgWorkAPICb(PDBUS_MSG_PACK pMsg)
|
||||||
if(pWorkDayInfo && err == 0)
|
if(pWorkDayInfo && err == 0)
|
||||||
{
|
{
|
||||||
memcpy(&g_workDayArray, pWorkDayInfo, sizeof(WORKDAY_INFO));
|
memcpy(&g_workDayArray, pWorkDayInfo, sizeof(WORKDAY_INFO));
|
||||||
|
g_workDayArray.isReady = TRUE;
|
||||||
|
LOG_EX(LOG_Debug, "Sync Alarm Database: %s\n", pMsg->pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
//LOG_EX2(LOG_Debug, "Database: %s\n", pMsg->pMsg);
|
//LOG_EX2(LOG_Debug, "Database: %s\n", pMsg->pMsg);
|
||||||
|
@ -1463,7 +1465,7 @@ static void __waitUDISKMount(void)
|
||||||
FILE* pFile;
|
FILE* pFile;
|
||||||
|
|
||||||
// wait system create setup status file
|
// wait system create setup status file
|
||||||
LOG_EX(LOG_Debug, "Wait boot status file create ......\n");
|
fprintf(stdout, "Wait boot status file create ......\n");
|
||||||
while(access(pBootStatFile, F_OK) != 0)
|
while(access(pBootStatFile, F_OK) != 0)
|
||||||
{
|
{
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
|
@ -1473,11 +1475,11 @@ static void __waitUDISKMount(void)
|
||||||
|
|
||||||
if(pFile == NULL)
|
if(pFile == NULL)
|
||||||
{
|
{
|
||||||
LOG_EX(LOG_Error, "Open boot status file error\n");
|
fprintf(stdout, "Open boot status file error\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_EX(LOG_Debug, "Wait boot status done ......\n");
|
fprintf(stdout, "Wait boot status done ......\n");
|
||||||
|
|
||||||
// when UDISK mount, file /tmp/booting_state content is "done"
|
// when UDISK mount, file /tmp/booting_state content is "done"
|
||||||
do
|
do
|
||||||
|
@ -1492,10 +1494,47 @@ static void __waitUDISKMount(void)
|
||||||
|
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
|
|
||||||
LOG_EX(LOG_Debug, "Boot status done ......\n");
|
fprintf(stdout, "Boot status done ......\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GetServerModeFromCC(int defValue, int* pErr)
|
||||||
|
{
|
||||||
|
char* pSvrMode = NULL;
|
||||||
|
int iValue = defValue;
|
||||||
|
|
||||||
|
GetShellExecResult("curl --silent http://localhost:1705/httpenv/999 | grep 'env:' | awk '{print $3}'", &pSvrMode);
|
||||||
|
|
||||||
|
if(pSvrMode == NULL)
|
||||||
|
{
|
||||||
|
if(pErr)
|
||||||
|
{
|
||||||
|
*pErr = -ERR_NO_ITEMS;
|
||||||
|
}
|
||||||
|
return defValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
iValue = strtol(pSvrMode, NULL, 10);
|
||||||
|
free(pSvrMode);
|
||||||
|
|
||||||
|
if(errno == EINVAL || errno == ERANGE)
|
||||||
|
{
|
||||||
|
if(pErr)
|
||||||
|
{
|
||||||
|
*pErr = -ERR_STR_CONVERT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return defValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pErr)
|
||||||
|
{
|
||||||
|
*pErr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return iValue;
|
||||||
|
}
|
||||||
|
|
||||||
DBusConnection* DBusWithLibuvInit(uv_loop_t* pUserLoop,
|
DBusConnection* DBusWithLibuvInit(uv_loop_t* pUserLoop,
|
||||||
const char* pBusName,
|
const char* pBusName,
|
||||||
OnDBusMessage cbOnMsg,
|
OnDBusMessage cbOnMsg,
|
||||||
|
@ -1551,21 +1590,63 @@ DBusConnection* DBusWithLibuvInit(uv_loop_t* pUserLoop,
|
||||||
|
|
||||||
puvFsReq = (uv_fs_t*)malloc(sizeof(uv_fs_t));
|
puvFsReq = (uv_fs_t*)malloc(sizeof(uv_fs_t));
|
||||||
|
|
||||||
|
// wait UDISK mount, configure file save in UDISK partition
|
||||||
|
__waitUDISKMount();
|
||||||
|
|
||||||
CfgFileInit();
|
CfgFileInit();
|
||||||
|
|
||||||
IHW_InitLOG(strrchr(pBusName, '.') + 1, NULL, TRUE);
|
IHW_InitLOG(strrchr(pBusName, '.') + 1, NULL, TRUE);
|
||||||
IHW_EnableLogLevel(LOG_Fatal | LOG_Error | LOG_Warn | LOG_Debug | LOG_Info, 1);
|
IHW_EnableLogLevel(LOG_Fatal | LOG_Error | LOG_Warn | LOG_Debug | LOG_Info, 1);
|
||||||
|
IHW_RunLogService();
|
||||||
|
|
||||||
APP_BUILD_INFO(strrchr(pBusName, '.') + 1, GetCurrentVersion());
|
APP_BUILD_INFO(strrchr(pBusName, '.') + 1, GetCurrentVersion());
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
svrMode = CfgGetIntValueV1("Global.ServerMode", PUBLISH_MODE, &ret);
|
||||||
|
|
||||||
// wait UDISK mount, configure file save in UDISK partition
|
if(ret != 0)
|
||||||
__waitUDISKMount();
|
{
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
usleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
svrMode = CfgGetIntValue("Global.ServerMode", PUBLISH_MODE);
|
LOG_EX(LOG_Debug, "ServerMode = %d, Error = %d\n", svrMode, ret);
|
||||||
|
} while (ret != 0 && i++ <= 3);
|
||||||
|
|
||||||
|
if(ret != 0)
|
||||||
|
{
|
||||||
|
LOG_EX(LOG_Error, "Read Server Mode Error: ret = %d\n", ret);
|
||||||
|
svrMode = CfgGetIntValueV2("ServerMode", PUBLISH_MODE, &ret);
|
||||||
|
|
||||||
|
if(ret == 0)
|
||||||
|
{
|
||||||
|
LOG_EX(LOG_Warn, "Recovery Server Mode OK: ServerMode = %d\n", svrMode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_EX(LOG_Error, "CfgGetInvValueV2 Read Server Mode Error: ret = %d\n", ret);
|
||||||
|
svrMode = GetServerModeFromCC(PUBLISH_MODE, &ret);
|
||||||
|
|
||||||
|
if(ret == 0)
|
||||||
|
{
|
||||||
|
LOG_EX(LOG_Warn, "Netease Controller Server Mode OK: ServerMode = %d\n", svrMode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
svrMode = PUBLISH_MODE;
|
||||||
|
LOG_EX(LOG_Error, "GetServerModeFromCC Read Server Mode Error: "
|
||||||
|
"ret = %d, Set to default: PUBLISH_MODE\n", ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SetCurrentServerMode(svrMode);
|
SetCurrentServerMode(svrMode);
|
||||||
DumpCurServerAddr("Default");
|
DumpCurServerAddr("Default");
|
||||||
|
|
||||||
|
|
||||||
#if USED_SHM_TO_DBUS
|
#if USED_SHM_TO_DBUS
|
||||||
uv_rwlock_init(&g_uvShmHashRwLock);
|
uv_rwlock_init(&g_uvShmHashRwLock);
|
||||||
|
@ -1718,8 +1799,6 @@ DBusConnection* DBusWithLibuvInit(uv_loop_t* pUserLoop,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
IHW_RunLogService();
|
|
||||||
|
|
||||||
return pBus;
|
return pBus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2007,6 +2086,11 @@ static int __reqWorkDayInfo(int year)
|
||||||
reqInfo.year = year;
|
reqInfo.year = year;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(reqInfo.year < (2018 - 1900))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
ret = DBusJsonSendToCommand(NULL,
|
ret = DBusJsonSendToCommand(NULL,
|
||||||
g_pModInfoTable[MODULE_CONTROLLER].modAliase,
|
g_pModInfoTable[MODULE_CONTROLLER].modAliase,
|
||||||
CMD_WORKDAY_DB_REQ,
|
CMD_WORKDAY_DB_REQ,
|
||||||
|
@ -2016,9 +2100,19 @@ static int __reqWorkDayInfo(int year)
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int IsHolidayDBSynced(void)
|
||||||
|
{
|
||||||
|
return g_workDayArray.isReady;
|
||||||
|
}
|
||||||
|
|
||||||
int CurrentIsWorkDay(int year, int day)
|
int CurrentIsWorkDay(int year, int day)
|
||||||
{
|
{
|
||||||
// LOG_EX(LOG_Debug, "CurrentIsWorkDay: year = %d, day = %d\n", year, day);
|
static unsigned int i = 0;
|
||||||
|
|
||||||
|
if(year != 0)
|
||||||
|
{
|
||||||
|
LOG_EX(LOG_Debug, "CurrentIsWorkDay: year = %d, day = %d\n", year, day);
|
||||||
|
}
|
||||||
|
|
||||||
if(day > 365)
|
if(day > 365)
|
||||||
{
|
{
|
||||||
|
@ -2029,7 +2123,10 @@ int CurrentIsWorkDay(int year, int day)
|
||||||
if(g_workDayArray.year <= 0)
|
if(g_workDayArray.year <= 0)
|
||||||
{
|
{
|
||||||
__reqWorkDayInfo(year);
|
__reqWorkDayInfo(year);
|
||||||
LOG_EX(LOG_Error, "Unsync Database: year = %d\n", year);
|
if(i++ % 10 == 0)
|
||||||
|
{
|
||||||
|
LOG_EX(LOG_Error, "Unsync Database: year = %d\n", year);
|
||||||
|
}
|
||||||
return (-ERR_UNINIT_ITEM);
|
return (-ERR_UNINIT_ITEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,14 +25,14 @@
|
||||||
#include <uvdbus/assistant.h>
|
#include <uvdbus/assistant.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SYNC_TIME_DELAY (5)
|
#define SYNC_TIME_DELAY (1)
|
||||||
|
|
||||||
static PASSISTANT_ARRAY_INFO g_pAlarmArray = NULL,
|
static PASSISTANT_ARRAY_INFO g_pAlarmArray = NULL,
|
||||||
g_pRemaindArray = NULL,
|
g_pRemaindArray = NULL,
|
||||||
g_pSessionArray = NULL;
|
g_pSessionArray = NULL;
|
||||||
|
|
||||||
static uv_rwlock_t g_uvListRwLock;
|
static uv_rwlock_t g_uvListRwLock;
|
||||||
static unsigned char g_syncFlags;
|
static unsigned char g_syncFlags = 0;
|
||||||
static unsigned int g_sessionId = 0;
|
static unsigned int g_sessionId = 0;
|
||||||
|
|
||||||
static void __onAlarmCb(unsigned int tmId, unsigned int status, void *pUserData);
|
static void __onAlarmCb(unsigned int tmId, unsigned int status, void *pUserData);
|
||||||
|
@ -462,6 +462,12 @@ static PDBUS_MSG_PACK __dBusOnMessage(uv_loop_t *pLoop, DBusConnection *pConn, P
|
||||||
switch(pMsg->busCmd)
|
switch(pMsg->busCmd)
|
||||||
{
|
{
|
||||||
case CMD_SESSION_ALARM_SYNC:
|
case CMD_SESSION_ALARM_SYNC:
|
||||||
|
if(IsHolidayDBSynced() != TRUE)
|
||||||
|
{
|
||||||
|
LOG_EX(LOG_Warn, "CMD_SESSION_ALARM_SYNC: Wait sync holiday database, this is dirty data.\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
pInfo = (PASSISTANT_SYNC_INFO)Json2Struct((const char *)pMsg->pMsg, JSON_ENGINE_ASSISTANT_SYNC_RSP, FALSE, &err);
|
pInfo = (PASSISTANT_SYNC_INFO)Json2Struct((const char *)pMsg->pMsg, JSON_ENGINE_ASSISTANT_SYNC_RSP, FALSE, &err);
|
||||||
|
|
||||||
if(pInfo)
|
if(pInfo)
|
||||||
|
@ -487,6 +493,12 @@ static PDBUS_MSG_PACK __dBusOnMessage(uv_loop_t *pLoop, DBusConnection *pConn, P
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_ALARM_SYNC_RSP:
|
case CMD_ALARM_SYNC_RSP:
|
||||||
|
if(IsHolidayDBSynced() != TRUE)
|
||||||
|
{
|
||||||
|
LOG_EX(LOG_Warn, "CMD_ALARM_SYNC_RSP: Wait sync holiday database, this is dirty data.\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
pInfo = (PASSISTANT_SYNC_INFO)Json2Struct((const char *)pMsg->pMsg, JSON_ENGINE_ASSISTANT_SYNC_RSP, FALSE, &err);
|
pInfo = (PASSISTANT_SYNC_INFO)Json2Struct((const char *)pMsg->pMsg, JSON_ENGINE_ASSISTANT_SYNC_RSP, FALSE, &err);
|
||||||
|
|
||||||
if(pInfo)
|
if(pInfo)
|
||||||
|
@ -580,6 +592,12 @@ static PDBUS_MSG_PACK __dBusOnMessage(uv_loop_t *pLoop, DBusConnection *pConn, P
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_REMAIND_SYNC_RSP:
|
case CMD_REMAIND_SYNC_RSP:
|
||||||
|
if(IsHolidayDBSynced() != TRUE)
|
||||||
|
{
|
||||||
|
LOG_EX(LOG_Warn, "CMD_REMAIND_SYNC_RSP: Wait sync holiday database, this is dirty data.\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
pInfo = (PASSISTANT_SYNC_INFO)Json2Struct((const char *)pMsg->pMsg, JSON_ENGINE_ASSISTANT_SYNC_RSP, FALSE, &err);
|
pInfo = (PASSISTANT_SYNC_INFO)Json2Struct((const char *)pMsg->pMsg, JSON_ENGINE_ASSISTANT_SYNC_RSP, FALSE, &err);
|
||||||
|
|
||||||
if(pInfo)
|
if(pInfo)
|
||||||
|
@ -705,12 +723,73 @@ static void __dBusDeameonCb(MODULE_NAME modName, int status)
|
||||||
|
|
||||||
static void __assistantSyncThread(void *pParam)
|
static void __assistantSyncThread(void *pParam)
|
||||||
{
|
{
|
||||||
int ret, isSynced = -1;
|
int ret, i = 0, isSynced = -1;
|
||||||
|
|
||||||
LOG_EX(LOG_Debug, "Beging Sync holiday Database\n");
|
LOG_EX(LOG_Debug, "Beging Sync holiday Database\n");
|
||||||
|
while(TRUE)
|
||||||
|
{
|
||||||
|
if(IsHolidayDBSynced() != TRUE)
|
||||||
|
{
|
||||||
|
CurrentIsWorkDay(0, 0);
|
||||||
|
if(i++ % 10 == 0 && i <= 1000)
|
||||||
|
{
|
||||||
|
LOG_EX(LOG_Debug, "Retry sync holiday database: %d\n", i);
|
||||||
|
}
|
||||||
|
sleep(SYNC_TIME_DELAY);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOG_EX(LOG_Debug, "Sync holiday Database Finished\n");
|
||||||
|
|
||||||
|
LOG_EX(LOG_Debug, "Beging sync ASSISTANT_TYPE_CLOCK\n");
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
if(g_syncFlags & (1 << ASSISTANT_TYPE_CLOCK))
|
||||||
|
{
|
||||||
|
LOG_EX(LOG_Debug, "Sync ASSISTANT_TYPE_CLOCK Finished\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = DBusSendToCommand(NULL,
|
||||||
|
g_pModInfoTable[MODULE_CONTROLLER].modAliase,
|
||||||
|
CMD_ALARM_SYNC_REQ, "");
|
||||||
|
|
||||||
|
LOG_EX(LOG_Debug, "Send CMD_ALARM_SYNC_REQ Command: %d\n", ret);
|
||||||
|
|
||||||
|
sleep(SYNC_TIME_DELAY);
|
||||||
|
} while(TRUE);
|
||||||
|
|
||||||
|
LOG_EX(LOG_Debug, "Beging sync ASSISTANT_TYPE_REMAIND\n");
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if(g_syncFlags & (1 << ASSISTANT_TYPE_REMAIND))
|
||||||
|
{
|
||||||
|
LOG_EX(LOG_Debug, "Sync ASSISTANT_TYPE_REMAIND Finished\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = DBusSendToCommand(NULL,
|
||||||
|
g_pModInfoTable[MODULE_CONTROLLER].modAliase,
|
||||||
|
CMD_REMAIND_SYNC_REQ, "");
|
||||||
|
|
||||||
|
LOG_EX(LOG_Debug, "Send CMD_REMAIND_SYNC_REQ Command: %d\n", ret);
|
||||||
|
|
||||||
|
sleep(SYNC_TIME_DELAY);
|
||||||
|
} while(TRUE);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if((g_syncFlags & (1 << ASSISTANT_TYPE_CLOCK))
|
||||||
|
&& (g_syncFlags & (1 << ASSISTANT_TYPE_REMAIND)))
|
||||||
|
{
|
||||||
|
LOG_EX(LOG_Debug, "Sync Alarm And Remaind Finished\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if((g_syncFlags & (1 << ASSISTANT_TYPE_CLOCK)) == 0)
|
if((g_syncFlags & (1 << ASSISTANT_TYPE_CLOCK)) == 0)
|
||||||
{
|
{
|
||||||
ret = DBusSendToCommand(NULL,
|
ret = DBusSendToCommand(NULL,
|
||||||
|
@ -726,18 +805,13 @@ static void __assistantSyncThread(void *pParam)
|
||||||
g_pModInfoTable[MODULE_CONTROLLER].modAliase,
|
g_pModInfoTable[MODULE_CONTROLLER].modAliase,
|
||||||
CMD_REMAIND_SYNC_REQ, "");
|
CMD_REMAIND_SYNC_REQ, "");
|
||||||
|
|
||||||
// LOG_EX(LOG_Debug, "Send CMD_REMAIND_SYNC_REQ Command: %d\n", ret);
|
LOG_EX(LOG_Debug, "Send CMD_REMAIND_SYNC_REQ Command: %d\n", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isSynced < 0)
|
|
||||||
{
|
|
||||||
isSynced = CurrentIsWorkDay(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
sleep(SYNC_TIME_DELAY);
|
sleep(SYNC_TIME_DELAY);
|
||||||
} while(g_syncFlags != ((1 << ASSISTANT_TYPE_CLOCK) | (1 << ASSISTANT_TYPE_REMAIND)));
|
} while(TRUE);
|
||||||
|
//while(g_syncFlags != ((1 << ASSISTANT_TYPE_CLOCK) | (1 << ASSISTANT_TYPE_REMAIND)));
|
||||||
|
|
||||||
LOG_EX(LOG_Debug, "Sync holiday Database Finished\n");
|
|
||||||
|
|
||||||
ret = DBusSendToCommand(NULL,
|
ret = DBusSendToCommand(NULL,
|
||||||
g_pModInfoTable[MODULE_CONTROLLER].modAliase,
|
g_pModInfoTable[MODULE_CONTROLLER].modAliase,
|
||||||
|
@ -750,6 +824,7 @@ static void __assistantSyncThread(void *pParam)
|
||||||
CMD_REMAIND_SYNC_REQ, "");
|
CMD_REMAIND_SYNC_REQ, "");
|
||||||
|
|
||||||
LOG_EX(LOG_Debug, "Send CMD_REMAIND_SYNC_REQ Command: %d\n", ret);
|
LOG_EX(LOG_Debug, "Send CMD_REMAIND_SYNC_REQ Command: %d\n", ret);
|
||||||
|
#endif
|
||||||
|
|
||||||
pthread_detach(pthread_self());
|
pthread_detach(pthread_self());
|
||||||
}
|
}
|
||||||
|
@ -775,8 +850,7 @@ int main(int argc, char **argv)
|
||||||
uv_rwlock_init(&g_uvListRwLock);
|
uv_rwlock_init(&g_uvListRwLock);
|
||||||
|
|
||||||
AlarmTimerInit(pLoop);
|
AlarmTimerInit(pLoop);
|
||||||
|
|
||||||
g_syncFlags = 0;
|
|
||||||
uv_thread_create(&uvSyncThread, __assistantSyncThread, NULL);
|
uv_thread_create(&uvSyncThread, __assistantSyncThread, NULL);
|
||||||
RunUVLoop(pLoop);
|
RunUVLoop(pLoop);
|
||||||
|
|
||||||
|
|
|
@ -1010,6 +1010,7 @@ static void __otaDownloadImageCb(void *pParams)
|
||||||
|
|
||||||
__otaRspStatus(OTA_DOWNLOAD_FILE, dlInfo.retCode);
|
__otaRspStatus(OTA_DOWNLOAD_FILE, dlInfo.retCode);
|
||||||
pthread_detach(pthread_self());
|
pthread_detach(pthread_self());
|
||||||
|
free(pInfo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1149,7 +1150,6 @@ static PDBUS_MSG_PACK __dBusOnMessage(uv_loop_t* pLoop, DBusConnection* pConn, P
|
||||||
if(pInfo == NULL)
|
if(pInfo == NULL)
|
||||||
{
|
{
|
||||||
__otaRspStatus(OTA_ERR_CODE, -ERR_INPUT_PARAMS);
|
__otaRspStatus(OTA_ERR_CODE, -ERR_INPUT_PARAMS);
|
||||||
free(pInfo);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1203,6 +1203,7 @@ static PDBUS_MSG_PACK __dBusOnMessage(uv_loop_t* pLoop, DBusConnection* pConn, P
|
||||||
g_IsOTAMode = FALSE;
|
g_IsOTAMode = FALSE;
|
||||||
LOG_EX(LOG_Error, "Error: Not Enought Space, Memory Free %llu bytes\n", uMemFreeSize);
|
LOG_EX(LOG_Error, "Error: Not Enought Space, Memory Free %llu bytes\n", uMemFreeSize);
|
||||||
__otaRspStatus(OTA_DISK_FULL, pInfo->otaCmd);
|
__otaRspStatus(OTA_DISK_FULL, pInfo->otaCmd);
|
||||||
|
free(pInfo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -39,6 +39,7 @@ typedef struct
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
int isReady;
|
||||||
int year;
|
int year;
|
||||||
unsigned char days[366];
|
unsigned char days[366];
|
||||||
} WORKDAY_INFO, *PWORKDAY_INFO;
|
} WORKDAY_INFO, *PWORKDAY_INFO;
|
||||||
|
@ -202,6 +203,7 @@ unsigned int AlarmTimerAdd(int year,
|
||||||
int *pError);
|
int *pError);
|
||||||
|
|
||||||
int CurrentIsWorkDay(int year, int day);
|
int CurrentIsWorkDay(int year, int day);
|
||||||
|
int IsHolidayDBSynced(void);
|
||||||
const char* DumpTimerRepeatModeString(int mode);
|
const char* DumpTimerRepeatModeString(int mode);
|
||||||
unsigned long long GetPartitionFreeSize(const char *pPartPath);
|
unsigned long long GetPartitionFreeSize(const char *pPartPath);
|
||||||
WIFI_STATUS GetCurrWIFIConnStatus(void);
|
WIFI_STATUS GetCurrWIFIConnStatus(void);
|
||||||
|
@ -215,6 +217,9 @@ char* GetCurrentVersion(void);
|
||||||
|
|
||||||
void CfgFileInit(void);
|
void CfgFileInit(void);
|
||||||
int CfgGetIntValue(const char* pTags, int defValue);
|
int CfgGetIntValue(const char* pTags, int defValue);
|
||||||
|
int CfgGetIntValueV1(const char* pTags, int defValue, int* pErr);
|
||||||
|
int CfgGetIntValueV2(const char* pTags, int defValue, int* pErr);
|
||||||
|
int GetServerModeFromCC(int defValue, int* pErr);
|
||||||
char* CfgGetStringValue(const char* pTags, char* pDefValue);
|
char* CfgGetStringValue(const char* pTags, char* pDefValue);
|
||||||
double CfgGetFloatValue(const char* pTags, double defValue);
|
double CfgGetFloatValue(const char* pTags, double defValue);
|
||||||
int CfgGetBoolValue(const char* pTags, int defValue);
|
int CfgGetBoolValue(const char* pTags, int defValue);
|
||||||
|
|
|
@ -19,9 +19,10 @@ typedef enum
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
DEV_MODE = 0,
|
DEV_MODE = 0,
|
||||||
TEST_MODE = 1,
|
TEST_MODE = 1,
|
||||||
PUBLISH_MODE = 2,
|
PUBLISH_MODE = 2,
|
||||||
|
PUBLISH_PREBUILD = 3,
|
||||||
MAX_MODE
|
MAX_MODE
|
||||||
} SERVER_MODE_TYPE;
|
} SERVER_MODE_TYPE;
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ typedef struct
|
||||||
FILE *pLogFile;
|
FILE *pLogFile;
|
||||||
} LOG_PROCESS_INFO, *PLOG_PROCESS_INFO;
|
} LOG_PROCESS_INFO, *PLOG_PROCESS_INFO;
|
||||||
|
|
||||||
static int g_bEnableLog = TRUE; // 是否启用 Log 功能
|
static int g_bEnableLog = FALSE; // 是否启用 Log 功能
|
||||||
static int g_bEnMailBackup = FALSE;
|
static int g_bEnMailBackup = FALSE;
|
||||||
static char* g_pEmailBox = NULL;
|
static char* g_pEmailBox = NULL;
|
||||||
static int g_bEnLogToFile = TRUE;
|
static int g_bEnLogToFile = TRUE;
|
||||||
|
|
Loading…
Reference in New Issue