eth test

Dependencies:   HTTPClient mbed-rtos

Fork of HTTPClient_HelloWorld by Donatien Garnier

Committer:
brdarji
Date:
Wed Jan 06 08:54:22 2016 +0000
Revision:
3:cde1ce546553
Parent:
2:270e2d0bb85a
eth_test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 0:0e0debc29569 1 #include "mbed.h"
donatien 0:0e0debc29569 2 #include "EthernetInterface.h"
donatien 0:0e0debc29569 3 #include "HTTPClient.h"
donatien 0:0e0debc29569 4
donatien 1:d263603373ac 5 EthernetInterface eth;
donatien 1:d263603373ac 6 HTTPClient http;
brdarji 3:cde1ce546553 7 Serial pc(P0_2, P0_3);
donatien 1:d263603373ac 8 char str[512];
donatien 1:d263603373ac 9
brdarji 3:cde1ce546553 10 // For Static IP
brdarji 3:cde1ce546553 11 static const char* mbedIp = "192.168.0.160"; //IP
brdarji 3:cde1ce546553 12 static const char* mbedMask = "255.255.255.0"; // Mask
brdarji 3:cde1ce546553 13 static const char* mbedGateway = "192.168.0.254"; //Gateway
brdarji 3:cde1ce546553 14
donatien 0:0e0debc29569 15 int main()
donatien 0:0e0debc29569 16 {
brdarji 3:cde1ce546553 17 // eth.init(); //Use DHCP
donatien 1:d263603373ac 18
brdarji 3:cde1ce546553 19 int s = eth.init(mbedIp,mbedMask,mbedGateway); //Use these parameters for static IP
donatien 0:0e0debc29569 20
brdarji 3:cde1ce546553 21 if( s != NULL )
donatien 2:270e2d0bb85a 22 {
brdarji 3:cde1ce546553 23 pc.printf( "Could not initialise. Will halt!\n\r" );
brdarji 3:cde1ce546553 24 exit( 0 );
brdarji 3:cde1ce546553 25 }
brdarji 3:cde1ce546553 26
brdarji 3:cde1ce546553 27 s = eth.connect();
donatien 2:270e2d0bb85a 28
brdarji 3:cde1ce546553 29 if( s != NULL )
donatien 2:270e2d0bb85a 30 {
brdarji 3:cde1ce546553 31 pc.printf( "Could not connect. Will halt!\n\r" );
brdarji 3:cde1ce546553 32 exit( 0 );
donatien 2:270e2d0bb85a 33 }
brdarji 3:cde1ce546553 34 else
donatien 2:270e2d0bb85a 35 {
brdarji 3:cde1ce546553 36 pc.printf( "IP: %s\n\r", eth.getIPAddress() );
donatien 2:270e2d0bb85a 37 }
brdarji 3:cde1ce546553 38 }