blob: f21f546872acde258d9f6b0b0ed4868ec39e3655 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/*
* ntp_client.h
*
* Copyright © 2023 Thomas White <taw@physics.org>
*
* This file is part of MorningTown
*
* Based on pico-examples/pico_w/ntp_client/picow_ntp_client.c
* Original license: BSD-3-Clause
* Copyright (c) 2022 Raspberry Pi (Trading) Ltd.
*
* MorningTown is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MorningTown is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MorningTown. If not, see <http://www.gnu.org/licenses/>.
*
*/
typedef struct NTP_T_ NTP_T;
/* Set your offset from UTC here, in seconds
* UTC+1 = 3600
* Sorry, no automatic DST handling yet. */
#define UTC_OFFSET_SEC 3600
enum {
NTP_DNS_ERROR,
NTP_DNS_NO_ADDR,
NTP_REQUEST_SENT,
NTP_BAD_REPLY,
NTP_TIMEOUT,
NTP_REPLY_RECEIVED
};
extern NTP_T *ntp_init(void (*reply_func)(int));
extern void ntp_send_request(NTP_T *state);
extern void ntp_poll(NTP_T *state);
/* For verbose debugging, switch the commenting of these two lines.
* .. and see CMakeLists.txt */
static void debug_print(const char *str, ...) {}
//#define debug_print printf
|