From: SnickerSun Date: Wed, 5 Jun 2024 08:38:39 +0000 (+0800) Subject: 添加RTC时间测试指令 AT^TIMESYNC X-Git-Tag: release_V1.2.70_20241020_135402~1044 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.js?a=commitdiff_plain;h=1c44613c1050db8bab38a151a93e258f2621fa44;p=mirrors%2FFD230.git 添加RTC时间测试指令 AT^TIMESYNC --- diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 0e7c31519..105c53ec5 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -146,12 +146,12 @@ void shutdown_reboot_prejobs_task(void) do_cywee_service_check_msg(CYWEE_SERVICE_CMD_SAVE_DATA,NULL); addressbookTowrite(); - - uapi_calendar_store_date(); //同步所有需要保存实时数据到config文件 uapi_dev_runtime_sync_runtime_env_to_config(); //保存config文件到磁盘 sync_all_config_to_disk(); + //重启前要保存时间 + uapi_calendar_store_date(); } static bool doing_shutdown_or_reboot = false; void shutdown_reboot_prejobs(void) @@ -1649,6 +1649,33 @@ uint32_t uapi_calendar_recover_date(void) return ret; } +#include "chip_system_time.h" +void test_bandy_time(uint32_t time) +{ + struct tm tm; + struct timeval tv; + // uint32_t time = 1716044461; // 2024-5-18 15:1:1 网站转换:2024-05-18 23:01:01 + printf("--------SYNC TIME----------\r\n"); + get_current_timestamp(); + get_current_time(&tv, &tm); + sync_time(time, 8); + get_current_timestamp(); + get_current_time(&tv, &tm); + printf("--------SAVE TIME----------\r\n"); + get_current_timestamp(); + get_current_time(&tv, &tm); + save_time(); + get_current_timestamp(); + get_current_time(&tv, &tm); + printf("--------RESTORE TIME----------\r\n"); + get_current_timestamp(); + get_current_time(&tv, &tm); + restore_time(); + get_current_timestamp(); + get_current_time(&tv, &tm); +} + + #include "tyhx_hrs_custom.h" void get_ppg_id(void) diff --git a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c index 2faf474b0..59ec91136 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c @@ -534,6 +534,30 @@ static uint32_t custom_utils_pdudec(uint8_t *para, uint32_t paraLen, char *strCo return ERRCODE_SUCC; } +static uint32_t custom_test_time_synct(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + UNUSED(strCommonCmd); + uint8_t argv[CUSTOM_UTILS_MAX_ARGC][CUSTOM_UTILS_MAX_ARGV_LEN] = { 0 }; + uint32_t argc = 0; + + int ret = ConvertCmdToParam(para, paraLen, argv, &argc); + if (ret != CUSTOM_UTILS_SUCCESS) { + PRINT("CUSTOM_UTILSTEST ATCMD Convert Command Failed\n"); + return ERRCODE_FAIL; + } + + if (argc != 1) { + PRINT("CUSTOM_UTILSTEST ATCMD Set Parameter Failed argc %d\n",argc); + return ERRCODE_FAIL; + } + uint32_t inpdustr = atol((char*)argv[0]); + + + test_bandy_time(inpdustr); + + return ERRCODE_SUCC; +} + #include "lwip/apps/sntp.h" static uint32_t custom_test_sntp(uint8_t *para, uint32_t paraLen, char *strCommonCmd) @@ -596,6 +620,7 @@ static const at_cmd_table_t g_custom_utils_cmd[] = { { (char *)"AT^LZMADEC", custom_utils_lzmadec, (char *)" " }, { (char *)"AT^PDUDEC", custom_utils_pdudec, (char *)" " }, { (char *)"AT^SNTP", custom_test_sntp, (char *)" " }, + { (char *)"AT^TIMESYNC", custom_test_time_synct, (char *)" " }, diff --git a/code/sdk/middleware/chips/brandy/exception/chip_system_time.c b/code/sdk/middleware/chips/brandy/exception/chip_system_time.c index 36c21313f..2d0ce3ede 100644 --- a/code/sdk/middleware/chips/brandy/exception/chip_system_time.c +++ b/code/sdk/middleware/chips/brandy/exception/chip_system_time.c @@ -125,28 +125,28 @@ uint32_t sync_time(uint32_t timestamp, uint32_t timezone) return settimeofday(&tv, &tzone); } -void test_bandy_time(void) -{ - struct tm tm; - struct timeval tv; - uint32_t time = 1716044461; // 2024-5-18 15:1:1 - printf("--------SYNC TIME----------\r\n"); - get_current_timestamp(); - get_current_time(&tv, &tm); - sync_time(time, 8); - get_current_timestamp(); - get_current_time(&tv, &tm); - printf("--------SAVE TIME----------\r\n"); - get_current_timestamp(); - get_current_time(&tv, &tm); - save_time(); - get_current_timestamp(); - get_current_time(&tv, &tm); - printf("--------RESTORE TIME----------\r\n"); - get_current_timestamp(); - get_current_time(&tv, &tm); - restore_time(); - get_current_timestamp(); - get_current_time(&tv, &tm); -} +// void test_bandy_time(uint32_t time) +// { +// struct tm tm; +// struct timeval tv; +// uint32_t time = 1716044461; // 2024-5-18 15:1:1 网站转换:2024-05-18 23:01:01 +// printf("--------SYNC TIME----------\r\n"); +// get_current_timestamp(); +// get_current_time(&tv, &tm); +// sync_time(time, 8); +// get_current_timestamp(); +// get_current_time(&tv, &tm); +// printf("--------SAVE TIME----------\r\n"); +// get_current_timestamp(); +// get_current_time(&tv, &tm); +// save_time(); +// get_current_timestamp(); +// get_current_time(&tv, &tm); +// printf("--------RESTORE TIME----------\r\n"); +// get_current_timestamp(); +// get_current_time(&tv, &tm); +// restore_time(); +// get_current_timestamp(); +// get_current_time(&tv, &tm); +// } #endif \ No newline at end of file diff --git a/code/sdk/middleware/chips/brandy/exception/chip_system_time.h b/code/sdk/middleware/chips/brandy/exception/chip_system_time.h index d2f2e7744..e097a4a25 100644 --- a/code/sdk/middleware/chips/brandy/exception/chip_system_time.h +++ b/code/sdk/middleware/chips/brandy/exception/chip_system_time.h @@ -56,7 +56,7 @@ uint32_t sync_time(uint32_t timestamp, uint32_t timezone); * @brief use for test * @return void. */ -void test_time(void); +void test_bandy_time(uint32_t time); /** * @brief Get the current system time as a local timestamp with timezone offset