UDP test example code.
Dependencies: EthernetInterface mbed-rtos mbed
Revision 0:b9107cf31131, committed 2014-10-13
- Comitter:
- ban4jp
- Date:
- Mon Oct 13 06:26:10 2014 +0000
- Commit message:
- UDP test example code.
Changed in this revision
diff -r 000000000000 -r b9107cf31131 EthernetInterface.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EthernetInterface.lib Mon Oct 13 06:26:10 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/EthernetInterface/#5887ae6c0c2c
diff -r 000000000000 -r b9107cf31131 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Oct 13 06:26:10 2014 +0000 @@ -0,0 +1,35 @@ +#include "mbed.h" +#include "EthernetInterface.h" +#include "UDPSocket.h" + +EthernetInterface eth; +UDPSocket udpClient; +Endpoint epServer; + +Serial pc(USBTX, USBRX); +DigitalOut myled1(LED1); +DigitalOut myled2(LED2); + +const char SENDDATA[] = "testtesttesttesttesttesttesttest"; + +int main() +{ + pc.printf("eth.init() dhcp return = %d\n", eth.init()); + //pc.printf("eth.init() static return = %d\n", eth.init("192.168.0.38", "255.255.255.0", "192.168.0.38")); + + eth.connect(); + udpClient.init(); + + epServer.set_address("239.168.1.1", 38383); + pc.printf("IP Address = %s\n", eth.getIPAddress()); + + while(1) { + for(int i=16; i<=sizeof(SENDDATA); i++) { + myled1 = !myled1; + udpClient.sendTo(epServer, (char * )&SENDDATA, i); + wait(0.25); + } + myled2 = !myled2; + wait(2); + } +}
diff -r 000000000000 -r b9107cf31131 mbed-rtos.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Mon Oct 13 06:26:10 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#631c0f1008c3
diff -r 000000000000 -r b9107cf31131 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Oct 13 06:26:10 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1 \ No newline at end of file