BLE Transmitter not working

Fork of Dealer_23Feb by kumar singh

Revision:
22:c2f034a13108
Parent:
21:a5fb0ae94dc6
Child:
23:688ee106c385
diff -r a5fb0ae94dc6 -r c2f034a13108 Lora.cpp
--- a/Lora.cpp	Wed Feb 22 14:59:59 2017 +0000
+++ b/Lora.cpp	Thu Feb 23 04:41:47 2017 +0000
@@ -313,7 +313,7 @@
     for(i=0;i<6;i++)
         Lora_Packet_To_Send[Pos++] = Fixed_Beacon_Packet.Parking3_Beacon_ID[i];       //Get Beacon_ID of 3rd nearby Beacon Device
     Lora_Packet_To_Send[Pos++] = Fixed_Beacon_Packet.Parking3_Beacon_Signal_Strength; //Get Signal Strength of 3rd nearby Beacon Device
-    for(i=0;i<6;i++)
+    /*for(i=0;i<6;i++)
         Lora_Packet_To_Send[Pos++] = Near_Car_Beacon_Packet.Near_Car1_Beacon_ID[i];       //Get Beacon_ID of 1st nearby Beacon Device
     Lora_Packet_To_Send[Pos++] = Near_Car_Beacon_Packet.Near_Car1_Beacon_Signal_Strength; //Get Signal Strength of 1st nearby Beacon Device
     for(i=0;i<6;i++)
@@ -321,9 +321,38 @@
     Lora_Packet_To_Send[Pos++] = Near_Car_Beacon_Packet.Near_Car2_Beacon_Signal_Strength; //Get Signal Strength of 2nd nearby Beacon Device
     for(i=0;i<6;i++)
         Lora_Packet_To_Send[Pos++] = Near_Car_Beacon_Packet.Near_Car3_Beacon_ID[i];       //Get Beacon_ID of 3rd nearby Beacon Device
-    Lora_Packet_To_Send[Pos++] = 0x23;//Near_Car_Beacon_Packet.Near_Car3_Beacon_Signal_Strength; //Get Signal Strength of 3rd nearby Beacon Device
+    */Lora_Packet_To_Send[Pos++] = 0x23;//Near_Car_Beacon_Packet.Near_Car3_Beacon_Signal_Strength; //Get Signal Strength of 3rd nearby Beacon Device
     Lora_Packet_To_Send[Pos++] = Vehicle_Status_Lora_Packet.Sequence_No;                  //Packet Sequence number
     Lora_Packet_To_Send[Pos++] = 0xEE;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEa;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEb;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEc;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEE;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xE3;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEb;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xE1;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xE5;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEa;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEb;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEf;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEE;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEa;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEb;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEc;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEE;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xE3;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEb;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xE1;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xE5;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEE;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEa;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEb;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xE9;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEE;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xE8;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xEb;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xE7;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0xE0;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
     Lora_Packet_To_Send[Pos++] = 0x0D;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
     /*Lora_Packet_To_Send[Pos++] = 0xA1;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
     Lora_Packet_To_Send[Pos++] = 0xA2;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
@@ -334,11 +363,12 @@
         Vehicle_Status_Lora_Packet.Sequence_No++;
     else
         Vehicle_Status_Lora_Packet.Sequence_No = 0x00;
-    /*for(i=0; i < Pos; i++)
+        pc2.printf("Status Packet sending");
+     for(i=0; i < Pos; i++)
      {
-        pc2.putc(Lora_Packet_To_Send[i]);
+         pc2.printf("0x%2x ",(Lora_Packet_To_Send[i]));
         //pc2.putc(Command_To_Send[i]);
-     }*/
+     }
      pc2.printf("Status Packet Sequence Number %d",Vehicle_Status_Lora_Packet.Sequence_No);
 }
 
@@ -371,6 +401,7 @@
     Lora_Packet_To_Send[Pos++] = Fixed_Beacon_Packet.Parking3_Beacon_Signal_Strength; //Get Signal Strength of 3rd nearby Beacon Device
     Lora_Packet_To_Send[Pos++] = CheckIN_Lora_Packet.Sequence_No;                  //Packet Sequence number
     Lora_Packet_To_Send[Pos++] = Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos] = 0x0D;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
     CheckIN_Packet_Sent_Count++;
     Send_Lora_Packet_To_Gateway(Lora_Packet_To_Send,Pos); 
     for(i=0; i < Pos; i++)
