b.liu | 4e243dc | 2023-11-27 11:20:00 +0800 | [diff] [blame^] | 1 | /**@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 |
|
| 18 | #ifndef _LYNQ_SYSTIME_H_
|
| 19 | #define _LYNQ_SYSTIME_H_
|
| 20 |
|
| 21 | #ifdef __cplusplus
|
| 22 | extern "C"
|
| 23 | {
|
| 24 | #endif
|
| 25 |
|
| 26 | typedef struct time_source_status
|
| 27 | {
|
| 28 | int ntp;
|
| 29 | int nitz;
|
| 30 | int gnss;
|
| 31 | }time_src_status_s;
|
| 32 |
|
| 33 | #ifdef MOBILETEK_TARGET_PLATFORM_T106
|
| 34 |
|
| 35 | /**@brief Set the rtc time to the system time.
|
| 36 | *
|
| 37 | * @param void
|
| 38 | *
|
| 39 | * @return
|
| 40 | * 0:success
|
| 41 | * other:failure
|
| 42 | */
|
| 43 | int lynq_sync_time_from_rtc(void);
|
| 44 |
|
| 45 | /**@brief Set the system time to the rtc time.
|
| 46 | *
|
| 47 | * @param void
|
| 48 | *
|
| 49 | * @return
|
| 50 | * 0:success
|
| 51 | * other:failure
|
| 52 | */
|
| 53 | int lynq_set_rtc_time(void);
|
| 54 |
|
| 55 | /**@brief Query the rtc time.
|
| 56 | *
|
| 57 | * @param [OUT] ulsec: rtc time, secconds from 1900.1.1 00:00
|
| 58 | *
|
| 59 | * @return
|
| 60 | * 0:success
|
| 61 | * other:failure
|
| 62 | */
|
| 63 | int lynq_get_rtc_time(unsigned long *ulsec);
|
| 64 | #endif
|
| 65 |
|
| 66 | /**@brief Query the time source status now.
|
| 67 | *
|
| 68 | * @param [OUT] ntp, nitz, gnss:
|
| 69 | * 0: disable
|
| 70 | * 1: enable
|
| 71 | *
|
| 72 | * @return
|
| 73 | * 0 : success
|
| 74 | * other:failure
|
| 75 | */
|
| 76 | int lynq_get_time_src_status(time_src_status_s *time_src);
|
| 77 |
|
| 78 | /**@brief Turn sntp on/off
|
| 79 | *
|
| 80 | * @param enable [IN] : 0 disenable; 1 enable;
|
| 81 | *
|
| 82 | * @return
|
| 83 | * 0 set success
|
| 84 | * 1 SNTP_DISENABLE
|
| 85 | * 2 SNTP_ALREADY_ENABLE
|
| 86 | */
|
| 87 | int ntp_sync_time(int enable);
|
| 88 |
|
| 89 | /**@brief Enable/Disenable sync time from NITZ.
|
| 90 | *
|
| 91 | * @param enable [IN] : 0 disenable; 1 enable;
|
| 92 | *
|
| 93 | * @return
|
| 94 | * 0:success
|
| 95 | * other:failure
|
| 96 | */
|
| 97 | int modem_time_enable(int enable);
|
| 98 |
|
| 99 | /**@brief Enable/Disenable sync time from GNSS.
|
| 100 | *
|
| 101 | * @param enable [IN] : 0 disenable; 1 enable;
|
| 102 | *
|
| 103 | * @return
|
| 104 | * 0:success
|
| 105 | * other:failure
|
| 106 | */
|
| 107 | int gnss_time_enable(int enable);
|
| 108 |
|
| 109 | /**@brief User set systime manually.
|
| 110 | *
|
| 111 | * @param enable [IN] : 0 disenable; 1 enable;
|
| 112 | *
|
| 113 | * @return
|
| 114 | * 0:success
|
| 115 | * other:failure
|
| 116 | */
|
| 117 | int user_set_time(char *date, char *time);
|
| 118 |
|
| 119 | #ifdef __cplusplus
|
| 120 | }
|
| 121 | #endif
|
| 122 | #endif
|