GPS working with LoRa code - can't transmit faster that once every 6 seconds
Dependencies: mbed LoRaWAN-lib_gps_lora SingleFrequencyLora
Diff: l86.cpp
- Revision:
- 12:d9144f16d78b
- Parent:
- 11:f2a7f98cc9bf
diff -r f2a7f98cc9bf -r d9144f16d78b l86.cpp --- a/l86.cpp Wed Nov 15 15:27:36 2017 +0000 +++ b/l86.cpp Fri Nov 24 14:26:09 2017 +0000 @@ -4,7 +4,7 @@ #include "mbed.h" #ifdef DEBUGGER -RawSerial pc2(PC_TX, PC_RX); // USART2 +RawSerial pc2(USBTX, USBRX); // USART2 #endif /* Parse NMEA RMC sentence into RMC data struct */ @@ -51,7 +51,7 @@ /* 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); + /*pc2.printf("UTC_Time: %s\r\n",RMC_data_print->UTC_Time); pc2.printf("Status: %s\r\n",RMC_data_print->Status); if(strcmp(RMC_data_print->Status,"A") == 0){ pc2.printf("Latitude: %s\r\n",RMC_data_print->Latitude); @@ -62,26 +62,32 @@ pc2.printf("Course: %s\r\n",RMC_data_print->Course_Over_Ground); pc2.printf("Date: %s\r\n",RMC_data_print->Date); pc2.printf("Mode: %s\r\n",RMC_data_print->Mode); - } + }*/ } /* 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; + char tempLat[11]="0"; + char tempLong[12]="0"; if(strcmp(RMC_parsed.Status,"A") == 0){ 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)); + tempLat[0] = '+'; } else{ - strcpy(GPS_parsed.Latitude, strcat("-", RMC_parsed.Latitude)); + tempLat[0] = '-'; } + strcat(tempLat, RMC_parsed.Latitude); + strcpy(GPS_parsed.Latitude,tempLat); if (strcmp(RMC_parsed.E_W_Indicator, "E") == 0){ - strcpy(GPS_parsed.Longitude, strcat("+", RMC_parsed.Longitude)); + tempLong[0] = '+'; } else{ - strcpy(GPS_parsed.Longitude, strcat("-", RMC_parsed.Longitude)); + tempLong[0] = '-'; } + strcat(tempLong, RMC_parsed.Longitude); + strcpy(GPS_parsed.Longitude, tempLong); 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); @@ -94,7 +100,7 @@ strcpy(GPS_parsed.Speed_Over_Ground,"0.00"); strcpy(GPS_parsed.Course_Over_Ground,"000.00"); strcpy(GPS_parsed.Date,"000000"); - strcpy(GPS_parsed.Valid,"V"); + strcpy(GPS_parsed.Valid,RMC_parsed.Status); } return GPS_parsed; } @@ -109,3 +115,4 @@ pc2.printf("Course: %s\r\n",GPS_data_print.Course_Over_Ground); pc2.printf("Date: %s\r\n",GPS_data_print.Date); } +