Test network communications

Dependencies:   EthernetInterface mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
MalcolmNixon
Date:
Sun May 04 14:11:44 2014 +0000
Parent:
4:f2789e665f4e
Commit message:
Initial Revision

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r f2789e665f4e -r 18415c556f04 main.cpp
--- a/main.cpp	Sun May 04 04:31:58 2014 +0000
+++ b/main.cpp	Sun May 04 14:11:44 2014 +0000
@@ -2,14 +2,10 @@
 #include "Thread.h"
 #include "mbed.h"
 
-// Configure the LEDs (off)
-DigitalOut led1(LED1, 1);
-DigitalOut led2(LED2, 1);
-    
-
-void ledThreadProc(const void *param)
+void led2ThreadProc(const void *param)
 {
-    // Toggle the Green LED
+    // Toggle LED2
+    DigitalOut led2(LED2, 1);
     for (;;)
     {
         led2 = !led2;
@@ -17,21 +13,33 @@
     }
 }
 
+void led3ThreadProc(const void *param)
+{
+    // Toggle LED3
+    DigitalOut led3(LED3, 1);
+    for (;;)
+    {
+        led3 = !led3;
+        Thread::wait(2000);
+    }
+}
+
 int main(void)
 {
-    Thread ledThread(ledThreadProc);
+    // Start LED toggle(s)
+    Thread led2(led2ThreadProc);
+    Thread led3(led3ThreadProc);
 
     // Start the network
-    EthernetInterface eth;
-    eth.init("192.168.5.100", "255.255.255.0", "0.0.0.0");
-    eth.connect();
+    EthernetInterface::init("192.168.5.100", "255.255.255.0", "0.0.0.0");
+    EthernetInterface::connect();
 
     // Construct the server
-    TCPSocketConnection conn;
     TCPSocketServer svr;
     svr.bind(1234);
     svr.listen();
 
+    TCPSocketConnection conn;
     for (;;)
     {
         // Accept the next connection
@@ -48,9 +56,6 @@
                 break;
             }
             
-            // Toggle the output on led1
-            led1 = !led1;
-            
             // Write the response twice
             conn.send(buf, nr);
             conn.send(buf, nr);