添加RTC时间测试指令 AT^TIMESYNC
authorSnickerSun <snickersun@163.com>
Wed, 5 Jun 2024 08:38:39 +0000 (16:38 +0800)
committerSnickerSun <snickersun@163.com>
Wed, 5 Jun 2024 08:38:39 +0000 (16:38 +0800)
code/sdk/drivers/peripheral/utils/custom_utils.c
code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c
code/sdk/middleware/chips/brandy/exception/chip_system_time.c
code/sdk/middleware/chips/brandy/exception/chip_system_time.h

index 0e7c315..105c53e 100644 (file)
@@ -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)
index 2faf474..59ec911 100644 (file)
@@ -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 *)" " },
 
     
 
index 36c2131..2d0ce3e 100644 (file)
@@ -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
index d2f2e77..e097a4a 100644 (file)
@@ -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