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
This commit is contained in:
parent
7a1d626504
commit
10386cf5b5
@ -12,14 +12,22 @@ config EXAMPLES_WGET
|
|||||||
|
|
||||||
if 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
|
config EXAMPLES_WGET_URL
|
||||||
string "File URL"
|
string "File URL"
|
||||||
default ""
|
default ""
|
||||||
---help---
|
---help---
|
||||||
The URL of the file to get
|
The URL of the file to get
|
||||||
|
|
||||||
config EXAMPLES_WGET_NOMAC
|
config EXAMPLES_WGET_NOMAC
|
||||||
bool "Use Canned MAC Address"
|
bool "Use Canned MAC Address"
|
||||||
|
depends on !NSH_NETINIT
|
||||||
default n
|
default n
|
||||||
|
|
||||||
config EXAMPLES_WGET_IPADDR
|
config EXAMPLES_WGET_IPADDR
|
||||||
|
@ -41,7 +41,7 @@ MAINSRC = wget_main.c
|
|||||||
|
|
||||||
PROGNAME = wget
|
PROGNAME = wget
|
||||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||||
STACKSIZE = $(CONFIG_DEFAULT_TASK_STACKSIZE)
|
STACKSIZE = $(CONFIG_EXAMPLES_WGET_STACKSIZE)
|
||||||
MODULE = $(CONFIG_EXAMPLES_WGET)
|
MODULE = $(CONFIG_EXAMPLES_WGET)
|
||||||
|
|
||||||
include $(APPDIR)/Application.mk
|
include $(APPDIR)/Application.mk
|
||||||
|
@ -108,6 +108,7 @@ static void callback(FAR char **buffer, int offset, int datend,
|
|||||||
|
|
||||||
int main(int argc, FAR char *argv[])
|
int main(int argc, FAR char *argv[])
|
||||||
{
|
{
|
||||||
|
#ifndef CONFIG_NSH_NETINIT
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
#if defined(CONFIG_EXAMPLES_WGET_NOMAC)
|
#if defined(CONFIG_EXAMPLES_WGET_NOMAC)
|
||||||
uint8_t mac[IFHWADDRLEN];
|
uint8_t mac[IFHWADDRLEN];
|
||||||
@ -145,9 +146,18 @@ int main(int argc, FAR char *argv[])
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
netlib_ifup("eth0");
|
netlib_ifup("eth0");
|
||||||
|
#endif /* CONFIG_NSH_NETINIT */
|
||||||
|
|
||||||
/* Then start the server */
|
/* 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user