diff --git a/components/time/time_sntp.c b/components/time/time_sntp.c index c37c8dc..793aa7e 100644 --- a/components/time/time_sntp.c +++ b/components/time/time_sntp.c @@ -60,6 +60,10 @@ static int command_func(int argc, char **argv) } else if (strcmp(argv[1], "stop") == 0) { sntp_stop(); return 0; + } else if (strcmp(argv[1], "ip") == 0) { + const ip_addr_t *ip = esp_sntp_getserver(0); + printf("%s\n", ipaddr_ntoa(ip)); + return 0; } else { printf("Unrecognised subcommand\n"); return 1; @@ -76,14 +80,15 @@ void time_sntp_init(void) (void)settings_get_sntp_server(sntp_server, SETTINGS_MAX_VALUE_SIZE); settings_add_sntp_server_callback(&handle_sntp_server_update); - esp_sntp_set_sync_mode(SNTP_SYNC_MODE_SMOOTH); esp_sntp_setoperatingmode(ESP_SNTP_OPMODE_POLL); esp_sntp_setservername(0, sntp_server); - sntp_set_time_sync_notification_cb(sntp_sync_callback); esp_sntp_init(); + sntp_set_time_sync_notification_cb(sntp_sync_callback); + console_register( - "sntp", "Manage SNTP", "sntp ", command_func); + "sntp", "Manage SNTP", "sntp ", + command_func); } void time_sntp_restart(void)