更新systime部分的代码,同步优化demo

Change-Id: Id2f58d7f4530f8fd44e6ef49ba3643bc0c1b4ea4
diff --git a/mbtk/lynq_lib/src/lynq_time.c b/mbtk/lynq_lib/src/lynq_time.c
index d027b62..5b59a18 100755
--- a/mbtk/lynq_lib/src/lynq_time.c
+++ b/mbtk/lynq_lib/src/lynq_time.c
@@ -27,11 +27,13 @@
 
 
 typedef enum {
-    MBTK_TIME_TYPE_CELL = 0,  //NITZ
-    MBTK_TIME_TYPE_NTP,
-    MBTK_TIME_TYPE_GNSS,
-    MBTK_TIME_TYPE_USER
-} mbtk_time_type_enum;
+    LYNQ_TIME_TYPE_CELL = 0,  //NITZ
+    LYNQ_TIME_TYPE_NTP,
+    LYNQ_TIME_TYPE_GNSS,
+    LYNQ_TIME_TYPE_USER,
+    
+    LYNQ_TIME_TYPE_UNUSE
+} lynq_time_type_enum;
 
 //enable set time from ntp
 int ntp_sync_time(int enable); 
@@ -93,7 +95,7 @@
     while(1){
         memset(time_type, 0, 10);
         property_get("persist.mbtk.time_type", time_type, "0");
-    	if(atoi(time_type) == MBTK_TIME_TYPE_NTP) // NTP time
+    	if(atoi(time_type) == LYNQ_TIME_TYPE_NTP) // NTP time
     	{
             char time_str[100] = {0};
             time_t time = 0;
@@ -150,9 +152,14 @@
     UNUSED(enable);
     if(enable)
     {
-        set_time_type(MBTK_TIME_TYPE_NTP);
+        set_time_type(LYNQ_TIME_TYPE_NTP);
         ntp_pthread_run();
     }
+    else
+    {
+        set_time_type(LYNQ_TIME_TYPE_UNUSE);
+    }
+
     return 0;
 }
 
@@ -163,7 +170,11 @@
 
     if(enable)
     {
-        set_time_type(MBTK_TIME_TYPE_CELL);
+        set_time_type(LYNQ_TIME_TYPE_CELL);
+    }
+    else
+    {
+        set_time_type(LYNQ_TIME_TYPE_UNUSE);
     }
     return 0;
 }
@@ -175,8 +186,13 @@
     UNUSED(enable);
     if(enable)
     {
-        set_time_type(MBTK_TIME_TYPE_GNSS);
+        set_time_type(LYNQ_TIME_TYPE_GNSS);
     }
+    else
+    {
+        set_time_type(LYNQ_TIME_TYPE_UNUSE);
+    }
+
     return 0;
 }
 
@@ -201,12 +217,12 @@
     if(p2 == NULL)
     {
         sprintf(time_str, "%s %s:00", date, time);  //2023-11-30 11:30
-        set_time_type(MBTK_TIME_TYPE_USER);
+        set_time_type(LYNQ_TIME_TYPE_USER);
         ret = set_time_user(time_str);
     }else
     {
         sprintf(time_str, "%s %s", date, time); //2023-11-30 11:30:31
-        set_time_type(MBTK_TIME_TYPE_USER);
+        set_time_type(LYNQ_TIME_TYPE_USER);
         ret = set_time_user(time_str);
     }
 
@@ -224,12 +240,16 @@
 
     type = atoi(time_type);
     printf("time_type :%d", type);
-    if(type == MBTK_TIME_TYPE_NTP){
+    if(type == LYNQ_TIME_TYPE_NTP){
         time_src->ntp = 1;
-    }else if(type == MBTK_TIME_TYPE_CELL){
+    }else if(type == LYNQ_TIME_TYPE_CELL){
         time_src->nitz = 1;
-    }else if(type == MBTK_TIME_TYPE_GNSS){
+    }else if(type == LYNQ_TIME_TYPE_GNSS){
         time_src->gnss = 1;
+    }else if(type == LYNQ_TIME_TYPE_UNUSE){
+        time_src->ntp = 0;
+        time_src->nitz = 0;
+        time_src->gnss = 0;
     }else{
 
     }
diff --git a/mbtk/test/asr1806/lynq_time_test.c b/mbtk/test/asr1806/lynq_time_test.c
index ec10c27..886f4d3 100755
--- a/mbtk/test/asr1806/lynq_time_test.c
+++ b/mbtk/test/asr1806/lynq_time_test.c
@@ -11,6 +11,7 @@
     int opt;
     time_src_status_s time_src ={0};
     unsigned long ulsec =0;
+    int en;
 
     while(1)
     {
@@ -36,16 +37,46 @@
                 printf("main exit\n");
                 return 0;
             case 1:
-                //enable set time from ntp
-                ntp_sync_time(1);
+                {
+                    printf(">>>>>Input 0 or 1<<<<<\n");
+                    memset(operator, 0x00, sizeof(operator));
+                    fgets(operator, sizeof(operator)-1, stdin);
+                    fflush(stdin);
+                    en = atoi(operator);
+                    //enable set time from ntp
+                    if (en == 0 || en == 1)
+                        ntp_sync_time(en);
+                    else
+                        printf(">>>>>RE Input 0 or 1<<<<<\n");
+                }
                 break;
             case 2:
-                //enable set time from nitz
-                modem_time_enable(1);
+                 {
+                    printf(">>>>>Input 0 or 1<<<<<\n");
+                    memset(operator, 0x00, sizeof(operator));
+                    fgets(operator, sizeof(operator)-1, stdin);
+                    fflush(stdin);
+                    en = atoi(operator);
+                    //enable set time from nitz
+                    if (en == 0 || en == 1)
+                        modem_time_enable(en);
+                    else
+                        printf(">>>>>RE Input 0 or 1<<<<<\n");
+                }
                 break;
             case 3:
-                //enable set time from gnss
-                gnss_time_enable(1);
+                 {
+                    printf(">>>>>Input 0 or 1<<<<<\n");
+                    memset(operator, 0x00, sizeof(operator));
+                    fgets(operator, sizeof(operator)-1, stdin);
+                    fflush(stdin);
+                    en = atoi(operator);
+                    //enable set time from gnss
+                    if (en == 0 || en == 1)
+                        gnss_time_enable(en);
+                    else
+                        printf(">>>>>RE Input 0 or 1<<<<<\n");
+                }
                 break;
             case 4:
                 //enable set time from user