GPS working with LoRa code - can't transmit faster that once every 6 seconds

Dependencies:   mbed LoRaWAN-lib_gps_lora SingleFrequencyLora

Revision:
10:0b5a507b4a4d
Parent:
9:b866f1bc8fd4
Child:
11:f2a7f98cc9bf
--- a/l86.cpp	Mon Nov 13 19:51:18 2017 +0000
+++ b/l86.cpp	Tue Nov 14 16:06:16 2017 +0000
@@ -7,24 +7,19 @@
 RawSerial pc2(PC_TX, PC_RX);    // USART2
 #endif
 
-RMC_data Parse_RMC_data(char RMC_sentence[MAX_NMEA_LENGTH]){
-    
-    //Local Variables
-    char RMC_message_copy[MAX_NMEA_LENGTH] = "";
+/* Parse NMEA RMC sentence into RMC data struct */
+RMC_data Parse_RMC_sentence(char RMC_sentence[MAX_NMEA_LENGTH]){
     const char delimeter[2] = ",";
     char *token = "";
     int i = 0;
     char temp[11][12];          /* [11][12]: 11 strings, of length 12 */
     RMC_data RMC_parsed;
     
-    //Copy original RMC sentence to a copy in order to not destroy message
-    strcpy(RMC_message_copy,RMC_sentence);
     strcpy(RMC_parsed.Message, RMC_sentence);
-    // pc2.printf(RMC_data_parse->Message);
     
     //Seperated Message
     /* get the first token */
-   token = strtok(RMC_message_copy, delimeter);
+   token = strtok(RMC_sentence, delimeter);
    
    /* walk through other tokens */
    while( token != NULL ) 
@@ -53,6 +48,7 @@
 
 // Use GPS data parse function? // parses into data formats that will be sent over LoRa
 
+/* Print RMC_data struct to PC USART for debugging */
 void Print_RMC_data(RMC_data *RMC_data_print){
     pc2.printf("RMC_Message: %s",RMC_data_print->Message);
     pc2.printf("UTC_Time: %s\r\n",RMC_data_print->UTC_Time);
@@ -67,4 +63,38 @@
         pc2.printf("Date: %s\r\n",RMC_data_print->Date);
         pc2.printf("Mode: %s\r\n",RMC_data_print->Mode);
     }
-}
\ No newline at end of file
+}
+
+/* Parse RMC_data struct into GPS data struct ready for sending over LoRa */
+GPS_data Parse_RMC_data(RMC_data RMC_parsed){
+    GPS_data GPS_parsed;
+    strcpy(GPS_parsed.UTC_Time,RMC_parsed.UTC_Time);
+    if (strcmp(RMC_parsed.N_S_Indicator, "N") == 0){
+        strcpy(GPS_parsed.Latitude, strcat("+", RMC_parsed.Latitude));
+    }
+    else{
+        strcpy(GPS_parsed.Latitude, strcat("-", RMC_parsed.Latitude));
+    }
+    if (strcmp(RMC_parsed.E_W_Indicator, "E") == 0){
+        strcpy(GPS_parsed.Longitude, strcat("+", RMC_parsed.Latitude));
+    }
+    else{
+        strcpy(GPS_parsed.Longitude, strcat("-", RMC_parsed.Latitude));
+    }
+    strcpy(GPS_parsed.Speed_Over_Ground,RMC_parsed.Speed_Over_Ground);
+    strcpy(GPS_parsed.Course_Over_Ground,RMC_parsed.Course_Over_Ground);
+    strcpy(GPS_parsed.Date,RMC_parsed.Date);
+    strcpy(GPS_parsed.Valid,RMC_parsed.Status);
+    return GPS_parsed;
+}
+
+/* Print GPS_data struct to PC USART for debugging */
+void Print_GPS_data(GPS_data GPS_data_print){
+    pc2.printf("UTC_Time: %s\r\n",GPS_data_print.UTC_Time);
+    pc2.printf("Status: %s\r\n",GPS_data_print.Valid);
+    pc2.printf("Latitude: %s\r\n",GPS_data_print.Latitude);
+    pc2.printf("Longitude: %s\r\n",GPS_data_print.Longitude);
+    pc2.printf("Speed: %s\r\n",GPS_data_print.Speed_Over_Ground);
+    pc2.printf("Course: %s\r\n",GPS_data_print.Course_Over_Ground);
+    pc2.printf("Date: %s\r\n",GPS_data_print.Date);
+}