Bläddra i källkod

1、修改NTP同步方式,修改东八区时区链接文件;
2、修改邮箱推送服务关闭时,表头启动崩溃的bug

liyuezong 1 år sedan
förälder
incheckning
17317170dc
4 ändrade filer med 29 tillägg och 27 borttagningar
  1. 21 22
      pro/src/app.c
  2. 3 0
      pro/src/appweb_handle.c
  3. 2 2
      pro/src/common.c
  4. 3 3
      pro/src/sqlite_handle.c

+ 21 - 22
pro/src/app.c

@@ -1812,38 +1812,37 @@ static void* ntp_thread(void *arg)
     dev_Alarm_Run_message(dm, language_alarm_Init_Success[0], "NTP");
 
 
-    #define NTP_INTERVAL_TIME  600
+    #define NTP_INTERVAL_TIME  300
     time1 = time(NULL);
-
-    while(h->quit==0) {
-        if(pntp->mode>0) {
-            if(ntp_sync_flag) {
-                destroyNTPClient(pc); pc = NULL;
-            }
-
-            if(pc==NULL) {
+    while (h->quit == 0)
+    {
+        if (pntp->mode > 0)
+        {
+            if (ntp_sync_flag || ((time1 - time2) >= NTP_INTERVAL_TIME))
+            {
                 pc = createNTPClient(pntp->ntpaddress, pntp->port);
-            }
-
-            if(pc) {
-                if((time2==0) || ((time2-time1)>=NTP_INTERVAL_TIME) || ntp_sync_flag) {
-                    if (getCurrentTimeFromNTP(pc, &ntp_time)==0) {
+                if (pc)
+                {
+                    if (getCurrentTimeFromNTP(pc, &ntp_time) == 0)
+                    {
                         time_t host_time = time(NULL);
                         log_d("host_time: %ld, ntp_time: %ld", host_time, ntp_time);
-                        if (host_time != ntp_time) {
-                            struct tm *ptm = localtime(&ntp_time);
-                            set_time(ptm);
-                        }
-                        time2 = time1;
-                        ntp_sync_flag = 0;
+                        struct tm *ptm = localtime(&ntp_time);
+                       // set_time(ptm);
+                        set_time_zone(ptm, pntp->tzone);
                     }
-                    else {
+                    else
+                    {
                         log_e("getCurrentTimeFromNTP failed!");
                     }
+                    destroyNTPClient(pc);
+                    pc = NULL;
                 }
-                time2 = time(NULL);
+                ntp_sync_flag = 0;
+                time2 = time1;
             }
         }
+        time1 = time(NULL);
         sleep(1);
     }
     destroyNTPClient(pc);

+ 3 - 0
pro/src/appweb_handle.c

@@ -4096,6 +4096,9 @@ static void serviceManagement(void *conn)
             tm_new.tm_sec = atoi(tempstr);
             t = mktime(&tm_new);
             set_time_zone(&tm_new, _globalNTPManager.tzone);
+        }
+        else if (_globalNTPManager.mode == 1)
+        {
             ntp_sync_flag = 1;
         }
 

+ 2 - 2
pro/src/common.c

@@ -347,7 +347,7 @@ int set_zone(int zone)
             sprintf(buf, "ln -sf /usr/share/zoneinfo/Asia/Bangkok /etc/localtime");
             break;
         case 8:
-            sprintf(buf, "ln -sf /usr/share/zoneinfo/Asia/Beijing /etc/localtime");
+            sprintf(buf, "ln -sf /usr/share/zoneinfo/Asia/Chongqing /etc/localtime");
             break;
         case 9:
             sprintf(buf, "ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime");
@@ -377,7 +377,7 @@ int set_time_zone(struct tm* time, int zone)
     if(r) {
         log_e("___ set_zone failed\n");
     }
-
+    sleep(1);
     r = set_time(time);
     if(r) {
         log_e("___ set_time failed\n");

+ 3 - 3
pro/src/sqlite_handle.c

@@ -3667,7 +3667,7 @@ int dev_Alarm_send_message(GlobalDeviceManager* globalDeviceManger,GlobalPowerMa
     strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", t);    
     int nAlarmID=dev_insert_alarm_info(globalDeviceManger->db,__globalPowerTemp->product_id,0,buffer,AlarmText);
 
-    mail_post_alarm(ALARM_TYPE_POWER, 0, _AlarmType, AlarmText);
+    if(globalDeviceManger->mailInfo.send.mode) mail_post_alarm(ALARM_TYPE_POWER, 0, _AlarmType, AlarmText);
 
     alarm_para_t para;
     //dev_search_last_Index(globalDeviceManger->db, );
@@ -3842,7 +3842,7 @@ int dev_Alarm_T_AC_message(GlobalDeviceManager* globalDeviceManger, GlobalTreeAC
     strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", t);    
     int nAlarmID=dev_insert_alarm_info(globalDeviceManger->db,__globalPowerTemp->product_id,0,buffer,AlarmText);
 
-    mail_post_alarm(ALARM_TYPE_POWER, 1, _AlarmType, AlarmText);
+     if(globalDeviceManger->mailInfo.send.mode) mail_post_alarm(ALARM_TYPE_POWER, 1, _AlarmType, AlarmText);
 
     alarm_para_t para;
     para.id = __globalPowerTemp->product_ch_id;
@@ -3958,7 +3958,7 @@ int dev_sensor_Alarm_send_message(GlobalDeviceManager* globalDeviceManger,Global
     int nAlarmID=dev_insert_alarm_info(globalDeviceManger->db,__globalPowerTemp->product_id,1,buffer,AlarmText);
 
     int subtype=__globalPowerTemp->sensor_type;
-    mail_post_alarm(ALARM_TYPE_SENSOR, subtype, _AlarmType, AlarmText);
+     if(globalDeviceManger->mailInfo.send.mode) mail_post_alarm(ALARM_TYPE_SENSOR, subtype, _AlarmType, AlarmText);
 
     alarm_para_t para;
     para.id = __globalPowerTemp->sensor_id;