From: SnickerSun Date: Tue, 7 May 2024 14:58:45 +0000 (+0800) Subject: 修复cat1时间同步错误。 X-Git-Tag: release_V1.2.70_20241020_135402~1113^2~14 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=411322d3d6a74a4718fca224bdc2fa2ba76202db;p=mirrors%2FFD230.git 修复cat1时间同步错误。 优化httpclient 下载 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp index c290b758e..5b74c7932 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp @@ -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 diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp index e06ea4cce..7487468d1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp @@ -13,7 +13,7 @@ #include "health_service.h" #include "custom_utils.h" -extern "C" errcode_t uapi_get_timestampe_ms(uint64_t *tm); +extern "C" errcode_t uapi_get_timestampe_ms(uint32_t *tm); #ifdef __cplusplus extern "C" { diff --git a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h index 70d4f8b2f..05146c715 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h @@ -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; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp index 8b73ae63a..d61dbde54 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp @@ -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 diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/include/PhoneService.h b/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/include/PhoneService.h index 8ac11c662..98b032a4d 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/include/PhoneService.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/include/PhoneService.h @@ -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; // 通话状态改变回调函数 diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c index 32f789c21..f3ebc1c4d 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -3554,7 +3554,7 @@ static void stepDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *total uint8_t data_len = 0; uint32_t time = 1704090976; uint32_t step = 0; - uint64_t timeMs = 0; + uint32_t timeMs = 0; int ret = uapi_get_timestampe_ms(&timeMs); if(ret==0){ timeMs = timeMs/1000; diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 413876ffe..fe4c7c0eb 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -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; diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index 642054f5d..6cd128c7f 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -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获取的时间字串设置时间*/ diff --git a/code/sdk/open_source/openharmony/third_party/lwip/src/apps/http/http_client.c b/code/sdk/open_source/openharmony/third_party/lwip/src/apps/http/http_client.c index d67d56060..527c14b82 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/src/apps/http/http_client.c +++ b/code/sdk/open_source/openharmony/third_party/lwip/src/apps/http/http_client.c @@ -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); } }