更新cat1固件,增加at指令接口,修正协议中不一致的地方。cat1_server 兼容前后两种协议。
authorSnickerSun <snickersun@163.com>
Mon, 29 Apr 2024 07:02:38 +0000 (15:02 +0800)
committerSnickerSun <snickersun@163.com>
Mon, 29 Apr 2024 07:02:38 +0000 (15:02 +0800)
同时释放最新cat1Service.py PY_SRV_V5 版本的cat1固件。EG810MCNLAR06A01M08_VOLTE_OCPU_QPY_BETA0312_20240429-1457.zip

code/sdk/application/brandy/brandy_recovery/recovery_display.c
code/sdk/drivers/peripheral/slip/cat1Service/cat1_at_cmd.cpp
code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp
code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.h
code/sdk/drivers/peripheral/slip/cat1Service/pyscript/cat1Service.py
code/sdk/drivers/peripheral/slip/cat1Service/pyscript/current_img/EG810MCNLAR06A01M08_VOLTE_OCPU_QPY_BETA0312_20240429-1457.zip [new file with mode: 0644]
code/sdk/drivers/peripheral/utils/custom_utils.c

index b16dd83..2b46643 100644 (file)
@@ -103,8 +103,7 @@ void recovery_display_sample(void)
 
     recovery_dispay_layer_and_surface_init(&surface, &layer_info, &update_rect);
     // 设置layer全白色, 也可以使用接口 recovery_dispay_read_image_and_savein_surface 实现从文件系统读图片
