kumar singh
/
Dealer_23Feb
Dummy Lora Packet Sending
Fork of Dealer_18feb17 by
Diff: Lora.cpp
- Revision:
- 24:1063cfc311e5
- Parent:
- 23:688ee106c385
diff -r 688ee106c385 -r 1063cfc311e5 Lora.cpp --- a/Lora.cpp Thu Feb 23 08:15:58 2017 +0000 +++ b/Lora.cpp Thu Feb 23 13:21:08 2017 +0000 @@ -62,28 +62,29 @@ //Set Up lora network void Set_Up_Lora_Network_Configuration(void) { + pc_2.baud(115200); LORA_Module_UART.baud(115200); LORA_Module_UART.printf(Attention);//Send Attention command AT_Response_Receive_Status = FAILURE; - pc2.printf("Nwk set up started"); + pc2.printf("\nNwk set up started"); while(AT_Response_Receive_Status) Get_Lora_Response(); - pc2.printf("AT Response received"); + pc2.printf("\nAT Response received"); LORA_Module_UART.printf("%s%d\r",Set_Frequency_Sub_Band,FREQUENCY_SUB_BAND_CHANNEL7);//set frequency sub band to 7 AT_Response_Receive_Status = FAILURE; while(AT_Response_Receive_Status) Get_Lora_Response(); - pc2.printf("Frequency band response received"); - LORA_Module_UART.printf("%s%d,%s\r",Set_Network_Key,STRING_PARAMETER,Network_Key); //set network key + pc2.printf("\nFrequency band response received"); + LORA_Module_UART.printf("\n%s%d,%s\r",Set_Network_Key,STRING_PARAMETER,Network_Key); //set network key AT_Response_Receive_Status = FAILURE; while(AT_Response_Receive_Status) Get_Lora_Response(); - pc2.printf("Network key Response received"); - LORA_Module_UART.printf("%s%d,%s\r",Set_Network_ID,STRING_PARAMETER,Network_ID); //set network id + pc2.printf("\nNetwork key Response received"); + LORA_Module_UART.printf("\n%s%d,%s\r",Set_Network_ID,STRING_PARAMETER,Network_ID); //set network id AT_Response_Receive_Status = FAILURE; while(AT_Response_Receive_Status) Get_Lora_Response(); - pc2.printf("Network Id response received"); + pc2.printf("\nNetwork Id response received"); LORA_Module_UART.printf("AT+TXDR=DR3\r"); AT_Response_Receive_Status = FAILURE; @@ -102,19 +103,19 @@ while(AT_Response_Receive_Status) Get_Lora_Response(); - pc2.printf("Configuration saved"); + pc2.printf("\nConfiguration saved"); LORA_Module_UART.printf("%s",Reset_Device); //reset device wait_ms(3500); LORA_Module_UART.printf(Attention); //Send Attention command AT_Response_Receive_Status = FAILURE; while(AT_Response_Receive_Status) Get_Lora_Response(); - pc2.printf("AT Response received"); + pc2.printf("\nAT Response received"); LORA_Module_UART.printf("%s",Join_Network); //join network with gateway AT_Response_Receive_Status = FAILURE; while(AT_Response_Receive_Status) Get_Lora_Response(); - pc2.printf("Join Response received"); + pc2.printf("\nJoin Response received"); } void Initialize_lora_Packets() @@ -132,12 +133,12 @@ Fixed_Beacon_Packet.Parking1_Beacon_ID[i] = (0x01+i); //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data Fixed_Beacon_Packet.Parking1_Beacon_Signal_Strength = 23; //Signal Strength of 3rd NearBy Beacon Device with Highest Signal Strength for(i=0;i<6;i++) - Fixed_Beacon_Packet.Parking2_Beacon_ID[i] = (10+i); //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data + Fixed_Beacon_Packet.Parking2_Beacon_ID[i] = (2+i); //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data Fixed_Beacon_Packet.Parking2_Beacon_Signal_Strength = 45; //Signal Strength of 3rd NearBy Beacon Device with Highest Signal Strength for(i=0;i<6;i++) - Fixed_Beacon_Packet.Parking3_Beacon_ID[i] = (20+i); //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data + Fixed_Beacon_Packet.Parking3_Beacon_ID[i] = (3+i); //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data Fixed_Beacon_Packet.Parking3_Beacon_Signal_Strength = 12; //Signal Strength of 3rd NearBy Beacon Device with Highest Signal Strength - Heart_Beat_Lora_Packet.Sequence_No = 0x00; //Sent Packet Sequence Number + Heart_Beat_Lora_Packet.Sequence_No = 0x01; //Sent Packet Sequence Number Heart_Beat_Lora_Packet.FCS = 0x00; //FCS of all packets /******* Initialize Lora packet for Vehicle Status *****/ @@ -145,94 +146,50 @@ Misc_Packet_Data.Protocol_Version = OBD_Protocol_Version; Vehicle_Status_Lora_Packet.Packet_Type = STATUS_PACKET_CMD; for(i=0;i<17;i++) - Misc_Packet_Data.VIN[i] = i;//Vehicle_Identification_Number[i]; + Misc_Packet_Data.VIN[i] = 0x06;//Vehicle_Identification_Number[i]; for(i=0;i<3;i++) Misc_Packet_Data.ODO_METER_READING[i] = 0x05; //Dummyy data, To be read using OBD Vehicle_Status_Lora_Packet.Fuel_Level = 1050;//10.5 litre - Misc_Packet_Data.OBD_Battery_Voltage = 350; - Misc_Packet_Data.Car_Battery_Voltage = 1250; - Misc_Packet_Data.OBD_Battery_Temperature = 95; - Misc_Packet_Data.Car_Ambient_Temperature = 104; + Misc_Packet_Data.OBD_Battery_Voltage = 200; + Misc_Packet_Data.Car_Battery_Voltage = 1000; + Misc_Packet_Data.OBD_Battery_Temperature = 100; + Misc_Packet_Data.Car_Ambient_Temperature = 200; for(i=0;i<6;i++) Vehicle_Status_Lora_Packet.BLE_Adv_Beacon_ID[i] = BLE_Adv_Module_Beacon_ID[i]; //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data for(i=0;i<6;i++) - Fixed_Beacon_Packet.Parking1_Beacon_ID[i] = i; //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data - Fixed_Beacon_Packet.Parking1_Beacon_Signal_Strength = 0x07; //Signal Strength of 3rd NearBy Beacon Device with Highest Signal Strength - for(i=0;i<6;i++) - Fixed_Beacon_Packet.Parking2_Beacon_ID[i] = i; //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data - Fixed_Beacon_Packet.Parking2_Beacon_Signal_Strength = 0x08; //Signal Strength of 3rd NearBy Beacon Device with Highest Signal Strength - for(i=0;i<6;i++) - Fixed_Beacon_Packet.Parking3_Beacon_ID[i] = i; //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data - Fixed_Beacon_Packet.Parking3_Beacon_Signal_Strength = 0x09; //Signal Strength of 3rd NearBy Beacon Device with Highest Signal Strength + Near_Car_Beacon_Packet.Near_Car1_Beacon_ID[i] = (3+i); //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data + Near_Car_Beacon_Packet.Near_Car1_Beacon_Signal_Strength = 0x07; //Signal Strength of 3rd NearBy Beacon Device with Highest Signal Strength for(i=0;i<6;i++) - Near_Car_Beacon_Packet.Near_Car1_Beacon_ID[i] = i; //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data - Near_Car_Beacon_Packet.Near_Car1_Beacon_Signal_Strength = 0x09; //Signal Strength of 3rd NearBy Beacon Device with Highest Signal Strength + Near_Car_Beacon_Packet.Near_Car2_Beacon_ID[i] = (2+i); //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data + Near_Car_Beacon_Packet.Near_Car2_Beacon_Signal_Strength = 0x08; //Signal Strength of 3rd NearBy Beacon Device with Highest Signal Strength for(i=0;i<6;i++) - Near_Car_Beacon_Packet.Near_Car2_Beacon_ID[i] = i; //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data - Near_Car_Beacon_Packet.Near_Car2_Beacon_Signal_Strength = 0x09; //Signal Strength of 3rd NearBy Beacon Device with Highest Signal Strength - for(i=0;i<6;i++) - Near_Car_Beacon_Packet.Near_Car3_Beacon_ID[i] = i; //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data + Near_Car_Beacon_Packet.Near_Car3_Beacon_ID[i] = (1+i); //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data Near_Car_Beacon_Packet.Near_Car3_Beacon_Signal_Strength = 0x09; //Signal Strength of 3rd NearBy Beacon Device with Highest Signal Strength - Vehicle_Status_Lora_Packet.Sequence_No = 0x00; //Sent Packet Sequence Number + Vehicle_Status_Lora_Packet.Sequence_No = 0x01; //Sent Packet Sequence Number Vehicle_Status_Lora_Packet.FCS = 0x00; //FCS of all packets /******* Initialize Lora packet for CheckIn *****/ Misc_Packet_Data.Header = LORA_PACKET_HEADER; Misc_Packet_Data.Protocol_Version = OBD_Protocol_Version; CheckIN_Lora_Packet.Packet_Type = CHECKIN_PACKET_CMD; - for(i=0;i<17;i++) - Misc_Packet_Data.VIN[i] = Vehicle_Identification_Number[i]; - for(i=0;i<3;i++) - Misc_Packet_Data.ODO_METER_READING[i] = 0x00; //Dummyy data, To be read using OBD for(i=0;i<5;i++) CheckIN_Lora_Packet.DTC[i] = 0x00; //Get Beacon_ID of 1st nearby Beacon Device - for(i=0;i<6;i++) - Fixed_Beacon_Packet.Parking1_Beacon_ID[i] = 0x00; //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data - Fixed_Beacon_Packet.Parking1_Beacon_Signal_Strength = 0x00; //Signal Strength of 3rd NearBy Beacon Device with Highest Signal Strength - for(i=0;i<6;i++) - Fixed_Beacon_Packet.Parking2_Beacon_ID[i] = 0x00; //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data - Fixed_Beacon_Packet.Parking2_Beacon_Signal_Strength = 0x00; //Signal Strength of 3rd NearBy Beacon Device with Highest Signal Strength - for(i=0;i<6;i++) - Fixed_Beacon_Packet.Parking3_Beacon_ID[i] = 0x00; //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data - Fixed_Beacon_Packet.Parking3_Beacon_Signal_Strength = 0x00; //Signal Strength of 3rd NearBy Beacon Device with Highest Signal Strength - CheckIN_Lora_Packet.Sequence_No = 0x00; //Sent Packet Sequence Number + CheckIN_Lora_Packet.Sequence_No = 0x01; //Sent Packet Sequence Number CheckIN_Lora_Packet.FCS = 0x00; //FCS of all packets /******* Initialize Lora packet for CheckOUT *****/ Misc_Packet_Data.Header = LORA_PACKET_HEADER; Misc_Packet_Data.Protocol_Version = OBD_Protocol_Version; CheckOUT_Packet.Packet_Type = CHECKIN_PACKET_CMD; - for(i=0;i<17;i++) - Misc_Packet_Data.VIN[i] = Vehicle_Identification_Number[i]; - for(i=0;i<3;i++) - Misc_Packet_Data.ODO_METER_READING[i] = 0x00; //Dummyy data, To be read using OBD - for(i=0;i<6;i++) - Fixed_Beacon_Packet.Parking1_Beacon_ID[i] = 0x00; //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data - Fixed_Beacon_Packet.Parking1_Beacon_Signal_Strength = 0x00; //Signal Strength of 3rd NearBy Beacon Device with Highest Signal Strength - for(i=0;i<6;i++) - Fixed_Beacon_Packet.Parking2_Beacon_ID[i] = 0x00; //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data - Fixed_Beacon_Packet.Parking2_Beacon_Signal_Strength = 0x00; //Signal Strength of 3rd NearBy Beacon Device with Highest Signal Strength - for(i=0;i<6;i++) - Fixed_Beacon_Packet.Parking3_Beacon_ID[i] = 0x00; //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data - Fixed_Beacon_Packet.Parking3_Beacon_Signal_Strength = 0x00; //Signal Strength of 3rd NearBy Beacon Device with Highest Signal Strength - CheckOUT_Packet.Sequence_No = 0x00; //Sent Packet Sequence Number + CheckOUT_Packet.Sequence_No = 0x01; //Sent Packet Sequence Number CheckOUT_Packet.FCS = 0x00; //FCS of all packets /******* Initialize Lora packet for Movement *****/ Misc_Packet_Data.Header = LORA_PACKET_HEADER; Misc_Packet_Data.Protocol_Version = OBD_Protocol_Version; Motion_Lora_Packet.Packet_Type = MOTION_PACKET_CMD; - for(i=0;i<6;i++) - Fixed_Beacon_Packet.Parking1_Beacon_ID[i] = 0x00; //MAC ID of 1st NearBy Beacon Device with Highest Signal Strength,dummy data - Fixed_Beacon_Packet.Parking1_Beacon_Signal_Strength = 0x00; //Signal Strength of 1st NearBy Beacon Device with Highest Signal Strength - for(i=0;i<6;i++) - Fixed_Beacon_Packet.Parking2_Beacon_ID[i] = 0x00; //MAC ID of 2nd NearBy Beacon Device with Highest Signal Strength,dummy data - Fixed_Beacon_Packet.Parking2_Beacon_Signal_Strength = 0x00; //Signal Strength of 2nd NearBy Beacon Device with Highest Signal Strength - for(i=0;i<6;i++) - Fixed_Beacon_Packet.Parking3_Beacon_ID[i] = 0x00; //MAC ID of 3rd NearBy Beacon Device with Highest Signal Strength,dummy data - Fixed_Beacon_Packet.Parking3_Beacon_Signal_Strength = 0x00; //Signal Strength of 3rd NearBy Beacon Device with Highest Signal Strength Motion_Lora_Packet.Acceleration_Type = 0x00; //Type of acceleration, Vehicle Started/Vehicle Stopped/Sudden Vehicle Movement - Motion_Lora_Packet.Sequence_No = 0x00; //Sent Packet Sequence Number + Motion_Lora_Packet.Sequence_No = 0x01; //Sent Packet Sequence Number Motion_Lora_Packet.FCS = 0x00; //FCS of all packets Lora_Packet_To_Send[0] = 0x41;//'A' Lora_Packet_To_Send[1] = 0x54;//'T' @@ -244,6 +201,7 @@ Lora_Packet_To_Send[7] = 0x20;//' ' Blank Space Lora_Packet_To_Send[8] = Misc_Packet_Data.Header; //Header of Lora Packet,0xFE Lora_Packet_To_Send[9] = Misc_Packet_Data.Protocol_Version; + pc2.printf("\nLora Packets Initialized"); } //HeartBeat Packet should be sent every 30sec @@ -268,8 +226,8 @@ 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++] = Heart_Beat_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++] = 0xDE;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos); //Calculate FCS of all bytes + //Lora_Packet_To_Send[Pos++] = Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos); //Calculate FCS of all bytes + Lora_Packet_To_Send[Pos++] = 0xFA;//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++] = 0xB1;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos); //Calculate FCS of all bytes Lora_Packet_To_Send[Pos++] = 0xB2;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos); //Calculate FCS of all bytes @@ -277,11 +235,11 @@ Lora_Packet_To_Send[Pos++] = 0xB4;//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); - if(Heart_Beat_Lora_Packet.Sequence_No < 0xFF) + if(Heart_Beat_Lora_Packet.Sequence_No < 0x08) Heart_Beat_Lora_Packet.Sequence_No++; else - Heart_Beat_Lora_Packet.Sequence_No = 0x00; - pc2.printf("Heartbeat Packet Sequence Number %d",Heart_Beat_Lora_Packet.Sequence_No); + Heart_Beat_Lora_Packet.Sequence_No = 0x01; + pc2.printf("\nHeartbeat Packet Sequence Number %d",Heart_Beat_Lora_Packet.Sequence_No); } //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 @@ -303,8 +261,6 @@ Lora_Packet_To_Send[Pos++] = Misc_Packet_Data.OBD_Battery_Temperature; //Get Battery Temperature Lora_Packet_To_Send[Pos++] = Misc_Packet_Data.Car_Ambient_Temperature; //Get Ambient Temperature for(i=0;i<6;i++) - 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 for(i=0;i<6;i++) @@ -313,7 +269,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 +277,9 @@ 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++] = 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 @@ -352,24 +308,19 @@ 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++] = 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 Lora_Packet_To_Send[Pos++] = 0xA3;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos); //Calculate FCS of all bytes Lora_Packet_To_Send[Pos++] = 0xA4;//Calculate_Lora_Frame_FCS(Lora_Packet_To_Send,Pos); //Calculate FCS of all bytes */Send_Lora_Packet_To_Gateway(Lora_Packet_To_Send,Pos); - if(Vehicle_Status_Lora_Packet.Sequence_No < 0xFF) + if(Vehicle_Status_Lora_Packet.Sequence_No < 0x08) Vehicle_Status_Lora_Packet.Sequence_No++; else - Vehicle_Status_Lora_Packet.Sequence_No = 0x00; - pc2.printf("Status Packet sending"); - for(i=0; i < Pos; 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); + Vehicle_Status_Lora_Packet.Sequence_No = 0x01; + pc2.printf("\nStatus Packet sending"); + pc2.printf("\nStatus Packet Sequence Number %d",Vehicle_Status_Lora_Packet.Sequence_No); } //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 @@ -404,14 +355,13 @@ 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++) - { - pc2.putc(Lora_Packet_To_Send[i]); - //pc2.putc(Command_To_Send[i]); - } - pc2.printf("CheckIN Packet Sent"); - CheckIN_Lora_Packet.Sequence_No++; - pc2.printf("Status Packet Sequence Number %d",CheckIN_Lora_Packet.Sequence_No); + pc2.printf("\nCheckIN Packet Sent"); + if(CheckIN_Lora_Packet.Sequence_No < 0x08) + CheckIN_Lora_Packet.Sequence_No++; + else + CheckIN_Lora_Packet.Sequence_No = 0x01; + pc2.printf("\nStatus Packet sending"); + pc2.printf("\nCheckIN Packet Sequence Number %d",CheckIN_Lora_Packet.Sequence_No); } @@ -431,18 +381,26 @@ Lora_Packet_To_Send[Pos++] = (Misc_Packet_Data.Car_Battery_Voltage & 0xFF); //Get Vehicle_Battery Temperature Lora_Packet_To_Send[Pos++] = Misc_Packet_Data.OBD_Battery_Temperature; //Get Battery Temperature Lora_Packet_To_Send[Pos++] = Misc_Packet_Data.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_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 + 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++] = 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++) - { - pc2.putc(Lora_Packet_To_Send[i]); - //pc2.putc(Command_To_Send[i]); - }pc2.printf("CheckOUT Packet Sent"); - CheckOUT_Packet.Sequence_No++; - pc2.printf("Status Packet Sequence Number %d",CheckOUT_Packet.Sequence_No); + pc2.printf("\nCheckOUT Packet Sent"); + if(CheckOUT_Packet.Sequence_No < 0x08) + CheckOUT_Packet.Sequence_No++; + else + CheckOUT_Packet.Sequence_No = 0x01; + pc2.printf("\CheckOUT Packet Sequence Number %d",CheckOUT_Packet.Sequence_No); } //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. @@ -451,7 +409,7 @@ { //write code to read accelerometer data,temperature,beacon data uint8 Pos = 10,i; - Lora_Packet_To_Send[Pos++] = (Motion_Lora_Packet.Packet_Type & 0xFF); //LSB of Motion Packet Type + Lora_Packet_To_Send[Pos++] = MOTION_PACKET_CMD;//(Motion_Lora_Packet.Packet_Type & 0xFF); //LSB of Motion Packet Type 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 @@ -464,14 +422,8 @@ 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++) - Lora_Packet_To_Send[Pos++] = Near_Car_Beacon_Packet.Near_Car2_Beacon_ID[i]; //Get Beacon_ID of 2nd nearby Beacon Device - 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++] = Motion_Lora_Packet.Acceleration_Type; //get Type of Acceleration - 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++) @@ -480,16 +432,17 @@ 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++] = Motion_Lora_Packet.Sequence_No; //Packet Sequence number + */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 + 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++) - { - pc2.putc(Lora_Packet_To_Send[i]); - //pc2.putc(Command_To_Send[i]); - }Motion_Lora_Packet.Sequence_No++; + if(Motion_Lora_Packet.Sequence_No < 0x08) + Motion_Lora_Packet.Sequence_No++; + else + Motion_Lora_Packet.Sequence_No = 0x01; + pc2.printf("\n Motion Packet Sent"); + pc2.printf("\Motion Packet Sequence Number %d",Motion_Lora_Packet.Sequence_No); } @@ -548,7 +501,7 @@ void Send_Lora_Packet_To_Gateway(uint8* Command_To_Send,uint8 Length) { uint8 i=0; - pc2.printf("Sending command"); + pc2.printf("\nSending command"); for(i=0; i < Length; i++) { LORA_Module_UART.putc(Command_To_Send[i]);