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

Dependencies:   mbed LoRaWAN-lib_gps_lora SingleFrequencyLora

Revision:
15:b4d11baea8bc
Parent:
14:9e41438308eb
--- a/app/main.cpp	Fri Nov 24 15:39:51 2017 +0000
+++ b/app/main.cpp	Wed Nov 29 15:01:09 2017 +0000
@@ -16,15 +16,14 @@
 #include "board.h"
 #include "radio.h"
 #include "LoRaMac.h"
- 
- 
-#define APPDATA_SIZE 54
+
+#define APPDATA_SIZE 53
 #define LORAWAN_DEFAULT_DATARATE DR_0
 #define LORAWAN_DEVICE_ADDRESS                      ( uint32_t )0x01234567
 #define LORAWAN_NWKSKEY                             { 0x11, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }
 #define LORAWAN_APPSKEY                             { 0x11, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }
  
-uint8_t AppData[APPDATA_SIZE];
+// uint8_t AppData[APPDATA_SIZE];
 static uint8_t NwkSKey[] = LORAWAN_NWKSKEY;
 static uint8_t AppSKey[] = LORAWAN_APPSKEY;
  
@@ -68,17 +67,13 @@
             if((strncmp(GPRMC_Tag,Rx_data,(sizeof(GPRMC_Tag)-1)) == 0) || (strncmp(GNRMC_Tag,Rx_data,(sizeof(GNRMC_Tag)-1)) == 0)){
                 RMC = Parse_RMC_sentence(Rx_data);
                 if(strcmp(RMC.Status, "A") == 0){
-                     // GPS_status = 0;    // Turn status LED off
+                    // GPS_status = 0;    // Turn status LED off
                     valid = 1;
                     // GPS_parse = Parse_RMC_data(RMC); // Parse into format suitable for Tom (Dinghy_RaceTrak software)
-                    // Call function to send using LoRa module
                 }
                 else{
                     // GPS_status = 1;
-                    // Send "No GPS fix" over LoRa?
-                }
-                
-                // delete these lines
+                }                
                 if (sending){
                     Char_index = 0;
                     memset(Rx_data,0,sizeof(Rx_data));
@@ -87,14 +82,13 @@
                 GPS_data_ready = 0;
                 GPS_parse = Parse_RMC_data(RMC); // Parse into format suitable for Tom (Dinghy_RaceTrak software)
                 GPS_data_ready = 1;
-
-
             }
             Char_index = 0;
             memset(Rx_data,0,sizeof(Rx_data));
         }
-        else
+        else{
             Char_index++;
+        }
     }
     return;
     // store chars into a string then process into LAT, LONG, SOG, COG & DATETIME, VALID/INVLAID
@@ -104,6 +98,10 @@
     if(GPS_data_ready == 1){
         sending = 1;
         char AppDatas[APPDATA_SIZE];//="h";
+        strcat(AppDatas, GPS_parse.Node_ID);
+        strcat(AppDatas, ",");
+        strcat(AppDatas, GPS_parse.Node_Type);
+        strcat(AppDatas, ",");
         strcat(AppDatas, GPS_parse.Latitude);
         strcat(AppDatas, ",");
         strcat(AppDatas, GPS_parse.Longitude);
@@ -112,8 +110,6 @@
         strcat(AppDatas, ",");
         strcat(AppDatas, GPS_parse.Speed_Over_Ground);
         strcat(AppDatas, ",");
-        strcat(AppDatas, GPS_parse.Date);
-        strcat(AppDatas, ",");
         strcat(AppDatas, GPS_parse.UTC_Time);
         strcat(AppDatas, ",");
         strcat(AppDatas, GPS_parse.Valid);
@@ -127,7 +123,12 @@
         mcpsReq.Req.Unconfirmed.fBufferSize = APPDATA_SIZE+2;
         mcpsReq.Req.Unconfirmed.Datarate = DR_5;
         // status = !status;
-        GPS_status = !GPS_status;
+        if(strcmp(GPS_parse.Valid, "V")==0){
+            GPS_status = !GPS_status;
+        }
+        else{
+            GPS_status = 0;
+        }
         LoRaMacMcpsRequest( &mcpsReq );
         GPS_data_ready = 0;
         // Ready_for_more = 1;
@@ -223,7 +224,8 @@
     GPS_status = 1;
     gps.attach(&gps_receive, Serial::RxIrq);
     gps.printf(PMTK_SET_NMEA_OUTPUT_RMC); // Only output RMC and GPTXT
-    gps.printf(PMTK_SET_UPDATE_F_2HZ);    // Set update Frequency to 2Hz  
+    gps.printf(PMTK_SET_UPDATE_F_2HZ);    // Set update Frequency to 2Hz
+    // wait(1);
     LoRaSend_timer.attach(&LoRaSend, 1.0);
     while(1){
         }