修复cat1时间同步错误。 141/1 141/head 142/target/1
authorSnickerSun <snickersun@163.com>
Tue, 7 May 2024 14:58:45 +0000 (22:58 +0800)
committerSnickerSun <snickersun@163.com>
Tue, 7 May 2024 14:58:45 +0000 (22:58 +0800)
优化httpclient 下载

code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp
code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp
code/sdk/application/wearable/nativeapp/nativeui/phoneservice/include/PhoneService.h
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c
code/sdk/drivers/peripheral/utils/custom_utils.c
code/sdk/drivers/peripheral/utils/custom_utils.h
code/sdk/open_source/openharmony/third_party/lwip/src/apps/http/http_client.c

index c290b75..5b74c79 100644 (file)
@@ -35,7 +35,7 @@
 #include "power_display_service.h"
 #include "custom_utils.h"
 #include "cywee_service.h"
-extern "C" errcode_t uapi_get_timestampe_ms(uint64_t *tm);
+extern "C" errcode_t uapi_get_timestampe_ms(uint32_t *tm);
 
 #define BLOODKEYABLE 0
 namespace OHOS
index e06ea4c..7487468 100644 (file)
@@ -13,7 +13,7 @@
 #include "health_service.h"\r
 #include "custom_utils.h"\r
 \r
-extern "C" errcode_t uapi_get_timestampe_ms(uint64_t *tm);\r
+extern "C" errcode_t uapi_get_timestampe_ms(uint32_t *tm);\r
 #ifdef __cplusplus\r
 extern "C"\r
 {\r
index 70d4f8b..05146c7 100644 (file)
@@ -30,8 +30,8 @@ typedef struct {
     unsigned char nameLen;
     unsigned char tel[MAX_PHONE_NUM];
     unsigned char telLen;
-    uint64 activeTime; // 首次电话接通时间点
-    uint64 creationTime; // 通话创建时间(不是接通时间)
+    uint32 activeTime; // 首次电话接通时间点
+    uint32 creationTime; // 通话创建时间(不是接通时间)
     hfp_hf_calls_info_t unitCalls;
 } PhoneCallInfo;
 
index 8b73ae6..d61dbde 100644 (file)
@@ -45,7 +45,7 @@
 #define HIGH_INTENSITY_LOWER_THRESHOLD 70
 #define HIGH_INTENSITY_UPPER_THRESHOLD 79
 
-extern "C" errcode_t uapi_get_timestampe_ms(uint64_t *tm);
+extern "C" errcode_t uapi_get_timestampe_ms(uint32_t *tm);
 extern "C" void custom_VibratorFunc(OHOS::VibratorType vibratorType);
 
 #ifdef __cplusplus
index 8ac11c6..98b032a 100755 (executable)
@@ -32,8 +32,8 @@ extern "C"
         unsigned char nameLen;
         unsigned char tel[MAX_PHONE_NUM];
         unsigned char telLen;
-        uint64 activeTime;   // 首次电话接通时间点
-        uint64 creationTime; // 通话创建时间(不是接通时间)
+        uint32 activeTime;   // 首次电话接通时间点
+        uint32 creationTime; // 通话创建时间(不是接通时间)
         hfp_hf_calls_info_t unitCalls;
     } PhoneCallInfo;
 
@@ -75,8 +75,8 @@ extern "C"
         unsigned char tel[MAX_PHONE_NUM];
         unsigned char telLen;
         CallFinishStatus status;
-        uint64 creationTime; // 通话创建时间(不是接通时间)
-        uint64 callDurTime;  // 通话持续时间
+        uint32 creationTime; // 通话创建时间(不是接通时间)
+        uint32 callDurTime;  // 通话持续时间
     } CallLogInfo;
 
     // 通话状态改变回调函数
index 32f789c..f3ebc1c 100644 (file)
@@ -3554,7 +3554,7 @@ static void stepDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *total
         uint8_t data_len = 0;\r
         uint32_t time = 1704090976;\r
         uint32_t step = 0;\r
-        uint64_t timeMs = 0;\r
+        uint32_t timeMs = 0;\r
         int ret = uapi_get_timestampe_ms(&timeMs);\r
         if(ret==0){\r
             timeMs = timeMs/1000;\r
index 413876f..fe4c7c0 100644 (file)
@@ -328,14 +328,14 @@ errcode_t uaip_cmd_update_request(void)
 #include "systick.h"
 #include "sys/time.h"
 #include "time.h"
-errcode_t uapi_get_timestampe_ms(uint64_t *tm)
+errcode_t uapi_get_timestampe_ms(uint32_t *tm)
 {
     struct timeval tv = { 0 };
 
     if (gettimeofday(&tv, NULL)) {
         return ERRCODE_FAIL;
     }
-    *tm = (uint64_t)(tv.tv_sec*1000 + tv.tv_usec/1000 );
+    *tm = (uint32_t)(tv.tv_sec*1000 + tv.tv_usec/1000 );
         
     return ERRCODE_SUCC;
 }
@@ -461,7 +461,7 @@ static int decodeTime(char* time,uint32_t *timeseconds,int *zone)
         return 2;
     }
     // const char* timestr="(2024, 3, 2, 18, 40, 1, 5, 62),8";
