Embedded TCP/IP stack: fnet_sntp.h Source File

FNET

fnet_sntp.h
1 /**************************************************************************
2 *
3 * Copyright 2017 by Andrey Butok. FNET Community.
4 *
5 ***************************************************************************
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may
8 * not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 ***************************************************************************
20 *
21 * SNTP Client API.
22 *
23 ***************************************************************************/
24 
25 #ifndef _FNET_SNTP_H_
26 
27 #define _FNET_SNTP_H_
28 
29 #if FNET_CFG_SNTP || defined(__DOXYGEN__)
30 
62 /**************************************************************************/
69 typedef struct
70 {
71  fnet_uint32_t seconds;
72  fnet_uint32_t seconds_fraction;
74 
75 /**************************************************************************/
79 typedef struct
80 {
81  fnet_uint32_t year;
82  fnet_uint32_t month;
83  fnet_uint32_t day;
84  fnet_uint32_t hour;
85  fnet_uint32_t minute;
86  fnet_uint32_t second;
87  fnet_uint32_t millisecond;
89 
90 /**************************************************************************/
101 typedef void(*fnet_sntp_callback_resolved_t)(const fnet_sntp_timestamp_t *timestamp, void *cookie);
102 
103 /**************************************************************************/
107 {
113  void *cookie;
116 };
117 
118 #if defined(__cplusplus)
119 extern "C" {
120 #endif
121 
122 /***************************************************************************/
150 
151 /***************************************************************************/
166 void fnet_sntp_release(void);
167 
168 /***************************************************************************/
184 
185 
186 
187 #if defined(__cplusplus)
188 }
189 #endif
190 
193 #endif /* FNET_CFG_SNTP */
194 
195 #endif /* _FNET_SNTP_H_ */
fnet_uint32_t seconds
Seconds (host endian).
Definition: fnet_sntp.h:71
fnet_uint32_t month
Month (1-12).
Definition: fnet_sntp.h:82
Coordinated Universal Time (UTC) type.
Definition: fnet_sntp.h:79
fnet_uint32_t day
Day of the month (1-31) .
Definition: fnet_sntp.h:83
fnet_uint32_t millisecond
Milliseconds (0-999).
Definition: fnet_sntp.h:87
fnet_return_t
General return codes, used by most of API functions.
Definition: fnet_stdlib.h:90
fnet_uint32_t year
Year (1968-2104).
Definition: fnet_sntp.h:81
Initialization parameters for the fnet_sntp_init() function.
Definition: fnet_sntp.h:106
void(* fnet_sntp_callback_resolved_t)(const fnet_sntp_timestamp_t *timestamp, void *cookie)
Prototype of the SNTP-client callback function that is called when the SNTP client has completed the ...
Definition: fnet_sntp.h:101
void fnet_sntp_release(void)
Aborts the time resolving and releases the SNTP-client service.
SNTP timestamp (RFC4330) is represented as a 64-bit unsigned fixed-point number, in seconds relative ...
Definition: fnet_sntp.h:69
void fnet_sntp_timestamp2utc(const fnet_sntp_timestamp_t *timestamp, fnet_sntp_utc_t *utc)
Converts the SNTP timestamp to the Coordinated Universal Time (UTC).
fnet_sntp_callback_resolved_t callback
Pointer to the callback function defined by fnet_sntp_callback_resolved_t. It is called when the SNTP...
Definition: fnet_sntp.h:110
fnet_uint32_t minute
Minutes (0-59).
Definition: fnet_sntp.h:85
fnet_uint32_t hour
Hour (0-23).
Definition: fnet_sntp.h:84
void * cookie
Optional application-specific parameter. It's passed to the callback function as input parameter...
Definition: fnet_sntp.h:113
fnet_return_t fnet_sntp_init(struct fnet_sntp_params *params)
Initializes the SNTP client service and starts the time resolving.
fnet_uint32_t second
Seconds (0-59).
Definition: fnet_sntp.h:86
Socket address structure.
Definition: fnet_socket.h:270
fnet_uint32_t seconds_fraction
Seconds Fraction (host endian).
Definition: fnet_sntp.h:72
struct fnet_sockaddr sntp_server_addr
Socket address of the remote SNTP/NTP server to connect to.
Definition: fnet_sntp.h:108

© 2005-2018 by Andrey Butok. http://fnet.sourceforge.net