diff --git a/Inc/HALAL/Services/Communication/SNTP/SNTP.hpp b/Inc/HALAL/Services/Communication/SNTP/SNTP.hpp index 0aab33f9e..36cf4cd3d 100644 --- a/Inc/HALAL/Services/Communication/SNTP/SNTP.hpp +++ b/Inc/HALAL/Services/Communication/SNTP/SNTP.hpp @@ -13,5 +13,6 @@ class SNTP{ public: static void sntp_update(uint8_t address_head, uint8_t address_second, uint8_t address_third, uint8_t address_last); static void sntp_update(string ip); + static void sntp_update(); }; diff --git a/Middlewares/Third_Party/LwIP/src/include/lwip/apps/sntp_opts.h b/Middlewares/Third_Party/LwIP/src/include/lwip/apps/sntp_opts.h index 5ec1cf560..e3fe75e19 100644 --- a/Middlewares/Third_Party/LwIP/src/include/lwip/apps/sntp_opts.h +++ b/Middlewares/Third_Party/LwIP/src/include/lwip/apps/sntp_opts.h @@ -56,7 +56,7 @@ EXTERNC u32_t get_rtc_us(); #define SUBSECONDS_PER_SECOND 32767 #define TRANSFORMATION_FACTOR (SUBSECONDS_PER_SECOND/999999.0) #define SNTP_COMP_ROUNDTRIP 1 -#define SNTP_UPDATE_DELAY 3600000 +#define SNTP_UPDATE_DELAY 60000 void set_time(uint32_t sec, uint32_t us){ struct timeval tv; diff --git a/Src/HALAL/HALAL.cpp b/Src/HALAL/HALAL.cpp index 163f49e2c..658b559ee 100644 --- a/Src/HALAL/HALAL.cpp +++ b/Src/HALAL/HALAL.cpp @@ -63,6 +63,7 @@ void HALAL::start(string ip, string subnet_mask, string gateway, UART::Periphera #ifdef HAL_TIM_MODULE_ENABLED Encoder::start(); + SNTP::sntp_update(); Time::start_rtc(); TimerPeripheral::start(); Time::start(); diff --git a/Src/HALAL/Services/Communication/SNTP/SNTP.cpp b/Src/HALAL/Services/Communication/SNTP/SNTP.cpp index 78fc0fded..4426e07ec 100644 --- a/Src/HALAL/Services/Communication/SNTP/SNTP.cpp +++ b/Src/HALAL/Services/Communication/SNTP/SNTP.cpp @@ -14,6 +14,7 @@ #define SUBSECONDS_PER_SECOND 32767 #define TRANSFORMATION_FACTOR (SUBSECONDS_PER_SECOND/999999.0) +#define TARGET_IP "192.168.1.3" void SNTP::sntp_update(uint8_t address_head, uint8_t address_second, uint8_t address_third, uint8_t address_last){ sntp_setoperatingmode(SNTP_OPMODE_POLL); @@ -23,6 +24,20 @@ void SNTP::sntp_update(uint8_t address_head, uint8_t address_second, uint8_t add sntp_init(); } +void SNTP::sntp_update(string ip) { + sntp_setoperatingmode(SNTP_OPMODE_POLL); + IPV4 target(ip); + sntp_setserver(0,&target.address); + sntp_init(); +} + +void SNTP::sntp_update(){ + sntp_setoperatingmode(SNTP_OPMODE_POLL); + IPV4 target(TARGET_IP); + sntp_setserver(0,&target.address); + sntp_init(); +} + void set_rtc(uint16_t counter, uint8_t second, uint8_t minute, uint8_t hour, uint8_t day, uint8_t month, uint16_t year){ Time::set_rtc_data(counter, second, minute, hour, day, month, year); }