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

Dependencies:   mbed LoRaWAN-lib_gps_lora SingleFrequencyLora

Files at this revision

API Documentation at this revision

Comitter:
Rishin
Date:
Wed Nov 29 15:01:09 2017 +0000
Parent:
14:9e41438308eb
Commit message:
publishining gps with lora

Changed in this revision

app/l86.cpp Show annotated file Show diff for this revision Revisions of this file
app/l86.hpp Show annotated file Show diff for this revision Revisions of this file
app/main.cpp Show annotated file Show diff for this revision Revisions of this file
mac/LoRaWAN-lib.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 9e41438308eb -r b4d11baea8bc app/l86.cpp
--- a/app/l86.cpp	Fri Nov 24 15:39:51 2017 +0000
+++ b/app/l86.cpp	Wed Nov 29 15:01:09 2017 +0000
@@ -90,7 +90,9 @@
         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);
+        // strcpy(GPS_parsed.Date,RMC_parsed.Date);
+        strcpy(GPS_parsed.Node_ID, TEST_NODE_ID);
+        strcpy(GPS_parsed.Node_Type, TEST_NODE_TYPE);
         strcpy(GPS_parsed.Valid,RMC_parsed.Status);
     }
     else {
@@ -98,8 +100,10 @@
         strcpy(GPS_parsed.Latitude,"+0000.0000");
         strcpy(GPS_parsed.Longitude,"+00000.0000");
         strcpy(GPS_parsed.Speed_Over_Ground,"0.00");
-        strcpy(GPS_parsed.Course_Over_Ground,"000.00");
-        strcpy(GPS_parsed.Date,"000000");
+        strcpy(GPS_parsed.Course_Over_Ground,"000.00");          
+        strcpy(GPS_parsed.Node_ID, TEST_NODE_ID);
+        strcpy(GPS_parsed.Node_Type, TEST_NODE_TYPE);
+        // strcpy(GPS_parsed.Date,"000000");
         strcpy(GPS_parsed.Valid,RMC_parsed.Status);
     }
     return GPS_parsed;
@@ -113,6 +117,6 @@
     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);
+    // pc2.printf("Date: %s\r\n",GPS_data_print.Date);
 }
 
diff -r 9e41438308eb -r b4d11baea8bc app/l86.hpp
--- a/app/l86.hpp	Fri Nov 24 15:39:51 2017 +0000
+++ b/app/l86.hpp	Wed Nov 29 15:01:09 2017 +0000
@@ -10,6 +10,10 @@
 
 #define DEBUGGER // uncomment to output serial data to PC
 
+
+#define TEST_NODE_ID    "666"
+#define TEST_NODE_TYPE  "R"
+
 /*      PIN DEFINITIONS      */
 // #define RESET_PIN       PB_14
 // #define FORCE_ON_PIN    PB_15
@@ -61,8 +65,10 @@
     char Longitude[12];
     char Speed_Over_Ground[5];
     char Course_Over_Ground[7];
-    char Date[7];
+    // char Date[7];
     char Valid[2];
+    char Node_ID[4];
+    char Node_Type[2];
 }GPS_data;
 
 RMC_data Parse_RMC_sentence(char RMC_sentence[MAX_NMEA_LENGTH]);
diff -r 9e41438308eb -r b4d11baea8bc app/main.cpp
--- 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){
         }
diff -r 9e41438308eb -r b4d11baea8bc mac/LoRaWAN-lib.lib
--- a/mac/LoRaWAN-lib.lib	Fri Nov 24 15:39:51 2017 +0000
+++ b/mac/LoRaWAN-lib.lib	Wed Nov 29 15:01:09 2017 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/cdebank/code/LoRaWAN-lib/#97ffb19b5627
+https://os.mbed.com/users/Rishin/code/LoRaWAN-lib_gps_lora/#97ffb19b5627