Using Ethernet Interface to communicate and add a RFID reader

Dependencies:   EthernetInterface ID12RFID mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
airaylee
Date:
Thu Oct 17 23:56:29 2013 +0000
Child:
1:ccc5641be0cd
Commit message:
Original Version;

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
ID12RFID.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface.lib	Thu Oct 17 23:56:29 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/EthernetInterface/#cba86db5ab96
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ID12RFID.lib	Thu Oct 17 23:56:29 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/ID12RFID/#f04afa911cf5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 17 23:56:29 2013 +0000
@@ -0,0 +1,43 @@
+
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "ID12RFID.h"
+
+ID12RFID rfid(p14); // uart rx
+EthernetInterface eth;
+const char* ECHO_SERVER_ADDRESS = "130.207.234.205";
+const int ECHO_SERVER_PORT = 7;
+
+int main() {
+    printf("Hello World\n");
+    eth.init(); //Use DHCP
+    //print out the MAC address first
+    printf("MAC Address is %s\n", eth.getMACAddress());
+    
+    while(1) {
+        if(rfid.readable()) {
+            int j=rfid.read();
+            //check if using right tag
+            if (j==36902518){
+                printf("Right RFID, Here is the Monitor Info\r\n");
+                eth.connect(7000);//Longer timeout here
+                printf("Client IP Address is %s\n", eth.getIPAddress());
+                TCPSocketConnection socket;
+                while (socket.connect(ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT) < 0) {
+                    printf("Unable to connect to (%s) on port (%d)\n", ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT);
+                    wait(1);
+                }
+                char buf[256]={0};
+                int n = socket.receive(buf, 256);
+                buf[n] = '\0';
+                printf("%s", buf);
+                socket.close();
+                eth.disconnect();        
+            }
+            else
+                printf("Wrong RFID Tag\r\n");
+           
+            printf("Wait for next RFID Tag\r\n");     
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Thu Oct 17 23:56:29 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#ee87e782d34f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Oct 17 23:56:29 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file