Compare commits
2 Commits
f8730808d1
...
WolfgangsO
Author | SHA1 | Date | |
---|---|---|---|
0957fc4830
|
|||
27f646860d |
@@ -71,7 +71,7 @@ uint16_t ntp_retry_cnt=0; //counting the ntp retry number
|
||||
48) UTC+13:00 Tonga
|
||||
49) UTC+14:00 Kiribati (Line Islands)
|
||||
*/
|
||||
void get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx)
|
||||
uint64_t get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx)
|
||||
{
|
||||
tstamp seconds = 0;
|
||||
uint8_t i=0;
|
||||
@@ -79,6 +79,8 @@ void get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx)
|
||||
{
|
||||
seconds = (seconds << 8) | buf[idx + i];
|
||||
}
|
||||
uint64_t rawSeconds = seconds;
|
||||
|
||||
switch (time_zone)
|
||||
{
|
||||
case 0:
|
||||
@@ -132,7 +134,7 @@ void get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx)
|
||||
case 20:
|
||||
seconds -= 1*3600;
|
||||
break;
|
||||
case 21: //<2F><EFBFBD>?
|
||||
case 21: //<2F>?
|
||||
case 22:
|
||||
break;
|
||||
case 23:
|
||||
@@ -213,6 +215,8 @@ void get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx)
|
||||
|
||||
//calculation for date
|
||||
calcdatetime(seconds);
|
||||
|
||||
return rawSeconds;
|
||||
}
|
||||
|
||||
void SNTP_init(uint8_t s, uint8_t *ntp_server, uint8_t tz, uint8_t *buf)
|
||||
@@ -262,7 +266,7 @@ int8_t SNTP_run(datetime *time)
|
||||
if (RSR_len > MAX_SNTP_BUF_SIZE) RSR_len = MAX_SNTP_BUF_SIZE; // if Rx data size is lager than TX_RX_MAX_BUF_SIZE
|
||||
recvfrom(NTP_SOCKET, data_buf, RSR_len, (uint8_t *)&destip, &destport);
|
||||
|
||||
get_seconds_from_ntp_server(data_buf,startindex);
|
||||
time->seconds = get_seconds_from_ntp_server(data_buf,startindex);
|
||||
time->yy = Nowdatetime.yy;
|
||||
time->mo = Nowdatetime.mo;
|
||||
time->dd = Nowdatetime.dd;
|
||||
|
@@ -56,6 +56,7 @@ typedef struct _datetime
|
||||
uint8_t hh;
|
||||
uint8_t mm;
|
||||
uint8_t ss;
|
||||
uint64_t seconds;
|
||||
} datetime;
|
||||
|
||||
#define ntp_port 123 //ntp server port number
|
||||
@@ -63,7 +64,7 @@ typedef struct _datetime
|
||||
#define UTC_ADJ_HRS 9 // SEOUL : GMT+9
|
||||
#define EPOCH 1900 // NTP start year
|
||||
|
||||
void get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx);
|
||||
uint64_t get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx);
|
||||
void SNTP_init(uint8_t s, uint8_t *ntp_server, uint8_t tz, uint8_t *buf);
|
||||
int8_t SNTP_run(datetime *time);
|
||||
tstamp changedatetime_to_seconds(void);
|
||||
|
4
Makefile
4
Makefile
@@ -2,7 +2,7 @@ WIZCHIP?=W5500
|
||||
ENABLE_DHCP?=yes
|
||||
ENABLE_DNS?=yes
|
||||
ENABLE_HTTPSERVER?=yes
|
||||
ENABLE_MQTT?=yes
|
||||
ENABLE_MQTT?=no
|
||||
ENABLE_SNTP?=yes
|
||||
|
||||
CFLAGS?=-mcpu=cortex-m3 -mthumb -Og -fdata-sections -ffunction-sections -g -gdwarf-2
|
||||
@@ -51,9 +51,9 @@ endif
|
||||
|
||||
|
||||
|
||||
|
||||
all: $(OBJS)
|
||||
$(AR) rcs w5500.a $^
|
||||
cp w5500.a ../build/
|
||||
|
||||
$(OBJDIR)/%.o: %.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
Reference in New Issue
Block a user