From 1263b3f72713fe1dc2c51bc87e53f495fecce845 Mon Sep 17 00:00:00 2001 From: Wonsang Ryou Date: Tue, 18 Jul 2017 18:50:26 +0900 Subject: [PATCH] examples/ntpclient_test: make ntp server port configurable in .config This patch enables ntp server's port number to be configurable in .config. You can set ntp server's port number using the following config variable. - CONFIG_EXAMPLES_NTPCLIENT_TEST_SERVER_PORT Change-Id: I39e8f46cbfc677449771016ac4048abcc9165e78 Signed-off-by: Wonsang Ryou --- apps/examples/ntpclient_test/Kconfig | 6 ++++++ apps/examples/ntpclient_test/ntpclient_main.c | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/examples/ntpclient_test/Kconfig b/apps/examples/ntpclient_test/Kconfig index 0ba92cc..fd1c7d1 100644 --- a/apps/examples/ntpclient_test/Kconfig +++ b/apps/examples/ntpclient_test/Kconfig @@ -20,6 +20,12 @@ config EXAMPLES_NTPCLIENT_TEST_PROGNAME This is the name of the program that will be use when the NSH ELF program is installed. +config EXAMPLES_NTPCLIENT_TEST_SERVER_PORT + int "NTP server port number" + default 123 + ---help--- + This is the port number of NTP server. + endif config USER_ENTRYPOINT diff --git a/apps/examples/ntpclient_test/ntpclient_main.c b/apps/examples/ntpclient_test/ntpclient_main.c index d38b747..2f5c0c9 100644 --- a/apps/examples/ntpclient_test/ntpclient_main.c +++ b/apps/examples/ntpclient_test/ntpclient_main.c @@ -71,7 +71,10 @@ ****************************************************************************/ #define TIME_STRING_LEN 16 #define DATE_STRING_LEN 16 -#define NTP_SERVER_PORT 123 + +#ifndef CONFIG_EXAMPLES_NTPCLIENT_TEST_SERVER_PORT +#define CONFIG_EXAMPLES_NTPCLIENT_TEST_SERVER_PORT 123 +#endif /**************************************************************************** * Enumeration @@ -272,7 +275,7 @@ int ntpclient_main(int argc, char *argv[]) memset(&g_server_conn, 0x0, sizeof(g_server_conn)); for (i = 0; i < num_of_servers; i++) { g_server_conn[i].hostname = argv[3 + i]; - g_server_conn[i].port = NTP_SERVER_PORT; + g_server_conn[i].port = CONFIG_EXAMPLES_NTPCLIENT_TEST_SERVER_PORT; } if (test_ntpclient_start(g_server_conn, interval_secs, num_of_servers) != 0) { goto errout; -- 2.7.4