blob: a9d54d927518f2a821b91c4313096a52610dcb12 [file] [log] [blame]
b.liud440f9f2025-04-18 10:44:31 +08001/**@file lynq-systime.h
2 *
3 * @brief Sync systime form each time source.
4 *
5 * @author sj.zhang
6 *
7 * @date 2023-08-14
8 *
9 * @version V1.0
10 *
11 * @copyright Copyright (c) MobileTek
12 */
13#include <stdio.h>
14#include <string.h>
15#include <stdlib.h>
16#include <time.h>
17#include "lynq_uci.h"
18
19#ifndef _LYNQ_SYSTIME_H_
20#define _LYNQ_SYSTIME_H_
21
22#ifdef __cplusplus
23extern "C"
24{
25#endif
26
27typedef struct time_source_status
28{
29 int ntp;
30 int nitz;
31 int gnss;
32}time_src_status_s;
33
34#ifdef MOBILETEK_TARGET_PLATFORM_T106
35
36 /**@brief Set the rtc time to the system time.
37 *
38 * @param void
39 *
40 * @return
41 * 0:success
42 * other:failure
43 */
44 int lynq_sync_time_from_rtc(void);
45
46 /**@brief Set the system time to the rtc time.
47 *
48 * @param void
49 *
50 * @return
51 * 0:success
52 * other:failure
53 */
54 int lynq_set_rtc_time(void);
55
56 /**@brief Query the rtc time.
57 *
58 * @param [OUT] ulsec: rtc time, secconds from 1900.1.1 00:00
59 *
60 * @return
61 * 0:success
62 * other:failure
63 */
64 int lynq_get_rtc_time(unsigned long *ulsec);
65#endif
66
67 /**@brief Query the time source status now.
68 *
69 * @param [OUT] ntp, nitz, gnss:
70 * 0: disable
71 * 1: enable
72 *
73 * @return
74 * 0 : success
75 * other:failure
76 */
77 int lynq_get_time_src_status(time_src_status_s *time_src);
78
79 /**@brief Turn sntp on/off
80 *
81 * @param enable [IN] : 0 disenable; 1 enable;
82 *
83 * @return
84 * 0 set success
85 * 1 SNTP_DISENABLE
86 * 2 SNTP_ALREADY_ENABLE
87 */
88 int ntp_sync_time(int enable);
89
90 /**@brief Enable/Disenable sync time from NITZ.
91 *
92 * @param enable [IN] : 0 disenable; 1 enable;
93 *
94 * @return
95 * 0:success
96 * other:failure
97 */
98 int modem_time_enable(int enable);
99
100 /**@brief Enable/Disenable sync time from GNSS.
101 *
102 * @param enable [IN] : 0 disenable; 1 enable;
103 *
104 * @return
105 * 0:success
106 * other:failure
107 */
108 int gnss_time_enable(int enable);
109
110 /**@brief User set systime manually.
111 *
112 * @param enable [IN] : 0 disenable; 1 enable;
113 *
114 * @return
115 * 0:success
116 * other:failure
117 */
118 int user_set_time(char *date, char *time);
119
120 int get_sync_time_result(void );
121
122#ifdef __cplusplus
123}
124#endif
125#endif