Importing without issues

Dependencies:   AES CRC DHT JSON MQTT UDAES WIZnetInterface mbed-src

Fork of Mbed_Prototype_copy_4_INNO_day_15_6_2017 by Irayya Mathad

Revision:
2:f390709f23e1
Parent:
1:903414009683
--- a/main.cpp	Tue Jun 20 05:35:14 2017 +0000
+++ b/main.cpp	Wed Sep 27 09:05:24 2017 +0000
@@ -1,5 +1,4 @@
 #include "mbed.h"                                       // this is the original copy of 13-6-2017 and today only modifying. date 15-6-2017
-#include "DHT.h"
 #include "AES.h"
 #include "MQTTEthernet.h"
 #include "MQTTClient.h"
@@ -112,12 +111,10 @@
 
         if(device.readable()) {
             p=0;
-            bluetooth();
-            //device.gets(dataReceive,19);                                                     // colling bluetooth() function for data reading from slave device
+            bluetooth();                                                        // colling bluetooth() function for data reading from slave device
             out.printf("\nThe received message is : %s",dataReceive);           // printing the message after data reading from slave device
 
-           
-            if(dataReceive[0]=='F' ) {              // CRC failed message sending to the slave
+            if(dataReceive[0]=='F' ) {                                      // CRC failed message sending to the slave
                 for(int q2=0; q2<19; q2++) {
                     wait_ms(50);
                     out.putc(send_message[q2]);
@@ -138,16 +135,16 @@
                     out.printf("\n CRC ok");
                     for(int q=0; q<16; q++) {                                          // for data storing in another char array by removing dummi start bits
                         encData[q]=dataReceive[q];
-                        // out.printf("%c\n",dataReceive[q]);
+
                     }
                     out.printf("\nThe data to be decrypted is : %s",encData);
                     char* decryptedData = decryptData(encData);                         // calling decryptData() function for decrypt the data
 
                     out.printf("\nThe final decrypted Data is: %s",decryptedData);      // printing the decrypted data
-                    if(decryptedData[0]=='L' || decryptedData[0]=='0' || decryptedData[0]=='1' || decryptedData[0]=='2' || decryptedData[0]=='3' || decryptedData[0]=='4' || decryptedData[0]=='5' || decryptedData[0]=='6' || decryptedData[0]=='7' || decryptedData[0]=='8' || decryptedData[0]=='9' ) {
+                    if(decryptedData[0]=='L' ) {
                         message.qos = MQTT::QOS0;
                         message.retained = false;                                           //A retained message is a normal MQTT message with the retained flag set to true. The broker will store the last retained message and the corresponding QoS for that topic.
-                        // if it is false The broker will store the last retained message.
+                        // if it is false The broker will not store the last retained message.
                         message.dup = false;                                                // the broker will not create duplicate message
                         message.payload = (void*)decryptedData;                             // decrypting the message
 
@@ -155,40 +152,45 @@
 
                         // rc = client.publish("/1/ON", message);
                         rc = client.publish("/1/ON", message);
-                        //memset(send_message,'\0',sizeof(send_message));
+
+
+                    }
+
+                    else if(decryptedData[0]=='0' || decryptedData[0]=='1' || decryptedData[0]=='2' || decryptedData[0]=='3' || decryptedData[0]=='4' || decryptedData[0]=='5' || decryptedData[0]=='6' || decryptedData[0]=='7' || decryptedData[0]=='8' || decryptedData[0]=='9' ) {
+                        message.qos = MQTT::QOS0;
+                        message.retained = false;                                           //A retained message is a normal MQTT message with the retained flag set to true. The broker will store the last retained message and the corresponding QoS for that topic.
+                        // if it is false The broker will not store the last retained message.
+                        message.dup = false;                                                // the broker will not create duplicate message
+                        message.payload = (void*)decryptedData;                             // decrypting the message
+
+                        message.payloadlen = strlen(decryptedData);                         // finding the length of the message
+
+                        // rc = client.publish("/1/ON", message);
+                        rc = client.publish("/1/Temp", message);
+
 
                     } else {
                         out.printf("\n Data is not correct");
                         memset(dataReceive,'\0',sizeof(dataReceive));
                         wait(5);
                         for(int k3=0; k3<5; k3++) {
-                        wait_ms(50);                                            //Wait for 20 milisecond
-                        //Print the character
-                        device.putc(crc_failed[k3]);                               //Send the character via BLE
-                    }
+                            wait_ms(50);                                            //Wait for 50 milisecond
+                            device.putc(crc_failed[k3]);
+                            out.putc(crc_failed[k3]);                          //Send the character via BLE
+                        }
                     }
                 } else {
                     memset(dataReceive,'\0',sizeof(dataReceive));
                     memset(rec_message,'\0',sizeof(rec_message));
                     out.printf("\n CRC failed");
-                    //device.printf("FCRC");
+
                     wait(5);
-                    //device.printf(send_message);
+
                     for(int k1=0; k1<5; k1++) {
-                        wait_ms(50);                                            //Wait for 20 milisecond
-                        //Print the character
-                        device.putc(crc_failed[k1]);                               //Send the character via BLE
+                        wait_ms(50);                                            //Wait for 50 milisecond
+                        device.putc(crc_failed[k1]);
+                        out.putc(crc_failed[k1]);                           //Send the character via BLE
                     }
-                    //device.printf("FCRC12435678901111!");
-                    //device.printf("CRC failed.......");
-                    /* if(send_message != NULL)                                        //Condition for crc failed and sending ack or message
-                     {
-                     device.printf(send_message);
-                     }
-                     else
-                     {
-                     device.printf("FCRC");
-                     }*/
 
                 }
             }
@@ -209,7 +211,7 @@
                 z=0;
                 return;
             } else {
-                dataReceive[z]=c;                                  //
+                dataReceive[z]=c;                                               // storing the characters which are received from slave
                 printf("%c",c);
                 z++;
             }