port ethernet libray for stm32f407 (seeed arch max). it works.

Dependencies:   EthernetInterface-arch-max-dev mbed-rtos mbed-src

Fork of TCPSocket_HelloWorld by mbed official

main.cpp

Committer:
yihui
Date:
2015-03-02
Revision:
17:bbdfe971ff07
Parent:
16:ded63414139d

File content as of revision 17:bbdfe971ff07:

#include "mbed.h"
#include "EthernetInterface.h"

int main() {
    EthernetInterface eth;
//    eth.init("192.168.1.3", "255.255.255.0", "192.168.1.1"); 
    eth.init(); // use DHCP
    eth.connect();
    printf("IP Address is %s\n", eth.getIPAddress());


    TCPSocketConnection sock;
    sock.connect("mbed.org", 80);
    
    char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
    sock.send_all(http_cmd, sizeof(http_cmd)-1);
    
    char buffer[300];
    int ret;
    while (true) {
        ret = sock.receive(buffer, sizeof(buffer)-1);
        if (ret <= 0)
            break;
        buffer[ret] = '\0';
        printf("Received %d chars from server:\n%s\n", ret, buffer);
    }
      
    sock.close();
    
    eth.disconnect();
    
    while(1) {} 
}