Code to run tests on the Ethernet library

Dependencies:   EthernetInterface mbed-rtos mbed

main.cpp

Committer:
lawless
Date:
2013-10-27
Revision:
0:3f5638515f99
Child:
1:effed2d57b6c

File content as of revision 0:3f5638515f99:

#include "mbed.h"
#include "EthernetInterface.h"
 
int main() {
    EthernetInterface eth;
    eth.init("192.168.9.8", "255.255.255.0", "192.168.9.1");
    eth.connect();
    printf("IP Address is %s\n", eth.getIPAddress());
    
    UDPSocket sock;
    sock.init();
    
    Endpoint seven;
    seven.set_address("192.168.9.7", 37);
    
    char out_buffer[] = "plop"; // Does not matter
    
    while(1) {
        sock.sendTo(seven, out_buffer, sizeof(out_buffer));
        wait(1);
    }
    
    sock.close();
    
    eth.disconnect();
}