-
+    printf("decodeTime %s\r\n",time);
     char buf[50] = {0};
     if (strlen(time)>sizeof(buf))
     {
@@ -553,7 +553,7 @@ static int decodeTime(char* time,uint32_t *timeseconds,int *zone)
         i++;
     }
     tmp_timestamp = (uint32_t)mktime(&_tm);
-    // tmp_timestamp -= tmp_zone * 3600; //cat1获得的时间时当下时间,实际上要减去zone的时间
+    tmp_timestamp -= tmp_zone * 3600; //cat1获得的时间时当下时间,实际上要减去zone的时间
     printf("time %04d-%02d-%02d %02d:%02d:%02d \r\nstamp %u \r\nzone %d\n",
      _tm.tm_year,_tm.tm_mon,_tm.tm_mday,_tm.tm_hour,_tm.tm_min,_tm.tm_sec,
      tmp_timestamp,
@@ -591,19 +591,19 @@ errcode_t uapi_set_time_from_cat1(char* cat1time)
       
    
     time_t rawtime;
-    struct tm* timeinfo;
+    struct tm timeinfo;
     time(&rawtime);
-    timeinfo = localtime(&rawtime);
+    localtime_r(&rawtime,&timeinfo);
 
     printf("set time success %04d-%02d-%02d %02d:%02d:%02d %d\n",
-    timeinfo->tm_year + 1900,
-    timeinfo->tm_mon + 1,
-    timeinfo->tm_mday,
-    timeinfo->tm_hour,
-    timeinfo->tm_min,
-    timeinfo->tm_sec,zone);
+    timeinfo.tm_year + 1900,
+    timeinfo.tm_mon + 1,
+    timeinfo.tm_mday,
+    timeinfo.tm_hour,
+    timeinfo.tm_min,
+    timeinfo.tm_sec,zone);
     
-    if (timeinfo->tm_year+1900 < 2024)
+    if (timeinfo.tm_year+1900 < 2024)
         return ERRCODE_FAIL;
 
     return ERRCODE_SUCC;
index 642054f..6cd128c 100644 (file)
@@ -37,7 +37,7 @@ extern uint32_t mcu_pm_lcd_off(uint8_t *para, uint32_t para_len);
 errcode_t uaip_cmd_update_request(void);
 
 /**获取单位ms的时间戳*/
-errcode_t uapi_get_timestampe_ms(uint64_t *tm);
+errcode_t uapi_get_timestampe_ms(uint32_t *tm);
 /*获取单位秒的时间戳*/
 errcode_t uapi_get_timestampe_ss(uint32_t *tm);
 /**根据cat1获取的时间字串设置时间*/
index d67d560..527c14b 100644 (file)
@@ -85,7 +85,7 @@
 #define HTTPC_DEBUG_SERIOUS      (HTTPC_DEBUG | LWIP_DBG_LEVEL_SERIOUS)
 
 #define HTTPC_POLL_INTERVAL     1
-#define HTTPC_POLL_TIMEOUT      160 /* 15 seconds */
+#define HTTPC_POLL_TIMEOUT      80 /* 15 seconds */
 
 #define HTTPC_CONTENT_LEN_INVALID 0xFFFFFFFF
 
@@ -325,6 +325,7 @@ httpc_tcp_recv(void *arg, struct altcp_pcb *pcb, struct pbuf *p, err_t r)
     }
     return httpc_close(req, result, req->rx_status, ERR_OK);
   }
+  req->timeout_ticks = HTTPC_POLL_TIMEOUT;
   if (req->parse_state != HTTPC_PARSE_RX_DATA) {
     if (req->rx_hdrs == NULL) {
       req->rx_hdrs = p;
@@ -400,10 +401,17 @@ httpc_tcp_poll(void *arg, struct altcp_pcb *pcb)
   httpc_state_t* req = (httpc_state_t*)arg;
   LWIP_UNUSED_ARG(pcb);
   if (req != NULL) {
+    if (req->timeout_ticks ==  HTTPC_POLL_TIMEOUT)
+    {
+      // printf("=============== timeout_ticks reset to default !\r\n");
+    }
     if (req->timeout_ticks) {
       req->timeout_ticks--;
+      // printf("=============== timeout_ticks -- %d !\r\n",req->timeout_ticks);
     }
     if (!req->timeout_ticks) {
+      // printf("=============== timeout_ticks HTTPC_RESULT_ERR_TIMEOUT !\r\n");
+
       return httpc_close(req, HTTPC_RESULT_ERR_TIMEOUT, 0, ERR_OK);
     }
   }