Bmag incl gps rettelse

Dependencies:   mbed WDT MODSERIAL BME280

Revision:
22:9f5955f051f5
Parent:
21:325cb82f1838
Child:
23:2e914b705b99
--- a/main.cpp	Thu May 11 13:42:32 2017 +0000
+++ b/main.cpp	Mon May 15 12:46:50 2017 +0000
@@ -4,13 +4,13 @@
 
 //change GPSACQTIMELIMITINSECONDS to change the duration in seconds, allowed for the gps to get gps fix. 
 //After this duration, an error indication will occur if fix is not present.
-#define GPSACQTIMELIMITINSECONDS 60 
+#define GPSACQTIMELIMITINSECONDS 120 
 
 //to change battery low indication change this value
 #define BATTERYLOWLIMIT 10.5 
 
 //change BARCODE string inside double quotes to barcode of BMAG equipment
-char BARCODE[6] = "12345";
+char BARCODE[6] = "06655";
 
 
 //Global GPS variables
@@ -140,7 +140,6 @@
     
     //Init errorhandler
     ErrorHandler dispTxtHandler(&batteryvoltage, &GGA_Fix_Present, &magParser, &gpsNMEA);
-    dispTxtHandler.setErrorState(NONE); 
             
     //infinite loop running after initialization
     while(run) {
@@ -164,7 +163,9 @@
         
         //if bmag data string is available
         if(BMAG_Data_Rdy) {
-
+            
+            dbg.printf("GGA_Fix_Present val: %d\r\n", GGA_Fix_Present);
+            
             //if mag data is present but gps data is not
             if(magCntWithoutGpsData < 100) {
                 magCntWithoutGpsData += 1;
@@ -381,14 +382,21 @@
                 greenLed = 0;
                 redLed = 1;
             }
+            
+            if(GpsCntWithoutMagData > 20){
+                //Missing MAG data prompt
+                dispTxtHandler.setErrorState(NO_MAG_DATA);
+                greenLed = 0;
+                redLed = 1;
+            }
                     
-           if(GpsCntWithoutMagData > 10){
-                
-                dispTxtHandler.setErrorState(NO_MAG_DATA);     
-                redLed = 1;
-                greenLed = 0; 
-                                     
-            }                       
+            if((GGA_Fix_Present && GpsCntWithoutMagData < 20) || (magTimeSetManually && GpsCntWithoutMagData < 20)){
+                //GGA fix LED indicator / time set manually unless battery is low
+                if(dispTxtHandler.getErrorState() != BATTERY_LOW){
+                    greenLed = 1;
+                    redLed = 0;                    
+                }     
+            }                        
             
             
             //clearing flags