Dummy Lora Packet Sending

Fork of Dealer_18feb17 by kumar singh

Revision:
23:688ee106c385
Parent:
22:c2f034a13108
Child:
24:1063cfc311e5
diff -r c2f034a13108 -r 688ee106c385 main.cpp
--- a/main.cpp	Thu Feb 23 04:41:47 2017 +0000
+++ b/main.cpp	Thu Feb 23 08:15:58 2017 +0000
@@ -18,10 +18,12 @@
 
 //Configure Serial port
 RawSerial LORA_UART(PA_0, PA_1);//USART4_TX->PA_0,USART4_RX->PA_1      :       Used for Lora module command sending and reception from gateway
-RawSerial pc1(PA_14, PA_15);//USART1_TX->PA_9,USART1_RX->PA_10   :       Used for debugging purpose only
-RawSerial DEBUG_UART(PA_14, PA_15);//USART1_TX->PA_9,USART1_RX->PA_10   :       Used for debugging purpose only
+//RawSerial pc1(PA_14, PA_15);//USART1_TX->PA_9,USART1_RX->PA_10   :       Used for debugging purpose only
+//RawSerial DEBUG_UART(PA_14, PA_15);//USART1_TX->PA_9,USART1_RX->PA_10   :       Used for debugging purpose only
 RawSerial Beacon_UART(PC_4, PC_5);//USART3_TX->PC4,USART3_RX->PC_5     :       Used for sending command to beacon module
 RawSerial BLE_RECEIVER_UART(PA_9, PA_10);//USART1_TX->PA_0,USART1_RX->PA_1      :       Used for Lora module command sending and reception from gateway
+Serial pc1(USBTX, USBRX);
+RawSerial DEBUG_UART(USBTX, USBRX);//USART1_TX->PA_9,USART1_RX->PA_10   :       Used for debugging purpose only
 
 //InterruptIn OBD_PLUGIN_INTERRUPT_PIN(PC_13);
 InterruptIn CheckIn_Interrupt(PB_7);//(PC_13);
@@ -39,7 +41,9 @@
 void Lora_Rcvd_Cmd_Processing_thread(void);// const *args);
 void Enable_CheckIN_Packet_Sending();
 
-const char GET_RSSI[]= {0x41,0x54,0x01,0x01,0x0D,0x0A};
+const char GET_RSSI[]= {0x41,0x54,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x0D,0x0A};
+const char SET_BEACON_VENDOR_ID[]= {0x41,0x54,0xF1,0x01,0x02,0x00,0x00,0x00,0x00,0xF2,0x0D,0x0A};
+const char SET_BEACON_MESSAGE_TYPE[]= {0x41,0x54,0xF2,0x01,0x00,0x00,0x00,0x00,0x00,0xF3,0x0D,0x0A};
 /*************************Accelerometer related definitions***********************************/
 //Accelerometer related definitions
 
@@ -116,6 +120,7 @@
 uint8 Command_Length_Sent;
 uint8 Checkin_Detect_Status = FALSE;
 void Extract_Received_Lora_Response(void);
+void Send_Command_To_BLE_Receiver(const char* Command);
 
 char previous_state = 0;
 char current_state = 0;
@@ -187,7 +192,7 @@
     while (Beacon_UART.readable()) {
         // while there is data waiting
         Beacon_RX_Buffer[Beacon_RxBuffer_End_Pos++] = Beacon_UART.getc(); // put it in the buffer
-        //pc1.putc(Beacon_RX_Buffer[Beacon_RxBuffer_End_Pos-1]);
+        pc1.printf("%2x",Beacon_RX_Buffer[Beacon_RxBuffer_End_Pos-1]);
         if(Beacon_RxBuffer_End_Pos >= 100) {
             // BUFFER OVERFLOW. What goes here depends on how you want to cope with that situation.
             // For now just throw everything away.
@@ -229,10 +234,18 @@
     //led2_thread is executing concurrently with main at this point
     //inactivity.rise(interrupt_activity_inactivity); // Attach the address of interrupt_activity_inactivity function to rising edge
     Initialize_Beacon_Module();
+    Send_Command_To_BLE_Receiver(SET_BEACON_VENDOR_ID);
+    Send_Command_To_BLE_Receiver(SET_BEACON_MESSAGE_TYPE);
     pc1.printf("%s","Transmitter MAC ID received");
     Lora_Periodic_Packet_Sending(); //Infinite loop for sending and receiving lora response, no return from here
 }
 
+void Send_Command_To_BLE_Receiver(const char* Command)
+{
+    uint8 i;
+    for(i=0;i<12;i++)
+        BLE_RECEIVER_UART.putc(Command[i]);
+}
 //Function to be called when Interrupt is genearted for motion sensing, checkin
 void Initialize_Packets_Sent_Count(void)
 {
@@ -252,6 +265,7 @@
             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 < 4) {
+                    Send_Command_To_BLE_Receiver(GET_RSSI);
                     Send_RSSI_Request_Command(GET_RSSI);
                     pc1.printf("Sending heartbeat packet");                               //call function to send periodic motion packet
                     Send_HeartBeat_Packet();                            //call function to send heartbeat packet
@@ -378,7 +392,7 @@
 
 void Send_RSSI_Request_Command(const char* Command_To_Send)
 {
-    BLE_RECEIVER_UART.printf(Command_To_Send);
+    //BLE_RECEIVER_UART.printf(Command_To_Send);
     Get_Fixed_Beacon_RSSI();
 }