You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/08/18 15:08:01 UTC

[incubator-nuttx-apps] 02/03: examples/wget: wget example to work without NSH_NETINIT config

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 10386cf5b5d8dad97c5a5dc3ffd2e321c47aa299
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Tue Jul 28 15:23:33 2020 +0900

    examples/wget: wget example to work without NSH_NETINIT config
    
    - Network initialization codes are not needed
      with NSH_NETINIT config.
    - Suppport commandline argument to set the URL to get.
    - Change stack size to independent
---
 examples/wget/Kconfig     | 10 +++++++++-
 examples/wget/Makefile    |  2 +-
 examples/wget/wget_main.c | 12 +++++++++++-
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/examples/wget/Kconfig b/examples/wget/Kconfig
index 437ec94..97c53aa 100644
--- a/examples/wget/Kconfig
+++ b/examples/wget/Kconfig
@@ -12,14 +12,22 @@ config EXAMPLES_WGET
 
 if EXAMPLES_WGET
 
+config EXAMPLES_WGET_STACKSIZE
+	int "wget stack size"
+	default DEFAULT_TASK_STACKSIZE
+	---help---
+		Stack size of "wget" command. If you use SSL connection,
+		you should increase this value around 8096.
+
 config EXAMPLES_WGET_URL
 	string "File URL"
 	default ""
 	---help---
-	The URL of the file to get
+		The URL of the file to get
 
 config EXAMPLES_WGET_NOMAC
 	bool "Use Canned MAC Address"
+	depends on !NSH_NETINIT
 	default n
 
 config EXAMPLES_WGET_IPADDR
diff --git a/examples/wget/Makefile b/examples/wget/Makefile
index cc3e241..ecc3966 100644
--- a/examples/wget/Makefile
+++ b/examples/wget/Makefile
@@ -41,7 +41,7 @@ MAINSRC = wget_main.c
 
 PROGNAME = wget
 PRIORITY = SCHED_PRIORITY_DEFAULT
-STACKSIZE = $(CONFIG_DEFAULT_TASK_STACKSIZE)
+STACKSIZE = $(CONFIG_EXAMPLES_WGET_STACKSIZE)
 MODULE = $(CONFIG_EXAMPLES_WGET)
 
 include $(APPDIR)/Application.mk
diff --git a/examples/wget/wget_main.c b/examples/wget/wget_main.c
index 32ed435..1f3897b 100644
--- a/examples/wget/wget_main.c
+++ b/examples/wget/wget_main.c
@@ -108,6 +108,7 @@ static void callback(FAR char **buffer, int offset, int datend,
 
 int main(int argc, FAR char *argv[])
 {
+#ifndef CONFIG_NSH_NETINIT
   struct in_addr addr;
 #if defined(CONFIG_EXAMPLES_WGET_NOMAC)
   uint8_t mac[IFHWADDRLEN];
@@ -145,9 +146,18 @@ int main(int argc, FAR char *argv[])
    */
 
   netlib_ifup("eth0");
+#endif /* CONFIG_NSH_NETINIT */
 
   /* Then start the server */
 
-  wget(CONFIG_EXAMPLES_WGET_URL, g_iobuffer, 512, callback, NULL);
+  if (argc > 1)
+    {
+      wget(argv[1], g_iobuffer, 512, callback, NULL);
+    }
+  else
+    {
+      wget(CONFIG_EXAMPLES_WGET_URL, g_iobuffer, 512, callback, NULL);
+    }
+
   return 0;
 }