Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface mbed-rtos mbed
Revision 0:31ba7a9a7743, committed 2018-05-05
- Comitter:
- Rbinas
- Date:
- Sat May 05 21:03:36 2018 +0000
- Commit message:
- Set-Up Ethernet port
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EthernetInterface.lib Sat May 05 21:03:36 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/EthernetInterface/#183490eb1b4a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sat May 05 21:03:36 2018 +0000
@@ -0,0 +1,59 @@
+
+//-----------Program used to Set-up Ethernet Static IPconfig--------------
+//----------Use HW Group Utility to monitor actvity-----------------------
+#include "mbed.h"
+#include "EthernetInterface.h"
+DigitalOut myled(LED1);
+DigitalOut myled2(LED2);
+Serial pc(USBTX, USBRX);
+//-------------Set Ethernet----------------------------
+static const char* mbedIp = "192.168.168.105"; //IP
+static const char* mbedMask = "255.255.255.0"; // Mask
+static const char* mbedGateway = "192.168.1.1"; //Gateway
+const int ECHO_SERVER_PORT = 5000;
+char buffer[256];
+EthernetInterface eth;
+TCPSocketServer server;
+TCPSocketConnection client;
+//---------------------------------------------------------------------
+int main()
+{
+
+
+eth.init(mbedIp,mbedMask,mbedGateway); //Use these parameters for static IP
+eth.connect();
+server.bind(ECHO_SERVER_PORT);
+server.listen();
+
+ while (true)
+ {
+
+ server.accept(client);
+ //-------------Test sending from MCU to PC--------------------------
+ client.send("Hello",5);
+ client.send("\n",1);
+ client.send("World",5);
+ client.send("\n",1);
+
+ while (true)
+ {
+
+ char n = client.receive(buffer, sizeof(buffer));
+ //-------------Test sending from PC to MCU-------------------
+ buffer[n] = '\0';
+ if (buffer[0] =='A') //send char A to turn on Led 1
+ {myled = 1;}
+ if (buffer[0] =='B') //send char B to turnoff on Led 1
+ {myled = 0;}
+
+ if (buffer[0] =='C')//send char C to turn on Led 2
+ {myled2 = 1;}
+ if (buffer[0] =='D')//send char D to turn off Led 2
+ {myled2 = 0;}
+
+ client.send("Test \n",4);
+
+ }
+
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Sat May 05 21:03:36 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#58563e6cba1e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat May 05 21:03:36 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/ef9c61f8c49f \ No newline at end of file