void *CNtpManager::NtpThreadProj()
{
int time_cnt = 0;
while(1)
{
++time_cnt; //利用NTP线程定时同步系统时间到RTC, 间隔1小时
if (time_cnt % 3600 == 3599)
{
int year, month, day, week, hour, minute, seconds;
GetUtcSystemTime(&year, &month, &day, &week, &hour, &minute, &seconds);
DEBUG_ERROR("Timer sync time to RTC, current UTC time=%04d-%02d-%02d %02d:%02d:%02d\n", year, month, day, hour, minute, seconds);
CRtc::Rtc_SetTime(year, month, day, hour, minute, seconds);
time_cnt = 0;
}
if(m_bNtpEnable)
{
int ret = -1;
time_t curTime = 0;
if((m_ntpSwitch) || CheckTimeTickEvent())
{
ret = GetUtcTime();
if(ret == 0)
{
curTime = GetTimerUtcSecond();
DEBUG_DEBUG("ntp -->curTime=%ld - m_ntpTime=%ld = %d ", curTime, m_ntpTime, curTime - m_ntpTime);
if(abs(curTime - m_ntpTime) >= 5) //5秒差距
{
SystemTimeDef_S sysTime;
#if 0
m_ntpTime = m_ntpTime + m_timeZone * 3600;
#endif
ChangeUtcToSysinfo(m_ntpTime, &sysTime);
sysTime.timeZone = m_timeZone;
DEBUG_DEBUG("ntp -->befor EVENT_DEVMANAGE_SET_NTP_TIME ");
g_messageClient->SendMessage( 0, EVENT_DEVMANAGE_SET_NTP_TIME, 0, (const char *)&sysTime, sizeof(sysTime), 1);
DEBUG_