更新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{
}