-    /*
-        /* image_tool 图片压缩参数如下:
+    /* image_tool 图片压缩参数如下:
        <imageRes compress="NONE" format="RGB888" align="16" tile="6"
                  alpha="0" rgb="0" autocmpmode="0" highqualitymode="0"
                  highcmpratiomode="0" ver="1">
index f693932..bda1058 100644 (file)
@@ -260,11 +260,11 @@ static uint32_t AT_cat1_checkota(uint8_t *para, uint32_t paraLen, char *strCommo
     cat1_ota_update("0");
     return ERRCODE_SUCC;
 }
-static uint32_t AT_cat1_reset_network(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+static uint32_t at_cat1_atcmd(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
 {
     UNUSED(strCommonCmd);
-    printf("CAT1TEST ATCMD  cat1 reset\n");
-    cat1_reset_network();
+    printf("CAT1TEST ATCMD %s \n",para);
+    cat1_at_cmd((char*)para);
     return ERRCODE_SUCC;
 }
 
@@ -317,7 +317,7 @@ static const at_cmd_table_t g_cat1_cmd[] = {
     { (char *)"AT^CAT1WAKECAT1",      cat1_wakeup, (char *)"1" },
     { (char *)"AT^IFCONFIG",      cat1_ifconfig, (char *)"1" },
     { (char *)"AT^CAT1GETVER",      at_cat1_getver, (char *)"1" },
-    { (char *)"AT^CAT1RESETNETWORK",      AT_cat1_reset_network, (char *)"1" },
+    { (char *)"AT^CAT1AT",      at_cat1_atcmd, (char *)"1" },
     { (char *)"AT^CAT1OTA",      AT_cat1_checkota, (char *)"1" },
        { (char *)"AT^CALL_1",      AT_CALL_ifconfig, (char *)"1" },
     { (char *)"AT^CALL_ADD_ADRESSBOOK",      ADD_ADDRESS, (char *)"1" },
index 3efbca4..2457ecb 100644 (file)
@@ -67,7 +67,7 @@ enum UDP_COMMAND_HEAD {
     UDP_CMD_GET_TIME = '6',               // 获取Cat1 时间 ,YYYYMMDD HHmmss zone
     UDP_CMD_GET_RECV_NETWORKSTAT = '7',               //获取Cat1 信号信息,VOLTE信息,信号强度,SIM卡状态  // 内容同UDP_CMD_GET_NETWORKSTAT,CAT主动发给MCU
     UDP_MSG_SMS = '8',              //  CAT1接收到的SMS信息给MCU,包含电话号及短信内容
-    UDP_CMD_RESET_NETWORKSTAT = '9',              // 重置网络
+    UDP_CMD_MSG_ATCMD = '9',              // AT 指令
     UDP_MSG_CALL_CONNECTED = 'A',         //  CAT1 电话接听消息
     UDP_MSG_CALL_DISCONNECTED = 'B',         //  CAT1 电话挂断消息
     UDP_MSG_COMMING_CALL = 'C'  ,       //  CAT1 来电消息,包含电话号
@@ -173,17 +173,24 @@ void udp_send_msg_toCat1(char cmd,char *content)
      uapi_cat1_wakeup_cat1(0);
 }
 
-#define BOOTMSG_HEADER_STR "BOOTUP,"
+#define BOOTMSG_HEADER_STR "BOOTUP"
 #define BOOTMSG_HEADER_STR_LEN strlen(BOOTMSG_HEADER_STR)
 #define NETSTAT_HEADER_STR "imei:"
 #define NETSTAT_HEADER_STR_LEN strlen(NETSTAT_HEADER_STR)
-#define VERMSG_HEADER_STR "pyVer,"
+#define VERMSG_HEADER_STR "pyVer"
 #define VERMSG_HEADER_STR_LEN strlen(VERMSG_HEADER_STR)
 #define MSG_SPLIT_CHAR ","
+#define MSG_SPLIT_CHAR2 "@"
 
 
+// const char* msgboot = "BOOTUP:pyVer,PY_SRV_V4,modemVer,EG810MCNLAR06A01M08_VOLTE_OCPU_QPY_BETA0312";
+// const char* msgver ="pyVer,PY_SRV_V4,modemVer,EG810MCNLAR06A01M08_VOLTE_OCPU_QPY_BETA0312";
 static int decodeVersion(char* msg)
 {
+
+    int update = 0;
+    runtime_status_t * runtime = get_device_runtime_status();
+    
     if (strlen(msg) < 50)
     {
         PRINT("msg len is too short !\r\n");
@@ -192,56 +199,84 @@ static int decodeVersion(char* msg)
     char buf[200] = {0};
     if (strncmp(msg,BOOTMSG_HEADER_STR,BOOTMSG_HEADER_STR_LEN) ==0)
     {
-        strcpy(buf,msg+BOOTMSG_HEADER_STR_LEN);
+        strcpy(buf,msg+BOOTMSG_HEADER_STR_LEN+1);
         // PRINT("BOOTMSG =============\r\n");
+
     }
     else if (strncmp(msg,VERMSG_HEADER_STR,VERMSG_HEADER_STR_LEN) ==0)
     {
         strcpy(buf,msg);
         // PRINT("version =============\r\n");
+
     }else{
         return -2;
     }
-    char* p = MSG_SPLIT_CHAR;
+
+   char* p = MSG_SPLIT_CHAR;
+   if (strstr(buf,MSG_SPLIT_CHAR2) != NULL)
+    {
+        p = MSG_SPLIT_CHAR2;
+    }
     char* s = NULL;
-    char *pbuf[4] = {0};
-    int  i = 0;
-    int update = 0;
-    runtime_status_t * runtime = get_device_runtime_status();
     for (s = strtok(buf,p); s!=NULL;s=strtok(NULL,p))
     {
-        pbuf[i] = s;
-        if(i==1) 
+        if((strncmp(s,"pyVer",5) == 0) && (strlen(s)> 5))
         {
-            // PRINT("pyVer= %s\r\n",pbuf[i]);
-            if (strncmp(pbuf[i],"PY_",3) == 0 || strcmp(runtime->cat1_runtime.pyVer,pbuf[i])==0 )
+            char* ptmp=s+6;
+            PRINT("pyVer= %s\r\n",ptmp);
+            if ( strcmp(runtime->cat1_runtime.pyVer,ptmp)!=0 )
             {
                 update++;
+                memset(runtime->cat1_runtime.pyVer,0,sizeof(runtime->cat1_runtime.pyVer));
+                strcpy_s(runtime->cat1_runtime.pyVer,sizeof(runtime->cat1_runtime.pyVer),ptmp);
             }
-            memset(runtime->cat1_runtime.pyVer,0,sizeof(runtime->cat1_runtime.pyVer));
-            strcpy_s(runtime->cat1_runtime.pyVer,sizeof(runtime->cat1_runtime.pyVer),pbuf[i]);
-        }
-        else if (i==3)
+
+        }else if ((strncmp(s,"modemVer",8) == 0) && (strlen(s)> 8))
+        {
+            char* ptmp=s+9;
+            PRINT("modemVer= %s\r\n",ptmp);
+            if (strcmp(runtime->cat1_runtime.modemVer,ptmp) != 0)
+            {
+                update++;
+                memset(runtime->cat1_runtime.modemVer,0,sizeof(runtime->cat1_runtime.modemVer));
+                strcpy_s(runtime->cat1_runtime.modemVer,sizeof(runtime->cat1_runtime.modemVer),ptmp);
+            }
+        } else if (strncmp(s,"PY_",3) == 0 )
+        {
+            PRINT("pyVer = %s\r\n",s);
+            if ( strcmp(runtime->cat1_runtime.pyVer,s)!=0 )
+            {
+                update++;
+                memset(runtime->cat1_runtime.pyVer,0,sizeof(runtime->cat1_runtime.pyVer));
+                strcpy_s(runtime->cat1_runtime.pyVer,sizeof(runtime->cat1_runtime.pyVer),s);
+            }
+
+        }else if (strncmp(s,"EG810M",6) == 0 )
         {
-            // PRINT("modemVer= %s\r\n",pbuf[i]);
-            if (strncmp(pbuf[i],"EG810M",6) == 0 || strcmp(runtime->cat1_runtime.modemVer,pbuf[i]) == 0)
+            PRINT("modemVer = %s\r\n",s);
+            if (strcmp(runtime->cat1_runtime.modemVer,s) != 0)
             {
                 update++;
+                memset(runtime->cat1_runtime.modemVer,0,sizeof(runtime->cat1_runtime.modemVer));
+                strcpy_s(runtime->cat1_runtime.modemVer,sizeof(runtime->cat1_runtime.modemVer),s);
             }
-            memset(runtime->cat1_runtime.modemVer,0,sizeof(runtime->cat1_runtime.modemVer));
-            strcpy_s(runtime->cat1_runtime.modemVer,sizeof(runtime->cat1_runtime.modemVer),pbuf[i]);
         }
-        i++;
     }
+    
     if (update > 0)
         return 0;
     else 
         return -3;
 }
-
-
+// const char* msgnet ="imei:860132060352796,sim:0,oper:-1,signal:99,net:([99, 0, 0, 0], [0, 0, 0, 0, 0])";
+// const char* msgnetfull = "imei:864430010001091,sim:1,oper:('CHN-CT', 'CT', '460', '11'),signal:22,net:([99, 99, 255, 255], [-71, -103, -12, 255, 4])";
+// ([rssi, bitErrorRate, rscp, ecno], [rssi, rsrp, rsrq, cqi, sinr])
+// const char* msgnet ="imei:860132060352796@sim:0@oper:-1@signal:99@net:([99, 0, 0, 0], [0, 0, 0, 0, 0])";
+// const char* msgnetfull = "imei:864430010001091@sim:1@oper:('CHN-CT', 'CT', '460', '11')@signal:22@net:([99, 99, 255, 255], [-71, -103, -12, 255, 4])";
 static int decodeNetStat(char* msg)
 {
+    int update = 0;
+    runtime_status_t * runtime = get_device_runtime_status();
     if (strlen(msg) < 50)
     {
         PRINT("msg len is too short !\r\n");
@@ -251,78 +286,71 @@ static int decodeNetStat(char* msg)
     if (strncmp(msg,NETSTAT_HEADER_STR,NETSTAT_HEADER_STR_LEN) ==0)
     {
         strcpy(buf,msg);
-        // PRINT("net stat  =============\r\n");
     }else{
         return -2;
     }
     char* p = MSG_SPLIT_CHAR;
+    if (strstr(buf,MSG_SPLIT_CHAR2) != NULL)
+    {
+        p = MSG_SPLIT_CHAR2;
+    }
     char* s = NULL;
-    char *pbuf[6] = {0};
-    char *ppbuf ;
-    int  i = 0;
-    int update = 0;
-    runtime_status_t * runtime = get_device_runtime_status();
+    char* ppbuf = NULL;
     for (s = strtok(buf,p); s!=NULL;s=strtok(NULL,p))
     {
-        pbuf[i] = s;
-        if(strncmp(pbuf[i],"imei:",5) == 0)
+        // PRINT("%s\r\n",s );
+        if(strncmp(s,"imei:",5) == 0)
         {
-            ppbuf=pbuf[i]+5;
+            ppbuf = s+5;
             PRINT("=== imei = %s\r\n",ppbuf);
-            if ( strcmp(runtime->cat1_runtime.imei,ppbuf)==0 )
+            if ( strcmp(runtime->cat1_runtime.imei,ppbuf)!=0 )
             {
-                 update++;
+                update++;
+                memset(runtime->cat1_runtime.imei,0,sizeof(runtime->cat1_runtime.imei));
+                strcpy_s(runtime->cat1_runtime.imei,sizeof(runtime->cat1_runtime.imei),ppbuf);
             }   
-            memset(runtime->cat1_runtime.imei,0,sizeof(runtime->cat1_runtime.imei));
-            strcpy_s(runtime->cat1_runtime.imei,sizeof(runtime->cat1_runtime.imei),ppbuf);
-            i++;
             continue;
-        } 
-        if(strncmp(pbuf[i],"sim:",4) == 0)
+        }else if(strncmp(s,"sim:",4) == 0)
         {
-            ppbuf=pbuf[i]+4;
+            ppbuf=s+4;
             int simstat = atoi(ppbuf);
             PRINT("=== sim = %d\r\n",simstat);
             if ( runtime->cat1_runtime.sim != simstat)
             {
                 update++;
+                runtime->cat1_runtime.sim = simstat;
             }  
-            runtime->cat1_runtime.sim = simstat;
-            i++;
             continue;
-        }   
-        if(strncmp(pbuf[i],"oper:",5) == 0)
+        }else if(strncmp(s,"oper:",5) == 0)
         {
 
-            if( *(pbuf[i]+5) == '(' )
-                ppbuf=pbuf[i]+6;
+            if( *(s+5) == '(' && (p != MSG_SPLIT_CHAR2))
+                ppbuf=s+6;
             else 
-                ppbuf=pbuf[i]+5;
+                ppbuf=s+5;
         
             PRINT("=== opera = %s\r\n",ppbuf);
-            if ( strcmp(runtime->cat1_runtime.opera,ppbuf)==0 )
+            if ( strcmp(runtime->cat1_runtime.opera,ppbuf)!=0 )
             {
-                 update++;
+                update++;
+                memset(runtime->cat1_runtime.opera,0,sizeof(runtime->cat1_runtime.opera));
+                strcpy_s(runtime->cat1_runtime.opera,sizeof(runtime->cat1_runtime.opera),ppbuf);
             } 
-            memset(runtime->cat1_runtime.opera,0,sizeof(runtime->cat1_runtime.opera));
-            strcpy_s(runtime->cat1_runtime.opera,sizeof(runtime->cat1_runtime.opera),ppbuf);
-            i++;
+
             continue;
-        }
-        if(strncmp(pbuf[i],"signal:",7) == 0)
+        }else if(strncmp(s,"signal:",7) == 0)
         {
-            ppbuf=pbuf[i]+7;
+            ppbuf=s+7;
             int signals = atoi(ppbuf);
             PRINT("=== signal = %d\r\n",signals);
             if ( runtime->cat1_runtime.signal != signals)
             {
                 update++;
+                runtime->cat1_runtime.signal = signals;
             }  
-            runtime->cat1_runtime.signal = signals;
-            i++;
             continue;
         }  
-        if (i>=4) break;
+        
     }
     if (update > 0)
         return 0;
@@ -349,9 +377,9 @@ void cat1_call_dial(char* phonenum)
     udp_send_msg_toCat1(UDP_CMD_DIAL_NUMB,phonenum);
 }
 
-void cat1_reset_network(void)
+void cat1_at_cmd(char * cmd)
 {
-    udp_send_msg_toCat1(UDP_CMD_RESET_NETWORKSTAT,"0");
+    udp_send_msg_toCat1(UDP_CMD_MSG_ATCMD,cmd);
 }
 
 void cat1_getsignal(void)
@@ -469,6 +497,7 @@ int cat1_handle_timesync(struct tcp_msg_t *msg)
     WEARABLE_LOGI(WEARABLE_LOG_MODULE_MAIN_SERVICE,"cat1 cat1_handle_timesync %s\n",timesync);
 
     // ('24/03/01 07:15:36 8 0', 1709277336, 0)
+    // "4294938528@(2106, 2, 7, 6, 28, 48, 6, 38)@8"
     //TODO:设置时间
     // if (g_time_synced == 0)
     {
@@ -614,8 +643,11 @@ static int udp_packet_parse(char *rx_buffer, int len)
                 }
                
                 break;
-             case UDP_CMD_GET_CAT1VER:
+            case UDP_CMD_GET_CAT1VER:
                 index = cat1_handle_version_msg(msg);
+                break;
+            case UDP_CMD_MSG_ATCMD:
+                PRINT("ATCMD reply : %s\n", msg->buffer);
                 break;
                    default:
                            PRINT("error message: %s\n", rx_buffer);
index 3032a0b..faf31ff 100644 (file)
@@ -26,7 +26,7 @@ void cat1_call_sms_send(char* phonenum,char* sms_txt);
 void cat1_gettime(void);
 void cat1_getver(void);
 void restart_time_sync(void);
-void cat1_reset_network(void);
+void cat1_at_cmd(char* cmd);
 
 errcode_t cat1_server_init(void);
 
index 11c9ec0..2016acf 100644 (file)
@@ -50,7 +50,7 @@ import request
 import ql_fs
 import pm
 PROJECT_NAME = "Cat1SlipUDPService"
-PROJECT_VERSION = "PY_SRV_V4"
+PROJECT_VERSION = "PY_SRV_V5"
 CONFIG_JSON="/usr/system_config.json"
 CURRENT_APP_TYPE="pysrv"
 
@@ -144,7 +144,7 @@ UDP_CMD_SEND_SMS = '5'         #发送SMS短信,mcu提供电话号及短信内
 UDP_CMD_GET_TIME = '6'               #获取Cat1 时间 ,YYYYMMDD HHmmss zone
 UDP_CMD_GET_RECV_NETWORKSTAT = '7'      #获取Cat1 信号信息,VOLTE信息,信号强度,SIM卡状态  // 内容同UDP_CMD_GET_NETWORKSTAT,CAT主动发给MCU
 UDP_MSG_SMS = '8'           #  CAT1接收到的SMS信息给MCU,包含电话号及短信内容
-UDP_CMD_RESET_NETWORKSTAT = '9'           # 重置网络
+UDP_CMD_ATCMD = '9'           # 执行AT指令
 UDP_MSG_CALL_CONNECTED = 'A'       #  CAT1 电话接听消息
 UDP_MSG_CALL_DISCONNECTED = 'B'        #  CAT1 电话挂断消息
 UDP_MSG_COMMING_CALL = 'C'       #  CAT1 来电消息,包含电话号
@@ -222,7 +222,7 @@ class Cat1Service:
     
     def bootup_msg_to_bt(self):
         modem_ver = modem.getDevFwVersion() 
-        self.reply_cmd('FF',"BOOTUP,pyVer,{},modemVer,{}".format(PROJECT_VERSION,modem_ver))
+        self.reply_cmd('FF',"BOOTUP@pyVer:{}@modemVer:{}".format(PROJECT_VERSION,modem_ver))
 
     def btmcu_cmd_handler(self,cmd,parm):
         print("btmcu_cmd_handler cmd {0} , args {1}".format(cmd,parm))
@@ -230,7 +230,7 @@ class Cat1Service:
             print(cmd)
             # UDP_CMD_GET_CAT1VER
             modem_ver = modem.getDevFwVersion() 
-            self.reply_cmd('F0',"pyVer,{},modemVer,{}".format(PROJECT_VERSION,modem_ver))
+            self.reply_cmd('F0',"pyVer:{}@modemVer:{}".format(PROJECT_VERSION,modem_ver))
         elif cmd == "F1":
             print("{}{}".format(cmd,parm))
             # UDP_CMD_DIAL_NUMB
@@ -260,7 +260,10 @@ class Cat1Service:
             time=utime.localtime()
             zone=utime.getTimeZone()
             #(2024, 3, 2, 18, 31, 32, 5, 62),8
-            self.reply_cmd('F6',"{0},{1}".format(time,zone))
+            # 返回当前时间戳,参数为元组
+            # timestamp = utime.mktime(time)
+            # cat1service_log.info(timestamp)
+            self.reply_cmd('F6',"{0}@{1}".format(time,zone))
         elif cmd == "F7":
             print(cmd)
             # UDP_CMD_GET_RECV_NETWORKSTAT
@@ -270,16 +273,20 @@ class Cat1Service:
             operator =  net.operatorName()
             signal = net.csqQueryPoll()
             print("imei:{0},sim:{1},oper:{2},signal:{3},net:{4}".format(imei,simstat,operator,signal,netstat))
-            self.reply_cmd('F7',"imei:{0},sim:{1},oper:{2},signal:{3},net:{4}".format(imei,simstat,operator,signal,netstat))
+            self.reply_cmd('F7',"imei:{0}@sim:{1}@oper:{2}@signal:{3}@net:{4}".format(imei,simstat,operator,signal,netstat))
         elif cmd == "F9":
-            print(cmd)
-            # UDP_CMD_RESET_NETWORKSTAT
-            net.setModemFun(0)
-            net.setModemFun(1)
-            # resp=bytearray(50)
-            # ret=atcmd.sendSync('AT+CFUN=1?\r\n',resp,'',20)
-            # print("reply:{},ret:{}".format(resp,ret))
-            # self.reply_cmd('F9',"ret:{}".format(ret))
+            print("{},{}".format(cmd,parm))
+            # UDP_CMD_ATCMD
+            # net.setModemFun(0)
+            # net.setModemFun(1)
+            resp=bytearray(50)
+            ret=atcmd.sendSync("{}\r\n".format(parm),resp,'',10)
+            if ret == 0:
+                print("reply:{},ret:{}".format(resp.decode(),ret))
+                self.reply_cmd('F9',"{}".format(resp.decode()))
+            else:
+                print("cmd error ret:{}".format(ret))
+                self.reply_cmd('F9',"{}".format("at error"))
 
 
     # 来电提醒
diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/pyscript/current_img/EG810MCNLAR06A01M08_VOLTE_OCPU_QPY_BETA0312_20240429-1457.zip b/code/sdk/drivers/peripheral/slip/cat1Service/pyscript/current_img/EG810MCNLAR06A01M08_VOLTE_OCPU_QPY_BETA0312_20240429-1457.zip
new file mode 100644 (file)
index 0000000..ad4b60d
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e958a4c6c18bb196e9bc602c3dca833d98637529c5b54fa73bd1103eacdf4a57
+size 11615507
index 6549d36..1b33440 100644 (file)
@@ -358,7 +358,7 @@ errcode_t uapi_get_timestampe_ss(uint32_t *tm)
 #define TIME_YEAR_OFFSET        123
 #define TIME_ZONE_OFF           (8 * 60)
 #define TIME_SECSPERMIN         60     /* second per minute */
