Seeed wifi shield hello world program
Dependencies: WiflyInterface mbed
Fork of Wifly_HelloWorld by
Revision 6:73c142780ad9, committed 2013-11-08
- Comitter:
- lz307
- Date:
- Fri Nov 08 21:44:01 2013 +0000
- Parent:
- 5:867d16e948eb
- Child:
- 7:6a7917d88dbe
- Commit message:
- hello world example for the seeed wifi shield
Changed in this revision
--- a/WiflyInterface.lib Fri Aug 24 13:52:40 2012 +0000 +++ b/WiflyInterface.lib Fri Nov 08 21:44:01 2013 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/WiflyInterface/#fb4494783863 +http://mbed.org/users/lz307/code/WiflyInterface/#3152fcc74390
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libxively.lib Fri Nov 08 21:44:01 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/xively/code/libxively/#4ce6299f7535
--- a/main.cpp Fri Aug 24 13:52:40 2012 +0000 +++ b/main.cpp Fri Nov 08 21:44:01 2013 +0000 @@ -7,15 +7,28 @@ * - p9 and p10 are for the serial communication * - p25 is for the reset pin * - p26 is for the connection status -* - "mbed" is the ssid of the network +* - "hotspot_name" is the ssid of the network * - "password" is the password -* - WPA is the security +* - WPA is the security method */ -WiflyInterface wifly(p9, p10, p25, p26, "mbed", "password", WPA); +WiflyInterface eth(p9, p10, p25, p26, "hotspot_name", "password", WPA); + +int main() +{ + int s = eth.init(); //Use DHCP -int main() { - wifly.init(); // use DHCP - while (!wifly.connect()); // join the network - printf("IP Address is %s\n\r", wifly.getIPAddress()); - wifly.disconnect(); -} \ No newline at end of file + if( s != NULL ) { + printf( "Could not initialise. Will halt!\n" ); + exit( 0 ); + } + + s = eth.connect(); // set up the chip and join the network + + if( s == false ) { + printf( "Could not connect. Will halt!\n" ); + exit( 0 ); + } else { + // print the IP address of the shield + printf( "IP: %s\n", eth.getIPAddress() ); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xi_user_config.h Fri Nov 08 21:44:01 2013 +0000 @@ -0,0 +1,23 @@ +#ifndef __XI_USER_CONFIG_H__ +#define __XI_USER_CONFIG_H__ + +// The following settings should lower memory footprint. +// The library currently allows one to send batch datapoint +// and feed updates, but it's not needed in most use cases +#define XI_MAX_DATAPOINTS 1 +// The number of channels can be increased if needed +#define XI_MAX_DATASTREAMS 5 + +// Below are optimisations that reduce some minor functionality +#define XI_OPT_NO_ERROR_STRINGS + +// If you wish to enable assertions, set this to 1 +#define XI_DEBUG_ASSERT 0 +// If you wish to disable debug output, set this to 0 +#define XI_DEBUG_OUTPUT 0 + +// On the mbed app board we can use the LCD for debug output, +// but one may wish to modify this and write to file instead +#define XI_DEBUG_PRINTF printf + +#endif /* __XI_USER_CONFIG_H__ */