Using Ethernet Interface to communicate and add a RFID reader
Dependencies: EthernetInterface ID12RFID mbed-rtos mbed
Revision 1:ccc5641be0cd, committed 2013-10-18
- Comitter:
- airaylee
- Date:
- Fri Oct 18 15:07:56 2013 +0000
- Parent:
- 0:053082d6a270
- Commit message:
- Second Version
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Oct 17 23:56:29 2013 +0000 +++ b/main.cpp Fri Oct 18 15:07:56 2013 +0000 @@ -5,6 +5,7 @@ ID12RFID rfid(p14); // uart rx EthernetInterface eth; +//Here is the IP address of Server and port const char* ECHO_SERVER_ADDRESS = "130.207.234.205"; const int ECHO_SERVER_PORT = 7; @@ -23,10 +24,12 @@ eth.connect(7000);//Longer timeout here printf("Client IP Address is %s\n", eth.getIPAddress()); TCPSocketConnection socket; + //Begin Connecting the server, if not, print the error info 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); } + //Begin receiving the data from server, and print out onto the terminal char buf[256]={0}; int n = socket.receive(buf, 256); buf[n] = '\0'; @@ -34,6 +37,7 @@ socket.close(); eth.disconnect(); } + //if not right tag, print out the error info and wait for another tag else printf("Wrong RFID Tag\r\n");