Dummy Lora Packet Sending

Fork of Dealer_18feb17 by kumar singh

Revision:
20:f812f85cf97e
Parent:
19:886d50ecc718
Child:
21:a5fb0ae94dc6
--- a/Lora.cpp	Tue Feb 21 06:27:13 2017 +0000
+++ b/Lora.cpp	Tue Feb 21 13:33:29 2017 +0000
@@ -85,7 +85,11 @@
         Get_Lora_Response();
     pc2.printf("Network Id response received");
     
-    LORA_Module_UART.printf("AT+TXDR=DR2\r");
+    LORA_Module_UART.printf("AT+TXDR\r");
+    AT_Response_Receive_Status = FAILURE;
+    while(AT_Response_Receive_Status)
+        Get_Lora_Response();
+    LORA_Module_UART.printf("AT+TXDR=DR3\r");
     AT_Response_Receive_Status = FAILURE;
     while(AT_Response_Receive_Status)
         Get_Lora_Response();
@@ -93,7 +97,7 @@
     AT_Response_Receive_Status = FAILURE;
     while(AT_Response_Receive_Status)
         Get_Lora_Response();
-    LORA_Module_UART.printf("AT+ADR=1\r"); //Enable adaptive data rate
+    LORA_Module_UART.printf("AT+ADR=0\r"); //Enable adaptive data rate
     AT_Response_Receive_Status = FAILURE;
     while(AT_Response_Receive_Status)
         Get_Lora_Response();
@@ -101,6 +105,11 @@
     AT_Response_Receive_Status = FAILURE;
     while(AT_Response_Receive_Status)
         Get_Lora_Response();
+        LORA_Module_UART.printf("AT+TXDR\r");
+    AT_Response_Receive_Status = FAILURE;
+    while(AT_Response_Receive_Status)
+        Get_Lora_Response();
+    
     pc2.printf("Configuration saved");
     LORA_Module_UART.printf("%s",Reset_Device);                    //reset device
     wait_ms(3500);
@@ -234,6 +243,14 @@
 {
     //write code to read obd data,temperature,beacon data
     uint8 Pos = 0,i;
+    Lora_Packet_To_Send[Pos++] = 0x41;//Heart_Beat_Lora_Packet.Header;                  //Header of Lora Packet,0xFE
+    Lora_Packet_To_Send[Pos++] = 0x54;//Misc_Packet_Data.Protocol_Version;
+    Lora_Packet_To_Send[Pos++] = 0x2b;//Heart_Beat_Lora_Packet.Packet_Type;      //MSB of Motion Packet Type
+    Lora_Packet_To_Send[Pos++] = 0x53;//(Misc_Packet_Data.OBD_Battery_Voltage >> 8);     //Get OBD_Battery Voltage
+    Lora_Packet_To_Send[Pos++] = 0x45;//(Misc_Packet_Data.OBD_Battery_Voltage & 0xFF);     //Get OBD_Battery Voltage
+    Lora_Packet_To_Send[Pos++] = 0x4e;//(Misc_Packet_Data.Car_Battery_Voltage >> 8); //Get Vehicle_Battery Temperature
+    Lora_Packet_To_Send[Pos++] = 0x44;//(Misc_Packet_Data.Car_Battery_Voltage & 0xFF); //Get Vehicle_Battery Temperature
+    Lora_Packet_To_Send[Pos++] = 0x20;//Vehicle_Status_Lora_Packet.Header;                  //Header of Lora Packet,0xFE
     Lora_Packet_To_Send[Pos++] = Heart_Beat_Lora_Packet.Header;                  //Header of Lora Packet,0xFE
     Lora_Packet_To_Send[Pos++] = Misc_Packet_Data.Protocol_Version;
     Lora_Packet_To_Send[Pos++] = Heart_Beat_Lora_Packet.Packet_Type;      //MSB of Motion Packet Type
@@ -251,8 +268,8 @@
     Lora_Packet_To_Send[Pos++] = Fixed_Beacon_Packet.Parking2_Beacon_Signal_Strength; //Get Signal Strength of 2nd nearby Beacon Device
     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
-    Lora_Packet_To_Send[Pos++] = Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    Lora_Packet_To_Send[Pos++] = 0x04;//Fixed_Beacon_Packet.Parking3_Beacon_Signal_Strength; //Get Signal Strength of 3rd nearby Beacon Device
+    Lora_Packet_To_Send[Pos++] = 0x05;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
     Packet_Type_To_Send = HEARTBEAT_TYPE_PACKET;
     Send_Lora_Packet_To_Gateway(Lora_Packet_To_Send,Pos); 
 }
