process timing to cause ts adjustment.
This commit is contained in:
parent
a36142bcf8
commit
d60443eca0
@ -4,6 +4,7 @@
|
|||||||
#include "mqttclient/mqtt_client.h"
|
#include "mqttclient/mqtt_client.h"
|
||||||
#include "dbaccess/sql_db.hpp"
|
#include "dbaccess/sql_db.hpp"
|
||||||
#include "platform/platform_init.hpp"
|
#include "platform/platform_init.hpp"
|
||||||
|
#include "scheduler/schedule.hpp"
|
||||||
#include "utility/md5.h"
|
#include "utility/md5.h"
|
||||||
|
|
||||||
extern zlog_category_t *zct;
|
extern zlog_category_t *zct;
|
||||||
@ -87,6 +88,7 @@ std::string JsonData::JsonCmd_Cgi_02(Param_02 ¶m) {
|
|||||||
SetTime((unsigned long)param.mTimeStamp);
|
SetTime((unsigned long)param.mTimeStamp);
|
||||||
mssleep(200);
|
mssleep(200);
|
||||||
system("hwclock -w");
|
system("hwclock -w");
|
||||||
|
scheduler::instance().ModifyScheduleTs(set_timestamp - current_timestamp);
|
||||||
} else {
|
} else {
|
||||||
zlog_warn(zct, "diff seconds:%ld lesser than 5, not to modify", diff_seconds);
|
zlog_warn(zct, "diff seconds:%ld lesser than 5, not to modify", diff_seconds);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#include "mqttclient/mqtt_client.h"
|
#include "mqttclient/mqtt_client.h"
|
||||||
#include "dbaccess/sql_db.hpp"
|
#include "dbaccess/sql_db.hpp"
|
||||||
#include "utility/secure.hpp"
|
#include "utility/secure.hpp"
|
||||||
|
#include "scheduler/schedule.hpp"
|
||||||
#include "jsonparse/communication_cmd.hpp"
|
#include "jsonparse/communication_cmd.hpp"
|
||||||
|
|
||||||
extern zlog_category_t *zct;
|
extern zlog_category_t *zct;
|
||||||
@ -62,12 +63,22 @@ void LocalServer::HandleFromServer(const char *pData_r, int pLen, const char *to
|
|||||||
case kTiming: {
|
case kTiming: {
|
||||||
std::string timestamp = recvBody["timestamp"].asString();
|
std::string timestamp = recvBody["timestamp"].asString();
|
||||||
unsigned long itimestamp = atol(timestamp.c_str());
|
unsigned long itimestamp = atol(timestamp.c_str());
|
||||||
SetTime(itimestamp);
|
char localtimestamp[32] = {0};
|
||||||
mssleep(200);
|
GetTimeNet(localtimestamp, 1);
|
||||||
system("hwclock -w");
|
std::string current_system_timestamp = std::string(localtimestamp);
|
||||||
if (!recvValue["ZoneId"].isNull() && recvValue["ZoneId"].asString().length() > 0) {
|
unsigned long current_timestamp = boost::lexical_cast<unsigned long>(current_system_timestamp);
|
||||||
std::string zoneid = recvValue["ZoneId"].asString();
|
unsigned long diff_seconds = abs(current_timestamp - itimestamp);
|
||||||
ZoneConfig(zoneid);
|
if (diff_seconds > 5) {
|
||||||
|
SetTime(itimestamp);
|
||||||
|
mssleep(200);
|
||||||
|
system("hwclock -w");
|
||||||
|
scheduler::instance().ModifyScheduleTs(itimestamp - current_timestamp);
|
||||||
|
if (!recvValue["ZoneId"].isNull() && recvValue["ZoneId"].asString().length() > 0) {
|
||||||
|
std::string zoneid = recvValue["ZoneId"].asString();
|
||||||
|
ZoneConfig(zoneid);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
zlog_warn(zct, "[Timing] diff seconds:%ld lesser than 5, not to modify", diff_seconds);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case 13: {
|
case 13: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user