kumar singh
/
Dealer_20Mar
BLE Transmitter not working
Fork of Dealer_23Feb by
Diff: main.cpp
- Revision:
- 22:c2f034a13108
- Parent:
- 21:a5fb0ae94dc6
- Child:
- 23:688ee106c385
diff -r a5fb0ae94dc6 -r c2f034a13108 main.cpp --- a/main.cpp Wed Feb 22 14:59:59 2017 +0000 +++ b/main.cpp Thu Feb 23 04:41:47 2017 +0000 @@ -137,6 +137,7 @@ void OBD_Plug_OUT_Interrupt() { + if(OBD_PlugIN_State2!=OBD_PlugIN_Temp_State) { OBD_PlugIN_State2=0; OBD_PlugIN_State=!OBD_PlugIN_State; @@ -200,7 +201,7 @@ while (BLE_RECEIVER_UART.readable()) { // while there is data waiting BLE_Receiver_UART_RX_Buffer[BLE_RxBuffer_End_Pos++] = BLE_RECEIVER_UART.getc(); // put it in the buffer - pc1.putc(BLE_Receiver_UART_RX_Buffer[BLE_RxBuffer_End_Pos-1]); + //pc1.putc(BLE_Receiver_UART_RX_Buffer[BLE_RxBuffer_End_Pos-1]); if(BLE_RxBuffer_End_Pos >= BLE_RECEIVER_UART_RX_Size) { // BUFFER OVERFLOW. What goes here depends on how you want to cope with that situation. // For now just throw everything away. @@ -216,7 +217,9 @@ pc1.printf("%s","Debugging started"); BLE_RECEIVER_UART.attach(&BLE_Receiver_onDataRx, Serial::RxIrq); LORA_UART.attach(&Lora_onDataRx, Serial::RxIrq); - + CheckIn_Interrupt.fall(&OBD_Plug_IN_Interrupt); + CheckIn_Interrupt.rise(&OBD_Plug_OUT_Interrupt); + //Create a thread to read vehicle data //Thread OBD_thread(OBD_Rcvd_Cmd_Processing_thread); @@ -224,9 +227,7 @@ // OBD_PLUGIN_INTERRUPT_PIN.rise(&Enable_CheckIN_Packet_Sending); // call toggle function on the rising edge //led2_thread is executing concurrently with main at this point - CheckIn_Interrupt.fall(&OBD_Plug_IN_Interrupt); - CheckIn_Interrupt.rise(&OBD_Plug_OUT_Interrupt); - inactivity.rise(interrupt_activity_inactivity); // Attach the address of interrupt_activity_inactivity function to rising edge + //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 @@ -260,7 +261,7 @@ Get_Lora_Response(); Send_Lora_Packet_Flag = FALSE; //pc1.printf("Heartbeat Packet Response Received"); - } else if(Status_Packet_Wait_Count >= 6){ + } else { //Send_RSSI_Request_Command(GET_RSSI); Status_Packet_Wait_Count = 0; pc1.printf("Sending Vehicle status packets"); //call function to send periodic motion packet @@ -303,6 +304,7 @@ Send_CheckIN_Packet(); //call function to send periodic checkIn packet pc1.printf("Sent Checkin Packet"); Process_Beacon_Command_Received(SET_VIRTUAL_PACKET_UUID); + wait(.2); Process_Beacon_Command_Received(SOFT_REBOOT1); } else @@ -311,11 +313,12 @@ Send_CheckOUT_Packet(); pc1.printf("Sent CheckOut Packet"); Process_Beacon_Command_Received(SET_VIRTUAL_PACKET_UUID2); + wait(.2); Process_Beacon_Command_Received(SOFT_REBOOT1); } - AT_Response_Receive_Status = FAILURE; + /* AT_Response_Receive_Status = FAILURE; while(AT_Response_Receive_Status) - Get_Lora_Response(); + Get_Lora_Response();*/ 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; @@ -329,6 +332,7 @@ //Get_Acceleration_Type(); // Process_Beacon_Command_Received(SET_VIRTUAL_PACKET_UUID); // Process_Beacon_Command_Received(SOFT_REBOOT1); + pc.putc('j'); OBD_PlugInOut_IOC_Status = FALSE; Packet_Type_To_Send = CHECKIN_TYPE_PACKET; Send_Lora_Packet_Flag = TRUE;