@@ -402,6 +433,7 @@
     Lora_Packet_To_Send[Pos++] = Misc_Packet_Data.Car_Ambient_Temperature;     //Get Ambient Temperature
     Lora_Packet_To_Send[Pos++] = CheckOUT_Packet.Sequence_No;                  //Packet Sequence number
     Lora_Packet_To_Send[Pos++] = Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos] = 0x0D;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
     CheckIN_Packet_Sent_Count++;
     Send_Lora_Packet_To_Gateway(Lora_Packet_To_Send,Pos); 
     for(i=0; i < Pos; i++)
@@ -451,6 +483,7 @@
     Lora_Packet_To_Send[Pos++] = Motion_Lora_Packet.Sequence_No;                  //Packet Sequence number
     Lora_Packet_To_Send[Pos++] = Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
     Motion_Packet_Sent_Count++;
+    Lora_Packet_To_Send[Pos] = 0x0D;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
     Send_Lora_Packet_To_Gateway(Lora_Packet_To_Send,Pos); 
     for(i=0; i < Pos; i++)
      {
@@ -490,14 +523,10 @@
         {
             LORA_UART_RX_Crnt_Pos = (Response_Start_Pos[0]);
             Response_Start_Pos[1]-=2;
-            //pc2.printf("\n Response packet\n");
             for(Temp_Pos1=0; LORA_UART_RX_Crnt_Pos < Response_Start_Pos[1]; Temp_Pos1++)
             {
                 Lora_Command_Rcvd[Temp_Pos1] = LORA_UART_RX_Buffer[LORA_UART_RX_Crnt_Pos++];
-                //pc2.printf("0x%2x ",(Lora_Command_Rcvd[Temp_Pos1]));
-                //pc2.putc(Lora_Command_Rcvd[Temp_Pos1]);
             }
-            //pc2.printf("\nTotal Reecived Bytes %d\n",LORA_UART_RX_Crnt_Pos);
             Lora_RxBuffer_End_Pos = 0;
             AT_Response_Receive_Status = SUCCESS;
         }
@@ -505,18 +534,10 @@
         {
             LORA_UART_RX_Crnt_Pos = (Response_Start_Pos[1]);
             Response_Start_Pos[2]-=2;
-            //pc2.printf("\n Response packet\n");
             for(Temp_Pos1=0; LORA_UART_RX_Crnt_Pos < Response_Start_Pos[2]; Temp_Pos1++)
             {
                 Lora_Command_Rcvd[Temp_Pos1] = LORA_UART_RX_Buffer[LORA_UART_RX_Crnt_Pos++];
-                
-                //pc2.putc(Lora_Command_Rcvd[Temp_Pos1]);
             }
-            /*for(Temp_Pos1=0; Temp_Pos1 < Length; Temp_Pos1++)
-             {
-            pc2.printf("0x%2x ",(Lora_Command_Rcvd[Temp_Pos1]));
-            }*/
-            //pc2.printf("\nTotal Reecived Bytes %d\n",LORA_UART_RX_Crnt_Pos);
             Lora_RxBuffer_End_Pos = 0;
             AT_Response_Receive_Status = SUCCESS;
         }
@@ -527,19 +548,20 @@
 void Send_Lora_Packet_To_Gateway(uint8* Command_To_Send,uint8 Length)
 {
      uint8 i=0;
+     pc2.printf("Sending command");
      for(i=0; i < Length; i++)
      {
         LORA_Module_UART.putc(Command_To_Send[i]);
-        //pc2.putc(Command_To_Send[i]);
+        pc2.printf("0x%2x ",(Command_To_Send[i]));
      }
      //LORA_Module_UART.printf("\r");
-     
+     /*
      pc2.printf("\n Sending packet\n");
      for(i=0; i < Length; i++)
      {
         pc2.printf("0x%2x ",(Command_To_Send[i]));
      }
-     
+     */
      // LORA_Module_UART.printf("%s",Command_To_Send);
      pc2.printf("\nTotal Bytes %d\n",Length);
 }