-static uint32_t get_sec_time_from_cat1time(char* time , uint32_t *second , uint8_t *zone)
+static uint32_t get_sec_time_from_cat1time(char* time , uint32_t *second , int *zone)
 {
 
     struct tm _tm = { 0 };
@@ -446,11 +446,128 @@ static uint32_t get_sec_time_from_cat1time(char* time , uint32_t *second , uint8
     //  printf("%04d-%02d-%02d %02d:%02d:%02d %d\n",_tm.tm_year,_tm.tm_mon,_tm.tm_mday,_tm.tm_hour,_tm.tm_min,_tm.tm_sec,*zone);
     return 0;
 }
+
+static int decodeTime(char* time,uint32_t *timeseconds,int *zone)
+{
+    
+    struct tm _tm = { 0 };
+    if (time==NULL || strlen(time) < 12)
+    {
+        printf("time==NULL || strlen(time) < 12 , format error, should like [(2024, 3, 2, 18, 40, 1, 5, 62),8]  or [(2106, 2, 7, 6, 28, 48, 6, 38)@8] ");
+        return 2;
+    }
+    // const char* timestr="(2024, 3, 2, 18, 40, 1, 5, 62),8";
+
+    char buf[50] = {0};
+    if (strlen(time)>sizeof(buf))
+    {
+        strncpy(buf,time,sizeof(buf));
+
+    }else{
+        strncpy(buf,time,strlen(time));
+
+    }
+    
+    char* p = ")";
+    char* s = NULL;
+    // PRINT("origin %s, %s \r\n",time,buf);
+    char tmp_time_buf[50]={0};
+    int tmp_zone=0;
+    uint32_t tmp_timestamp =0 ;
+
+    int index=0;
+    for (s = strtok(buf,p); s!=NULL;s=strtok(NULL,p))
+    {   
+        if (index == 0 )
+        {
+            char* ptime = s+1;
+            strncpy(tmp_time_buf,ptime,strlen(ptime));
+            // PRINT("ptime= %s \r\n",ptime );
+            
+        }else if (index == 1)
+        {
+            char* pzone = s+1;
+            // PRINT("pzone %s\r\n",pzone);
+            tmp_zone = strtol(pzone, NULL, DECIMAL);
+    
+        }
+        index++;
+    }   
+    
+    int i = 0;
+    s = NULL;
+
+    // PRINT("time %s zone %d\r\n",tmp_time_buf,tmp_zone);
+
+    for (s = strtok(tmp_time_buf,","); s!=NULL;s=strtok(NULL,","))
+    {
+        // printf("[%d]%s\r\n",i,s);
+        switch(i)
+        {
+            case 0://year
+                // 年的计算需要减去1900
+                _tm.tm_year = strtol(s, NULL, DECIMAL) - 1900;
+                if (_tm.tm_year < TIME_YEAR_OFFSET) {
+                    PRINT("ERR!year num must bigger than 2023!");
+                    return 3;
+                }
+                break;
+            case 1://month
+                // 月的计算需要减1
+                if (s[0] == ' ')
+                    _tm.tm_mon = strtol(s+1, NULL, DECIMAL) - 1;
+                else
+                    _tm.tm_mon = strtol(s, NULL, DECIMAL) - 1;
+                break;
+            case 2://day
+                if (s[0] == ' ')
+                    _tm.tm_mday = strtol(s+1, NULL, DECIMAL);
+                else
+                    _tm.tm_mday = strtol(s, NULL, DECIMAL);
+                break;
+            case 3://hour
+                if (s[0] == ' ')
+                    _tm.tm_hour = strtol(s+1, NULL, DECIMAL);
+                else
+                    _tm.tm_hour = strtol(s, NULL, DECIMAL);
+                break;
+            case 4://minitue
+                if (s[0] == ' ')
+                    _tm.tm_min = strtol(s+1, NULL, DECIMAL);
+                else
+                    _tm.tm_min = strtol(s, NULL, DECIMAL);
+                break;
+            case 5://seconds
+                if (s[0] == ' ')
+                    _tm.tm_sec = strtol(s+1, NULL, DECIMAL);
+                else
+                    _tm.tm_sec = strtol(s, NULL, DECIMAL);
+                break;
+            default:
+                break;        
+        }
+        i++;
+    }
+    tmp_timestamp = (uint32_t)mktime(&_tm);
+    // 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,
+     tmp_zone);
+    
+    
+    *zone = tmp_zone;
+    *timeseconds  = tmp_timestamp;
+
+    return 0;
+    
+} 
 errcode_t uapi_set_time_from_cat1(char* cat1time)
 {
-    uint8_t zone = 0;
+    int zone = 0;
      uint32_t sec = 0;
-     uint32_t ret = get_sec_time_from_cat1time(cat1time,&sec,&zone);
+    //  uint32_t ret = get_sec_time_from_cat1time(cat1time,&sec,&zone);
+     uint32_t ret = decodeTime(cat1time,&sec,&zone);
 
      if (ret == 0 )
      {