kumar singh
/
Dealer_23Feb
Dummy Lora Packet Sending
Fork of Dealer_18feb17 by
Diff: main.cpp
- Revision:
- 20:f812f85cf97e
- Parent:
- 19:886d50ecc718
- Child:
- 21:a5fb0ae94dc6
--- a/main.cpp Tue Feb 21 06:27:13 2017 +0000 +++ b/main.cpp Tue Feb 21 13:33:29 2017 +0000 @@ -172,7 +172,7 @@ while (LORA_UART.readable()) { // while there is data waiting LORA_UART_RX_Buffer[Lora_RxBuffer_End_Pos++] = LORA_UART.getc(); // put it in the buffer - pc1.putc(LORA_UART_RX_Buffer[Lora_RxBuffer_End_Pos-1]); + //pc1.putc(LORA_UART_RX_Buffer[Lora_RxBuffer_End_Pos-1]); if(Lora_RxBuffer_End_Pos >= LORA_UART_RX_Size) { // BUFFER OVERFLOW. What goes here depends on how you want to cope with that situation. // For now just throw everything away. @@ -229,6 +229,7 @@ CheckIn_Interrupt.rise(&OBD_Plug_OUT_Interrupt); inactivity.rise(interrupt_activity_inactivity); // Attach the address of interrupt_activity_inactivity function to rising edge Initialize_Beacon_Module(); + pc1.printf("%s","Transmitter MAC ID received"); Lora_Periodic_Packet_Sending(); //Infinite loop for sending and receiving lora response, no return from here } @@ -250,8 +251,8 @@ if(Packet_Type_To_Send == HEARTBEAT_TYPE_PACKET) { //check if packet to be sent is Heartbeat packet if(Send_Lora_Packet_Flag) { //Check if packet sending is enabled, Packet should be sent only when enabled after timeout period Status_Packet_Wait_Count++; - if(Status_Packet_Wait_Count < 5) { - Send_RSSI_Request_Command(GET_RSSI); + if(Status_Packet_Wait_Count <= 3) { + //Send_RSSI_Request_Command(GET_RSSI); Send_HeartBeat_Packet(); //call function to send heartbeat packet pc.printf("Sent HeartBeat Packet"); AT_Response_Receive_Status = FAILURE; @@ -260,15 +261,15 @@ Send_Lora_Packet_Flag = FALSE; pc1.printf("Heartbeat Packet Response Received"); } else { - Send_RSSI_Request_Command(GET_RSSI); + //Send_RSSI_Request_Command(GET_RSSI); Status_Packet_Wait_Count = 0; Send_Vehicle_Status_Packet(); //call function to send heartbeat packet - //pc1.printf("Sent Status Packet"); + pc1.printf("Sent Status Packet"); //AT_Response_Receive_Status = FAILURE; //while(AT_Response_Receive_Status) // Get_Lora_Response(); Send_Lora_Packet_Flag = FALSE; - pc1.printf("Status Packet Response Received"); + //pc1.printf("Status Packet Response Received"); } } } else if(Packet_Type_To_Send == MOTION_TYPE_PACKET) { //check if packet to be sent is motion packet @@ -293,7 +294,7 @@ if(Send_Lora_Packet_Flag) { //Check if packet sending isd enabled, Packet should be sent only when enabled after timeout period Send_Lora_Packet_Flag = FALSE; pc1.printf("Sent Beacon ID request"); - Send_RSSI_Request_Command(GET_RSSI); + // Send_RSSI_Request_Command(GET_RSSI); if(OBD_PlugIN_State) { Send_CheckIN_Packet(); //call function to send periodic checkIn packet @@ -304,23 +305,25 @@ Send_CheckOUT_Packet(); pc1.printf("Sent CheckOut Packet"); } - __enable_irq(); // Enable Interrupts + //__enable_irq(); // Enable Interrupts AT_Response_Receive_Status = FAILURE; while(AT_Response_Receive_Status) Get_Lora_Response(); pc1.printf("Checkin Packet Response Received"); if(CheckIN_Packet_Sent_Count >= 5) { //Stop Sending Motion Packets if after sending for 2 minute pc1.printf("Packet Type Sending Changed to HeartBeat"); - CheckIN_Packet_Sent_Count = 0; - Packet_Type_To_Send = HEARTBEAT_TYPE_PACKET; //Set Packet type to send as heartbeat packet - Initialize_Packets_Sent_Count(); + CheckIN_Packet_Sent_Count = 0; + Packet_Type_To_Send = HEARTBEAT_TYPE_PACKET; //Set Packet type to send as heartbeat packet + Initialize_Packets_Sent_Count(); } } } if(OBD_PlugInOut_IOC_Status) { //Check if Accelerometer Interrupt is generated - __disable_irq(); // Disable Interrupts + //__disable_irq(); // Disable Interrupts //Enable_CheckIN_Packet_Sending(); //Get_Acceleration_Type(); + Process_Beacon_Command_Received(SET_VIRTUAL_PACKET_UUID); + Process_Beacon_Command_Received(SOFT_REBOOT); OBD_PlugInOut_IOC_Status = FALSE; Packet_Type_To_Send = CHECKIN_TYPE_PACKET; Send_Lora_Packet_Flag = TRUE;