Serial communication between the W7500 and WIZ750SR to send RFID data

Dependencies:   HCSR04 MFRC522 TextLCD mbed-src

Fork of RFID_copy by Rajib Kumer Dey

Files at this revision

API Documentation at this revision

Comitter:
HarshaDRAGNEEL
Date:
Tue Jul 17 06:19:38 2018 +0000
Parent:
0:1fdb07d055b9
Commit message:
Receive the RFID data and send serially data to the WIZ750SR

Changed in this revision

HCSR04.lib Show annotated file Show diff for this revision Revisions of this file
MQTT.lib Show diff for this revision Revisions of this file
TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
WIZnetInterface.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-src.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 1fdb07d055b9 -r 2c9b99e9122b HCSR04.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HCSR04.lib	Tue Jul 17 06:19:38 2018 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/antoniolinux/code/HCSR04/#86b2086be101
diff -r 1fdb07d055b9 -r 2c9b99e9122b MQTT.lib
--- a/MQTT.lib	Thu Jun 07 04:14:28 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/users/jamesabruce/code/MQTT/#d3feba7f242a
diff -r 1fdb07d055b9 -r 2c9b99e9122b TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Tue Jul 17 06:19:38 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/simon/code/TextLCD/#308d188a2d3a
diff -r 1fdb07d055b9 -r 2c9b99e9122b WIZnetInterface.lib
--- a/WIZnetInterface.lib	Thu Jun 07 04:14:28 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/#bda61525ac71
diff -r 1fdb07d055b9 -r 2c9b99e9122b main.cpp
--- a/main.cpp	Thu Jun 07 04:14:28 2018 +0000
+++ b/main.cpp	Tue Jul 17 06:19:38 2018 +0000
@@ -1,9 +1,6 @@
-//Test of cheap 13.56 Mhz RFID-RC522 module from eBay
-//This code is based on Martin Olejar's MFRC522 library. Minimal changes
-//Adapted for Nucleo STM32 F401RE. Should work on other Nucleos too
- 
+
 //Connect as follows:
-//RFID pins        ->  Nucleo header CN5 (Arduino-compatible header)
+
 //----------------------------------------
 //RFID IRQ=pin5    ->   Not used. Leave open
 //RFID MISO=pin4   ->   Nucleo SPI_MISO=PA_6=D12
@@ -11,60 +8,37 @@
 //RFID SCK=pin2    ->   Nucleo SPI_SCK =PA_5=D13
 //RFID SDA=pin1    ->   Nucleo SPI_CS  =PB_6=D10
 //RFID RST=pin7    ->   Nucleo         =PA_9=D8
-//3.3V and Gnd to the respective pins                              
-                              
+                          
+
 #include "mbed.h"
 #include "MFRC522.h"
 #include "SPI.h"
-#include "MQTTEthernet.h"
-#include "MQTTClient.h"
-
 #define ECHO_SERVER_PORT   7
  
-// Nucleo Pin for MFRC522 reset (pick another D pin if you need D8)
-//#define MF_RESET    D8
  
 #define SPI_MOSI D11
 #define SPI_MISO D12
 #define SPI_SCK D13
 #define SPI_CS D10
-#define MF_RESET D9
-DigitalOut l1(D4);
-DigitalOut l2(D5);
-DigitalOut LedGreen(LED1);
- 
+#define MF_RESET D8
+
+
 //Serial connection to PC for output
-//Serial pc(USBTX, USBRX);
- 
+Serial pc(USBTX, USBRX);
+// Serial connection with W750SR gateway for MQTT communication  
+Serial a(D1,D0);
+// Initializing RFID chip pins
 MFRC522    RfChip   (SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, MF_RESET);
- 
-int main(void) {
-    //pc.printf("starting...\n");
-    
-    Serial pc(USBTX, USBRX);
-    pc.baud(115200);
-    printf("Wait a second...\r\n");
-    char* topic = "openhab/parents/command";
-    MQTTEthernet ipstack = MQTTEthernet();
+  
+    char c;
+    int d;
     
-    MQTT::Client<MQTTEthernet, Countdown> client = MQTT::Client<MQTTEthernet, Countdown>(ipstack);
-    
-    char* hostname = "172.16.73.4";
-    int port = 1883;
-    
-    int rc = ipstack.connect(hostname, port);
-    if (rc != 0)
-        printf("rc from TCP connect is %d\n", rc);
-        
-    printf("Topic: %s\r\n",topic);
-    
-    MQTTPacket_connectData data = MQTTPacket_connectData_initializer;       
-    data.MQTTVersion = 3;
-    data.clientID.cstring = "parents";
-
-    if ((rc = client.connect(data)) == 0)
-        printf("rc from MQTT connect is %d\n", rc);
+int main(void) {
  
+    Serial pc(USBTX, USBRX);
+    Serial a(D1,D0);
+    pc.printf("Wait a second...\r\n");
+   
   //Init. RC522 Chip
   RfChip.PCD_Init();
  
@@ -77,17 +51,15 @@
       wait_ms(500);
       continue;
     }
- 
-    // Select one of the cards
+   // Select one of the cards
     if ( ! RfChip.PICC_ReadCardSerial())
     {
       wait_ms(500);
       continue;
     }
- 
-    //LedGreen = 0;
-    char data[20]="";
-    char data1[20]="";
+   
+   char data[20]="";
+  // char data1[20]="";
     
     // Print Card UID
     pc.printf("Card UID: ");
@@ -100,39 +72,11 @@
       strcat(data,temp);
     }
     
-    /*    
-    pc.printf("\n\r");
-    printf("%s\n\r",data);
-    */
- 
     // Print Card type
     uint8_t piccType = RfChip.PICC_GetType(RfChip.uid.sak);
     pc.printf(" \nPICC Type: %s \n\r", RfChip.PICC_GetTypeName(piccType));
     wait_ms(1000);
-    
-    if(strcmp(data,"5C02820285024502")==0)
-    {   
-        strcat(data1,"fruits");
-    }
-    if(strcmp(data,"B3026802A002202")==0)
-    {
-        strcat(data1,"vegatables");
-    }
-    if(strcmp(data,"F2029C02AC021F02")==0)
-    {
-        strcat(data1,"milk");
-    
-    MQTT::Message message;
-    char buf[100];
-    sprintf(buf, "%s", data1);
-    message.qos = MQTT::QOS0;
-    message.retained = false;
-    message.dup = false;
-    message.payload = (void*)data1;
-    message.payloadlen = strlen(data1);
-    rc = client.publish("grocery", message); 
-    client.yield(60000);
-    memset(data1, '\0',sizeof(data1)); 
+    a.printf("%s",data);
+  
   }
 }
-}
\ No newline at end of file
diff -r 1fdb07d055b9 -r 2c9b99e9122b mbed-src.lib
--- a/mbed-src.lib	Thu Jun 07 04:14:28 2018 +0000
+++ b/mbed-src.lib	Tue Jul 17 06:19:38 2018 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-src/#2d5fc5624619
+http://mbed.org/users/mbed_official/code/mbed-src/#a11c0372f0ba