-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ntp server ip to settings menu and ntp via dhcp support. Prepare …
…manual ntp server ip entry. Add support for setting ntp ip addr manually via prusa_printer_settings.ini.
- Loading branch information
Showing
14 changed files
with
104 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,47 @@ | ||
#include "sntp.h" | ||
#include "sntp_client.h" | ||
#include "netdev.h" | ||
#include "netif.h" | ||
|
||
static ip_addr_t ntp_server; // testing ntp server located in Prague | ||
static uint32_t sntp_running = 0; // describes if sntp is currently running or not | ||
void sntp_client_init(void) { | ||
void sntp_client_static_init(ip4_addr_t *ntp_ipv4_address) { | ||
sntp_setoperatingmode(SNTP_OPMODE_POLL); | ||
sntp_servermode_dhcp(0); | ||
#if LWIP_IPV4 | ||
sntp_setserver(0, ntp_ipv4_address); | ||
#endif /* LWIP_IPV4 */ | ||
sntp_init(); | ||
} | ||
|
||
/* TODO: enable DNS for ntp.pool.org as default sntp server*/ | ||
|
||
// TMP: ip of Czech CESNET NTP server tak.cesnet.cz | ||
if (ipaddr_aton("195.113.144.238", &ntp_server)) { | ||
sntp_setserver(0, &ntp_server); | ||
} | ||
void sntp_client_dhcp_init(ip4_addr_t *ntp_ipv4_address) { | ||
sntp_setoperatingmode(SNTP_OPMODE_POLL); | ||
sntp_servermode_dhcp(1); | ||
#if LWIP_IPV4 | ||
sntp_setserver(0, ntp_ipv4_address); | ||
#endif /* LWIP_IPV4 */ | ||
sntp_init(); | ||
} | ||
|
||
void sntp_client_step(void) { | ||
void sntp_client_step(bool ntp_via_dhcp, ip4_addr_t *ntp_ipv4_address) { | ||
netdev_status_t eth = netdev_get_status(NETDEV_ETH_ID); | ||
netdev_status_t wifi = netdev_get_status(NETDEV_ESP_ID); | ||
|
||
if (!sntp_running && (eth == NETDEV_NETIF_UP || wifi == NETDEV_NETIF_UP)) { | ||
sntp_client_init(); | ||
if (ntp_via_dhcp) { | ||
sntp_client_dhcp_init(ntp_ipv4_address); | ||
} else { | ||
sntp_client_static_init(ntp_ipv4_address); | ||
} | ||
sntp_running = 1; | ||
} else if (sntp_running && eth != NETDEV_NETIF_UP && wifi != NETDEV_NETIF_UP) { | ||
sntp_stop(); | ||
sntp_running = 0; | ||
} | ||
} | ||
|
||
void sntp_client_stop() { | ||
if (sntp_running) { | ||
sntp_stop(); | ||
sntp_running = 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters