Commit 90105373 authored by Martin Vítek's avatar Martin Vítek

Fixed last_update problem

parent 79c55c23
......@@ -110,32 +110,16 @@ void NixieClock::display_handler()
void NixieClock::sntp_handler()
{
if (time(NULL) > (stack.sntp.last_update + SNTP_UPDATE_INTERVAL))
//FIXME: There are 2 instances of SNTP_client, temporary fixed by static variable
if (time(NULL) == (stack.sntp.last_update + SNTP_UPDATE_INTERVAL))
{
uart.send("Time: ");
uart.send_dec(time(NULL));
uart.send_new_line();
uart.send("Update: ");
uart.send_dec(stack.sntp.last_update + SNTP_UPDATE_INTERVAL);
uart.send_new_line();
//Give SNTP some time, then retry if request failed
//Give SNTP some time, then retry if request failed (last_update wasn't updated yet)
stack.sntp.last_update += SNTP_RETRY_INTERVAL;
stack.send_sntp_request(sntp_server_ip);
debug.message("Send SNTP request");
sys.delay_ms(500);
sys.delay_ms(500);
sys.delay_ms(500);
sys.delay_ms(500);
sys.delay_ms(500);
sys.delay_ms(500);
sys.delay_ms(500);
sys.delay_ms(500);
sys.delay_ms(500);
}
}
......
......@@ -32,8 +32,8 @@ class NixieClock
enum
{
SNTP_UPDATE_INTERVAL = 15, //Update interval in seconds (15min)
SNTP_RETRY_INTERVAL = 5,
SNTP_UPDATE_INTERVAL = 900, //Update interval in seconds (15min)
SNTP_RETRY_INTERVAL = 15,
};
public:
......
......@@ -8,8 +8,9 @@
#include "Debug.h"
time_t SNTP_client::last_update = 0;
SNTP_client::SNTP_client(): last_update(0)
SNTP_client::SNTP_client()
{
}
......@@ -23,7 +24,7 @@ void SNTP_client::decode(uint8_t* data)
seconds = __ntohl(packet->transmit_timestamp.seconds) - 2208988800;
last_update = time(NULL);
last_update = seconds;
//tm time_date;
//localtime_r(&last_update, &time_date);
......
......@@ -62,7 +62,7 @@ struct NTP_packet
class SNTP_client
{
public:
time_t last_update;
static time_t last_update;
public:
SNTP_client();
......
......@@ -23,7 +23,7 @@ struct UDP_packet
class UDP_protocol
{
private:
public:
SNTP_client sntp;
public:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment