Commit 79c55c23 authored by Martin Vítek's avatar Martin Vítek

Fixes, disabled some debug

parent f606849f
......@@ -353,7 +353,7 @@ void Debug::rx_status(const ENC28J60_namespace::rx_status_vector& status, bool s
uart.send_dec(status.bit.rx_byte_count);
uart.send_new_line();
uart.send("\t\tTransmit done: ");
uart.send("\t\tReceive done: ");
uart.send(status.bit.received_ok ? "True" : "False");
uart.send_new_line();
......
......@@ -109,20 +109,33 @@ void NixieClock::display_handler()
}
void NixieClock::sntp_handler()
{
{
if (time(NULL) > (stack.sntp.last_update + SNTP_UPDATE_INTERVAL))
{
//Give SNTP 60seconds, then retry
stack.sntp.last_update += SNTP_UPDATE_INTERVAL + SNTP_RETRY_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
stack.sntp.last_update += SNTP_RETRY_INTERVAL;
stack.send_sntp_request(sntp_server_ip);
debug.message("SNTP request");
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 = 100, //Update interval in seconds (15min)
SNTP_RETRY_INTERVAL = 0,
SNTP_UPDATE_INTERVAL = 15, //Update interval in seconds (15min)
SNTP_RETRY_INTERVAL = 5,
};
public:
......
......@@ -92,7 +92,7 @@ void NixieStack::rx_handler()
//If was RX successful
if (eth.rx_frame(rx_buffer.write()))
{
debug.frame_type(rx_buffer.write());
//debug.frame_type(rx_buffer.write());
rx_buffer.write_advance();
}
......@@ -210,6 +210,8 @@ void NixieStack::send_sntp_request(const IP ntp_server_ip)
MAC dst_mac;
IP ip_to_search;
debug.info("Sending SNTP request");
//Is requested IP on local network?
if ((ntp_server_ip.ip.value & mask.ip.value) != (gateway.ip.value & mask.ip.value))
{
......
......@@ -9,7 +9,7 @@
SNTP_client::SNTP_client()
SNTP_client::SNTP_client(): last_update(0)
{
}
......@@ -17,17 +17,18 @@ void SNTP_client::decode(uint8_t* data)
{
NTP_packet* packet = (NTP_packet*) data;
debug.sntp(packet);
//debug.sntp(packet);
debug.info("Updated time from SNTP");
seconds = __ntohl(packet->transmit_timestamp.seconds) - 2208988800;
tm time_date;
last_update = seconds;
localtime_r(&last_update, &time_date);
debug.info(asctime(&time_date));
last_update = time(NULL);
//tm time_date;
//localtime_r(&last_update, &time_date);
//debug.info(asctime(&time_date));
//TODO: Set milliseconds to match timestamp fraction part
}
......
......@@ -5,8 +5,8 @@
Time tim;
volatile clock_t clk_count;
volatile time_t seconds = 1494172872;
volatile clock_t clk_count = 0;
volatile time_t seconds = 0;
clock_t clock()
{
......
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