
Test network communications
Dependencies: EthernetInterface mbed-rtos mbed
Revision 0:9eba2bd74769, committed 2014-05-04
- Comitter:
- MalcolmNixon
- Date:
- Sun May 04 02:09:14 2014 +0000
- Child:
- 1:429f7bca62aa
- Commit message:
- Initial Revision
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EthernetInterface.lib Sun May 04 02:09:14 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/EthernetInterface/#f6ec7a025939
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun May 04 02:09:14 2014 +0000 @@ -0,0 +1,59 @@ +#include "EthernetInterface.h" +#include "Thread.h" +#include "mbed.h" + + + +// Construct the Ethernet interface +EthernetInterface eth; + +// Led thread procedure +void ledThreadProc(const void *) +{ + // Create a digital output pin on LED1 (the Red LED) + DigitalOut led1(LED1); + + // Loop forever + for (;;) + { + // Turn LED off + led1 = 1; + + // Wait for 100ms + Thread::wait(100); + + // Turn LED on + led1 = 0; + + // Wait for 100ms + Thread::wait(100); + } +} + +int main(void) +{ + // Configure the Ethernet interface + eth.init("192.168.5.100", "255.255.255.0", "0.0.0.0"); + + // Start the ethernet interface + eth.connect(); + + // Start a thread for led blink + Thread ledThread(ledThreadProc, 0, osPriorityHigh); + + UDPSocket sock; + sock.init(); + + Endpoint ep; + ep.set_address("192.168.5.1", 1234); + + // Loop forever + for (;;) + { + char msg[] = "Hello World"; + sock.sendTo(ep, msg, sizeof(msg) - 1); + + // Wait 1 second + Thread::wait(1000); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Sun May 04 02:09:14 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#5dfe422a963d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-src.lib Sun May 04 02:09:14 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-src/#d57c40a064c8