MistyGro API
C++ API for MistyGro's ESP32 controller based on the Arduino framework
timer.h
Go to the documentation of this file.
1 /*
2  * Copyright 2023 Myron Rodrigues
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _TIMER_H_
18 #define _TIMER_H_
19 
20 #include <WiFi.h>
21 
26 class Timer
27 {
28 private:
29  static const char * ntp_server_;
30 
31 public:
32  Timer();
33 
39  tm get_utc_time();
40 
46  time_t get_epoch_time();
47 
52  void print_utc_time();
53 
59  void begin(long int sync_interval_ms = 600000); // 10 mins
60 };
61 
62 #endif
Timer that syncs with NTP server.
Definition: timer.h:27
void begin(long int sync_interval_ms=600000)
initialise the timer, set a sync interval to sync with NTP server
Definition: timer.cpp:52
Timer()
Definition: timer.cpp:26
void print_utc_time()
Print the seconds since epoch.
Definition: timer.cpp:44
tm get_utc_time()
Get the utc time now.
Definition: timer.cpp:28
time_t get_epoch_time()
Get the seconds since epoch now.
Definition: timer.cpp:38