This documentation is for the Segundo Equipo version of the NetServices library.
This library is based on Donatien's source V1.04 (5 August 2010).
The following improvements and bug fixes are made:
#pragma diag_remark directives are added to the following files to turn compiler warnings into remarks (which are not normally displayed)
base64.h
EmailMessage.cpp / .h
Public Member Functions |
|
| EmailMessage () | |
|
Instantiates the email message.
|
|
| ~EmailMessage () | |
|
Destructor for the email message.
|
|
| void | setFrom (const char *from) |
|
Set FROM address.
|
|
| void | addTo (const char *to) |
|
Add TO address to list of recipient addresses.
|
|
| void | clearTo () |
|
Clear TO addresses.
|
|
| int | printf (const char *format,...) |
|
Append text to content of message using printf.
|
|
| void | clearContent () |
|
Clear content previously appended by printf.
|
|
Friends |
|
| class | SMTPClient |
eth_drv.cpp / .h
Ethernet* eth_interface();
EthernetNetIf.cpp / .h
IpAddr ethIp = eth.getIp();
printf("Connected ok, IP : %d.%d.%d.%d\n", ethIp[0], ethIp[1], ethIp[2], ethIp[3]);
const char* hwAddr = eth.getHwAddr();
printf("HW address : %02x:%02x:%02x:%02x:%02x:%02x\n",
hwAddr[0], hwAddr[1], hwAddr[2],
hwAddr[3], hwAddr[4], hwAddr[5]);
// set hostname ready for DHCP
EthernetNetIf eth("mbedSE");
Public Member Functions |
|
| EthernetNetIf (const char *hostname=NULL) | |
|
Instantiates the Interface and register it against the stack, DHCP will be used.
|
|
| EthernetNetIf ( IpAddr ip, IpAddr netmask, IpAddr gateway, IpAddr dns) | |
|
Instantiates the Interface and register it against the stack, DHCP will not be used.
|
|
| EthernetErr | setup (int timeout_ms=15000) |
|
Brings the interface up.
|
|
| const char * | getHwAddr () const |
|
Returns an array containing the hardware address.
|
|
| const char * | getHostname () const |
|
Returns a pointer to the hostname set in the constructor.
|
|
| IpAddr | getIp () const |
|
Returns the IP of the interface once it's connected.
|
|
#define HOSTNAME "mbedSE"
EthernetNetIf eth(HOSTNAME);
EthernetErr ethErr;
do {
printf("Setting up...\n");
ethErr = eth.setup();
if (ethErr) printf("Timeout\n", ethErr);
} while (ethErr != ETH_OK);
mem.c
memp.c
lwipopts.h
MEM_POSITION becomes effective (due to mem.c and memp.c changes) and is defined as AHBSRAM1 (not AHBSRAM0)
lwipopts2.h
netCfg.h
NTPClient.cpp
if ((int)time(NULL) < 1280000000) set_time( 1280000000 ); //End of July 2010... just there to limit offset range
RPCHandler.cpp
#include "url.h"
...
void RPCHandler::cleanReq(char* data)
{
char* decoded = url_decode(data);
strcpy(data, decoded);
free(decoded);
/*
char* p;
static const char* lGarbage[2] = {"%20", "+"};
for(int i = 0; i < 2; i++)
{
while( p = strstr(data, lGarbage[i]) )
{
memset((void*) p, ' ', strlen(lGarbage[i]));
}
}
*/
}
SMTPClient.cpp / .h
Public Member Functions |
|
| SMTPClient () | |
|
Instantiates the SMTP client.
|
|
| virtual | ~SMTPClient () |
|
Destructor for the SMTP client.
|
|
| SMTPClient (const Host &host, const char *heloDomain, const char *user, const char *password, SMTPAuth auth) | |
|
Full constructor for the SMTP client.
|
|
| void | setServer (const Host &host) |
|
Set server host.
|
|
| void | setAuth (const char *user, const char *password) |
|
Provides a plain authentication feature (Base64 encoded username and password)
|
|
| void | clearAuth () |
|
Turns off authentication.
|
|
| void | setHeloDomain (const char *heloDomain) |
|
Set HELO domain (defaults to localhost if not set)
|
|
| SMTPResult | send ( EmailMessage *pMessage) |
|
Sends the message (blocking)
|
|
| SMTPResult | send ( EmailMessage *pMessage, void(*pMethod)( SMTPResult )) |
|
Sends the message (non blocking)
|
|
| template<class T > | |
| SMTPResult | send ( EmailMessage *pMessage, T *pItem, void(T::*pMethod)( SMTPResult )) |
|
Sends the message (non blocking)
|
|
| void | doSend ( EmailMessage *pMessage) |
|
Sends the message (non blocking)
|
|
| void | setOnResult (void(*pMethod)( SMTPResult )) |
|
Setup the result callback.
|
|
| void | setTimeout (int ms) |
|
Setup timeout.
|
|
| string & | getLastResponse () |
|
Gets the last response from the server.
|
|
| virtual void | poll () |
|
This method can be inherited so that it is called on each
Net::poll()
call.
|
|
Protected Member Functions |
|
| void | close () |
|
This flags the service as to be destructed if owned by the pool.
|
|
timers.c
void sys_timeouts_init(void)
{
next_timeout = NULL;
...
Please login to post comments.
Using the NTPClient to set the current time seems to eat all available memory (less than 240 bytes left). I'm not really sure where this comes from, since I experience the malloc problem described here: http://mbed.org/forum/bugs-suggestions/topic/1593/ .
When trying to build a short program to reproduce this, I found out that it seems to be heavily influenced by the program layout (e.g. changing the text of my debug printf() message made the bug go away...).
What I'm observing is that after an ntp.setTime() call, the memory available for malloc drops below 240 bytes (which is the last malloc I see executing in the AvailableMemory() call). But it doesn't matter how much memory is available on the beginning - if I allocate 16000 bytes before the NTP call, the time is still set and I also get less than 240 bytes left (but I can free my 16000 bytes and be happy).
I also see similiar problems when using HTTPClient together with HTTPStream - I have plenty of memory available, but not afterwards (or, in my case, in the loop handling the received data).
This issue might be related to the malloc problem I linked to - maybe it's just the internal memory handling which gets messed up.
My test program is published as http://mbed.org/users/hlipka/programs/ntp_mem .