From: SnickerSun Date: Sun, 23 Jun 2024 14:43:31 +0000 (+0800) Subject: 修复ble协议 时间同步计算错误 X-Git-Tag: release_V1.2.70_20241020_135402~959^2~1 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F370%2Fhead;p=mirrors%2FFD230.git 修复ble协议 时间同步计算错误 --- 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; }