Dummy Lora Packet Sending

Fork of Dealer_18feb17 by kumar singh

Revision:
18:86f069689502
Parent:
17:758fb8454ab0
Child:
19:886d50ecc718
--- a/Lora.cpp	Sat Feb 18 08:36:54 2017 +0000
+++ b/Lora.cpp	Sat Feb 18 08:52:04 2017 +0000
@@ -26,6 +26,7 @@
  //Create Object for Type of Lora Packet to send
  Heart_Beat_PacketType Heart_Beat_Lora_Packet;    //Allocate Memory for HeartBeat Lora Packets
  CheckIN_PacketType CheckIN_Lora_Packet; //Allocate Memory for CheckIN Lora Packets
+ CheckOUT_PacketType CheckOUT_Packet; //Allocate Memory for CheckOUT Lora Packets
  Motion_PacketType Motion_Lora_Packet;    //Allocate Memory for Movement Lora Packets
  Vehicle_Status_PacketType Vehicle_Status_Lora_Packet;    //Allocate Memory for Movement Lora Packets
  Near_Car_Beacon Near_Car_Beacon_Packet;
@@ -354,6 +355,45 @@
     Send_Lora_Packet_To_Gateway(Lora_Packet_To_Send,Pos); 
 }
 
+
+//CheckIN packets sending should be started when device is plugged in to the vehicle. It should be sent every 5sec for 2minutes and afterthat it should stop sending
+void Send_CheckOUT_Packet(void)
+{
+    //write code to read OBD data,temperature,beacon data
+    uint8 Pos = 0,i;
+    Lora_Packet_To_Send[Pos++] = CheckOUT_Packet.Header;                  //Header of Lora Packet,0xFE
+    Lora_Packet_To_Send[Pos++] = CheckOUT_Packet.Protocol_Version;      //MSB of Motion Packet Type
+    Lora_Packet_To_Send[Pos++] = CHECK_OUT_PACKET;      //Checkout detected. Set packet type to Checkout type
+    for(i=0;i < 17;i++)
+        Lora_Packet_To_Send[Pos++] = CheckOUT_Packet.VIN[i];           //Get OBD_ID
+    for(i=0;i < 3;i++)
+        Lora_Packet_To_Send[Pos++] = CheckOUT_Packet.ODO_METER_READING[i];           //Get OBD_ID
+    Lora_Packet_To_Send[Pos++] = (CheckOUT_Packet.OBD_Battery_Voltage >> 8);     //Get OBD_Battery Voltage
+    Lora_Packet_To_Send[Pos++] = (CheckOUT_Packet.OBD_Battery_Voltage & 0xFF);     //Get OBD_Battery Voltage
+    Lora_Packet_To_Send[Pos++] = (CheckOUT_Packet.Car_Battery_Voltage >> 8); //Get Vehicle_Battery Temperature
+    Lora_Packet_To_Send[Pos++] = (CheckOUT_Packet.Car_Battery_Voltage & 0xFF); //Get Vehicle_Battery Temperature
+    Lora_Packet_To_Send[Pos++] = CheckOUT_Packet.OBD_Battery_Temperature;     //Get Battery Temperature
+    Lora_Packet_To_Send[Pos++] = CheckOUT_Packet.Car_Ambient_Temperature;     //Get Ambient Temperature
+    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_Minor >> 8);     //Get Parking1 Minor
+    Lora_Packet_To_Send[Pos++] = (Fixed_Beacon_Packet.Parking1_Beacon_Minor & 0xFF);     //Get Parking1 Minor
+    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_Minor >> 8);     //Get Parking2 Minor
+    Lora_Packet_To_Send[Pos++] = (Fixed_Beacon_Packet.Parking2_Beacon_Minor & 0xFF);     //Get Parking2 Minor
+    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_Minor >> 8);     //Get Parking3 Minor
+    Lora_Packet_To_Send[Pos++] = (Fixed_Beacon_Packet.Parking3_Beacon_Minor & 0xFF);     //Get Parking3 Minor
+    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
+    CheckIN_Packet_Sent_Count++;
+    Send_Lora_Packet_To_Gateway(Lora_Packet_To_Send,Pos); 
+}
+
 //Motion packets sending should be started when vehicle acceleration changes like when it starts moving,stops moving and gets sudden jurk in case of theft.
 // It should be sent every 30sec for 2minutes and afterthat it should stop sending
 void Send_Motion_Packet(void)