@@ -262,6 +279,21 @@
 {
     //write code to read OBD data,temperature,beacon data
     uint8 Pos = 0,i;
+    Lora_Packet_To_Send[Pos++] = 0x41;//Heart_Beat_Lora_Packet.Header;                  //Header of Lora Packet,0xFE
+    Lora_Packet_To_Send[Pos++] = 0x54;//Misc_Packet_Data.Protocol_Version;
+    Lora_Packet_To_Send[Pos++] = 0x2b;//Heart_Beat_Lora_Packet.Packet_Type;      //MSB of Motion Packet Type
+    Lora_Packet_To_Send[Pos++] = 0x53;//(Misc_Packet_Data.OBD_Battery_Voltage >> 8);     //Get OBD_Battery Voltage
+    Lora_Packet_To_Send[Pos++] = 0x45;//(Misc_Packet_Data.OBD_Battery_Voltage & 0xFF);     //Get OBD_Battery Voltage
+    Lora_Packet_To_Send[Pos++] = 0x4e;//(Misc_Packet_Data.Car_Battery_Voltage >> 8); //Get Vehicle_Battery Temperature
+    Lora_Packet_To_Send[Pos++] = 0x44;//(Misc_Packet_Data.Car_Battery_Voltage & 0xFF); //Get Vehicle_Battery Temperature
+    Lora_Packet_To_Send[Pos++] = 0x20;//Vehicle_Status_Lora_Packet.Header;                  //Header of Lora Packet,0xFE
+    Lora_Packet_To_Send[Pos++] = Heart_Beat_Lora_Packet.Header;                  //Header of Lora Packet,0xFE
+    Lora_Packet_To_Send[Pos++] = Misc_Packet_Data.Protocol_Version;
+    Lora_Packet_To_Send[Pos++] = Vehicle_Status_Lora_Packet.Packet_Type;      //MSB of Motion Packet Type
+    Lora_Packet_To_Send[Pos++] = (Misc_Packet_Data.OBD_Battery_Voltage >> 8);     //Get OBD_Battery Voltage
+    Lora_Packet_To_Send[Pos++] = (Misc_Packet_Data.OBD_Battery_Voltage & 0xFF);     //Get OBD_Battery Voltage
+    Lora_Packet_To_Send[Pos++] = (Misc_Packet_Data.Car_Battery_Voltage >> 8); //Get Vehicle_Battery Temperature
+    Lora_Packet_To_Send[Pos++] = (Misc_Packet_Data.Car_Battery_Voltage & 0xFF); //Get Vehicle_Battery Temperature
     Lora_Packet_To_Send[Pos++] = Vehicle_Status_Lora_Packet.Header;                  //Header of Lora Packet,0xFE
     Lora_Packet_To_Send[Pos++] = Misc_Packet_Data.Protocol_Version;      //MSB of Motion Packet Type
     Lora_Packet_To_Send[Pos++] = Vehicle_Status_Lora_Packet.Packet_Type;      //MSB of Motion Packet Type
@@ -281,7 +313,7 @@
         Lora_Packet_To_Send[Pos++] = Vehicle_Status_Lora_Packet.BLE_Adv_Beacon_ID[i];       //Get Beacon_ID of 1st nearby Beacon Device
     for(i=0;i<6;i++)
         Lora_Packet_To_Send[Pos++] = Fixed_Beacon_Packet.Parking1_Beacon_ID[i];       //Get Beacon_ID of 1st nearby Beacon Device
-    Lora_Packet_To_Send[Pos++] = Fixed_Beacon_Packet.Parking1_Beacon_Signal_Strength; //Get Signal Strength of 1st nearby Beacon Device
+    /*Lora_Packet_To_Send[Pos++] = Fixed_Beacon_Packet.Parking1_Beacon_Signal_Strength; //Get Signal Strength of 1st nearby Beacon Device
     for(i=0;i<6;i++)
         Lora_Packet_To_Send[Pos++] = Fixed_Beacon_Packet.Parking2_Beacon_ID[i];       //Get Beacon_ID of 2nd nearby Beacon Device
     Lora_Packet_To_Send[Pos++] = Fixed_Beacon_Packet.Parking2_Beacon_Signal_Strength; //Get Signal Strength of 2nd nearby Beacon Device
@@ -296,8 +328,8 @@
     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++] = Near_Car_Beacon_Packet.Near_Car3_Beacon_Signal_Strength; //Get Signal Strength of 3rd nearby Beacon Device
-    Lora_Packet_To_Send[Pos++] = Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
+    */Lora_Packet_To_Send[Pos++] = 0x06;//Near_Car_Beacon_Packet.Near_Car3_Beacon_Signal_Strength; //Get Signal Strength of 3rd nearby Beacon Device
+    Lora_Packet_To_Send[Pos++] = 0x04;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos);   //Calculate FCS of all bytes
     Send_Lora_Packet_To_Gateway(Lora_Packet_To_Send,Pos); 
 }
 
@@ -461,9 +493,27 @@
 void Send_Lora_Packet_To_Gateway(uint8* Command_To_Send,uint8 Length)
 {
     uint8 i=0;
-    LORA_Module_UART.printf("%s",Send_Lora_Packet);//write to serial port for sending through lora module
-    LORA_Module_UART.printf("%s",Command_To_Send);
+    //pc2.printf("Sending data");
+   // LORA_Module_UART.printf("%s",Send_Lora_Packet);//write to serial port for sending through lora module
+     /*for(i=0; i < 7; i++)
+     {
+        LORA_Module_UART.putc(Send_Lora_Packet[i]);
+        
+     }*/
+     for(i=0; i < Length; i++)
+     {
+        LORA_Module_UART.putc(Command_To_Send[i]);
+        pc2.putc(Command_To_Send[i]);
+     }
+     for(i=0; i < Length; i++)
+     {
+        pc2.putc(Command_To_Send[i]);
+        
+     }
+     
+   // LORA_Module_UART.printf("%s",Command_To_Send);
     LORA_Module_UART.printf("\r");
+    pc2.printf("Total Bytes %d",Length);
 }