From 92c3ca33152737e5307fadacc1a40e2034101369 Mon Sep 17 00:00:00 2001 From: "snickersun@163.com" Date: Sun, 23 Jun 2024 14:45:19 +0000 Subject: [PATCH] Merge #370 into sdk602patch0521 from refs/changes/370/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 修复ble协议 时间同步计算错误 * refs/changes/370/head: (1 commits squashed) - 修复ble协议 时间同步计算错误 Signed-off-by: snickersun@163.com Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/370 --- .../service/ble_service/bleservice/bleEvent.c | 12 +++++++++--- code/sdk/drivers/peripheral/utils/custom_utils.c | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) 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 ee6d36827..7e0f3378d 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -1308,9 +1308,15 @@ static uint8_t jsonCheck_time(uint8_t *buf)//json 格式解析 /***计算timezone*/ - struct tm *tmp = gmtime(×tamp); - time_t timestamp2 = mktime(tmp); - uint32_t timezone = (timestamp-timestamp2)/60/15; + struct tm tmp={0}; + tmp.tm_year = year+2000 - 1900; + tmp.tm_mon = month -1; + tmp.tm_mday = day; + tmp.tm_hour = hour; + tmp.tm_min = minute; + tmp.tm_sec = second; + time_t timestamp2 = __tm_to_secs(&tmp); + uint32_t timezone = (timestamp2-timestamp)/60/15; printf("timezone in quarters %d\n",timezone); uapi_set_timezone(timezone); //要在uaip_sntp_set_time_utc 之前执行才有效 /********/ diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 4f683e2bf..3b9ae3f1a 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -444,7 +444,7 @@ errcode_t uaip_sntp_set_time_utc(uint32_t seconds) timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec,zone_quarters,ret); - printf("utc timestamp %d , local timestamp %d\n",get_current_timestamp(),get_local_timestamp()); + printf("utc timestamp %d , local timestamp %d, timezone %ld\n",get_current_timestamp(),get_local_timestamp(),timezone); return ERRCODE_SUCC; } -- 2.17.1