GPS working with LoRa code - can't transmit faster that once every 6 seconds
Dependencies: mbed LoRaWAN-lib_gps_lora SingleFrequencyLora
l86.cpp@9:b866f1bc8fd4, 2017-11-13 (annotated)
- Committer:
- Rishin
- Date:
- Mon Nov 13 19:51:18 2017 +0000
- Revision:
- 9:b866f1bc8fd4
- Parent:
- 7:1c90f51096fe
- Child:
- 10:0b5a507b4a4d
Commit to mark end of day progress
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rishin | 5:850a9db98a41 | 1 | #include "l86.hpp" |
Rishin | 5:850a9db98a41 | 2 | #include <string.h> |
Rishin | 6:670ff1507ff4 | 3 | #include <stdio.h> |
Rishin | 7:1c90f51096fe | 4 | #include "mbed.h" |
Rishin | 5:850a9db98a41 | 5 | |
Rishin | 7:1c90f51096fe | 6 | #ifdef DEBUGGER |
Rishin | 7:1c90f51096fe | 7 | RawSerial pc2(PC_TX, PC_RX); // USART2 |
Rishin | 7:1c90f51096fe | 8 | #endif |
Rishin | 7:1c90f51096fe | 9 | |
Rishin | 7:1c90f51096fe | 10 | RMC_data Parse_RMC_data(char RMC_sentence[MAX_NMEA_LENGTH]){ |
Rishin | 5:850a9db98a41 | 11 | |
Rishin | 5:850a9db98a41 | 12 | //Local Variables |
Rishin | 5:850a9db98a41 | 13 | char RMC_message_copy[MAX_NMEA_LENGTH] = ""; |
Rishin | 5:850a9db98a41 | 14 | const char delimeter[2] = ","; |
Rishin | 5:850a9db98a41 | 15 | char *token = ""; |
Rishin | 5:850a9db98a41 | 16 | int i = 0; |
Rishin | 7:1c90f51096fe | 17 | char temp[11][12]; /* [11][12]: 11 strings, of length 12 */ |
Rishin | 7:1c90f51096fe | 18 | RMC_data RMC_parsed; |
Rishin | 5:850a9db98a41 | 19 | |
Rishin | 5:850a9db98a41 | 20 | //Copy original RMC sentence to a copy in order to not destroy message |
Rishin | 7:1c90f51096fe | 21 | strcpy(RMC_message_copy,RMC_sentence); |
Rishin | 7:1c90f51096fe | 22 | strcpy(RMC_parsed.Message, RMC_sentence); |
Rishin | 7:1c90f51096fe | 23 | // pc2.printf(RMC_data_parse->Message); |
Rishin | 5:850a9db98a41 | 24 | |
Rishin | 5:850a9db98a41 | 25 | //Seperated Message |
Rishin | 5:850a9db98a41 | 26 | /* get the first token */ |
Rishin | 5:850a9db98a41 | 27 | token = strtok(RMC_message_copy, delimeter); |
Rishin | 5:850a9db98a41 | 28 | |
Rishin | 5:850a9db98a41 | 29 | /* walk through other tokens */ |
Rishin | 5:850a9db98a41 | 30 | while( token != NULL ) |
Rishin | 5:850a9db98a41 | 31 | { |
Rishin | 5:850a9db98a41 | 32 | strcpy(temp[i],token); |
Rishin | 5:850a9db98a41 | 33 | i++; |
Rishin | 5:850a9db98a41 | 34 | token = strtok(NULL, delimeter); |
Rishin | 5:850a9db98a41 | 35 | } |
Rishin | 5:850a9db98a41 | 36 | |
Rishin | 6:670ff1507ff4 | 37 | //Copy the message into its individual components |
Rishin | 7:1c90f51096fe | 38 | strcpy(RMC_parsed.Message_ID,temp[0]); |
Rishin | 7:1c90f51096fe | 39 | strcpy(RMC_parsed.UTC_Time,temp[1]); |
Rishin | 7:1c90f51096fe | 40 | strcpy(RMC_parsed.Status,temp[2]); |
Rishin | 7:1c90f51096fe | 41 | if(strcmp(RMC_parsed.Status,"A") == 0){ |
Rishin | 7:1c90f51096fe | 42 | strcpy(RMC_parsed.Latitude,temp[3]); |
Rishin | 7:1c90f51096fe | 43 | strcpy(RMC_parsed.N_S_Indicator,temp[4]); |
Rishin | 7:1c90f51096fe | 44 | strcpy(RMC_parsed.Longitude,temp[5]); |
Rishin | 7:1c90f51096fe | 45 | strcpy(RMC_parsed.E_W_Indicator,temp[6]); |
Rishin | 7:1c90f51096fe | 46 | strcpy(RMC_parsed.Speed_Over_Ground,temp[7]); |
Rishin | 7:1c90f51096fe | 47 | strcpy(RMC_parsed.Course_Over_Ground,temp[8]); |
Rishin | 7:1c90f51096fe | 48 | strcpy(RMC_parsed.Date,temp[9]); |
Rishin | 7:1c90f51096fe | 49 | strcpy(RMC_parsed.Mode,temp[10]); |
Rishin | 7:1c90f51096fe | 50 | } |
Rishin | 7:1c90f51096fe | 51 | return RMC_parsed; |
Rishin | 6:670ff1507ff4 | 52 | } |
Rishin | 6:670ff1507ff4 | 53 | |
Rishin | 7:1c90f51096fe | 54 | // Use GPS data parse function? // parses into data formats that will be sent over LoRa |
Rishin | 7:1c90f51096fe | 55 | |
Rishin | 7:1c90f51096fe | 56 | void Print_RMC_data(RMC_data *RMC_data_print){ |
Rishin | 9:b866f1bc8fd4 | 57 | pc2.printf("RMC_Message: %s",RMC_data_print->Message); |
Rishin | 7:1c90f51096fe | 58 | pc2.printf("UTC_Time: %s\r\n",RMC_data_print->UTC_Time); |
Rishin | 7:1c90f51096fe | 59 | pc2.printf("Status: %s\r\n",RMC_data_print->Status); |
Rishin | 7:1c90f51096fe | 60 | if(strcmp(RMC_data_print->Status,"A") == 0){ |
Rishin | 7:1c90f51096fe | 61 | pc2.printf("Latitude: %s\r\n",RMC_data_print->Latitude); |
Rishin | 7:1c90f51096fe | 62 | pc2.printf("N/S: %s\r\n",RMC_data_print->N_S_Indicator); |
Rishin | 7:1c90f51096fe | 63 | pc2.printf("Longitude: %s\r\n",RMC_data_print->Longitude); |
Rishin | 7:1c90f51096fe | 64 | pc2.printf("E/W: %s\r\n",RMC_data_print->E_W_Indicator); |
Rishin | 7:1c90f51096fe | 65 | pc2.printf("Speed: %s\r\n",RMC_data_print->Speed_Over_Ground); |
Rishin | 7:1c90f51096fe | 66 | pc2.printf("Course: %s\r\n",RMC_data_print->Course_Over_Ground); |
Rishin | 7:1c90f51096fe | 67 | pc2.printf("Date: %s\r\n",RMC_data_print->Date); |
Rishin | 7:1c90f51096fe | 68 | pc2.printf("Mode: %s\r\n",RMC_data_print->Mode); |
Rishin | 7:1c90f51096fe | 69 | } |
Rishin | 7:1c90f51096fe | 70 | } |