From 1e60556b89305022b6cefe9bb28badb51dc15620 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 27 Oct 2007 18:56:04 +0000 Subject: Fixes found in smtp testing git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@356 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/examples/uip/main.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'nuttx/examples/uip') diff --git a/nuttx/examples/uip/main.c b/nuttx/examples/uip/main.c index 3024de873..9cddb0ab9 100644 --- a/nuttx/examples/uip/main.c +++ b/nuttx/examples/uip/main.c @@ -45,6 +45,7 @@ #include #include +#include #include #include @@ -70,11 +71,29 @@ # include #elif defined(CONFIG_EXAMPLE_UIP_WEBCLIENT) # include +#else +# error "No network application specified" #endif -/************************************************************ +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#if defined(CONFIG_EXAMPLE_UIP_SMTP) +static const char g_host_name[] = "localhost"; +static const char g_recipient[] = "spudmonkey@racsa.co.cr"; +static const char g_sender[] = "nuttx-testing@example.com"; +static const char g_subject[] = "Testing SMTP from NuttX"; +static const char g_msg_body[] = "Test message sent by NuttX\r\n"; +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** * user_initialize - ************************************************************/ + ****************************************************************************/ #ifndef CONFIG_HAVE_WEAKFUNCTIONS void user_initialize(void) @@ -85,11 +104,11 @@ void user_initialize(void) } #endif -/************************************************************ +/**************************************************************************** * user_start - ************************************************************/ + ****************************************************************************/ - int user_start(int argc, char *argv[]) +int user_start(int argc, char *argv[]) { struct in_addr addr; #if defined(CONFIG_EXAMPLE_UIP_DHCPC) || defined(CONFIG_ARCH_SIM) @@ -154,9 +173,9 @@ void user_initialize(void) handle = smtp_open(); if (handle) { - smtp_configure("localhost", addr.s_addr); - smtp_send("adam@sics.se", NULL, "uip-testing@example.com", - "Testing SMTP from uIP", "Test message sent by uIP\r\n"); + smtp_configure(handle, g_host_name, &addr.s_addr); + smtp_send(handle, g_recipient, NULL, g_sender, g_subject, + g_msg_body, strlen(g_msg_body)); smtp_close(handle); } #elif defined(CONFIG_EXAMPLE_UIP_WEBCLIENT) @@ -180,6 +199,7 @@ void uip_log(char *m) printf("uIP log message: %s\n", m); } +#if defined(CONFIG_EXAMPLE_UIP_WEBCLIENT) void webclient_closed(void) { printf("Webclient: connection closed\n"); @@ -204,3 +224,4 @@ void webclient_datahandler(char *data, uint16 len) { printf("Webclient: got %d bytes of data.\n", len); } +#endif -- cgit v1.2.3