Seeed wifi shield hello world program

Dependencies:   WiflyInterface mbed

Fork of Wifly_HelloWorld by Samuel Mokrani

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "WiflyInterface.h"
00003 
00004 Serial pc(USBTX, USBRX);
00005 
00006 /* wifly object where:
00007 *     - p9 and p10 are for the serial communication
00008 *     - p25 is for the reset pin
00009 *     - p26 is for the connection status
00010 *     - "hotspot_name" is the ssid of the network
00011 *     - "password" is the password
00012 *     - WPA is the security method
00013 */
00014 WiflyInterface eth(p9, p10, p25, p26, "hotspot_name", "password", WPA);
00015 
00016 int main()
00017 {
00018     int s = eth.init(); //Use DHCP
00019 
00020     if( s != NULL ) {
00021         printf( "Could not initialise. Will halt!\n" );
00022         exit( 0 );
00023     }
00024 
00025     s = eth.connect(); // set up the chip and join the network
00026 
00027     if( s == false ) {
00028         printf( "Could not connect. Will halt!\n" );
00029         exit( 0 );
00030     } else {
00031         // print the IP address of the shield
00032         printf( "IP: %s\n", eth.getIPAddress() );
00033     }
00034 }