@@ -321,3 +321,76 @@ void printCurrentConditions()
321
321
Serial.println ();
322
322
}
323
323
}
324
+
325
+ void printCurrentConditionsNMEA ()
326
+ {
327
+ if (online.gnss == true )
328
+ {
329
+ // First, let's collect the position data
330
+ uint8_t month = i2cGNSS.getMonth ();
331
+ uint8_t day = i2cGNSS.getDay ();
332
+ int year = i2cGNSS.getYear () % 2000 ; // Limit to last two digits
333
+
334
+ uint8_t hour = i2cGNSS.getHour ();
335
+ uint8_t minute = i2cGNSS.getMinute ();
336
+ uint8_t second = i2cGNSS.getSecond ();
337
+ int mseconds = ceil (i2cGNSS.getMillisecond () / 10.0 ); // Limit to first two digits
338
+
339
+ int32_t latitude = i2cGNSS.getHighResLatitude ();
340
+ int8_t latitudeHp = i2cGNSS.getHighResLatitudeHp ();
341
+ int32_t longitude = i2cGNSS.getHighResLongitude ();
342
+ int8_t longitudeHp = i2cGNSS.getHighResLongitudeHp ();
343
+ int32_t ellipsoid = i2cGNSS.getElipsoid ();
344
+ int8_t ellipsoidHp = i2cGNSS.getElipsoidHp ();
345
+ int32_t msl = i2cGNSS.getMeanSeaLevel ();
346
+ int8_t mslHp = i2cGNSS.getMeanSeaLevelHp ();
347
+ uint32_t accuracy = i2cGNSS.getHorizontalAccuracy ();
348
+ byte siv = i2cGNSS.getSIV ();
349
+ byte fixType = i2cGNSS.getFixType ();
350
+ byte rtkSolution = i2cGNSS.getCarrierSolutionType ();
351
+
352
+ // Defines storage for the lat and lon as double
353
+ double d_lat; // latitude
354
+ double d_lon; // longitude
355
+
356
+ // Assemble the high precision latitude and longitude
357
+ d_lat = ((double )latitude) / 10000000.0 ; // Convert latitude from degrees * 10^-7 to degrees
358
+ d_lat += ((double )latitudeHp) / 1000000000.0 ; // Now add the high resolution component (degrees * 10^-9 )
359
+ d_lon = ((double )longitude) / 10000000.0 ; // Convert longitude from degrees * 10^-7 to degrees
360
+ d_lon += ((double )longitudeHp) / 1000000000.0 ; // Now add the high resolution component (degrees * 10^-9 )
361
+
362
+ // float f_ellipsoid;
363
+ float f_msl;
364
+ float f_accuracy;
365
+
366
+ // f_ellipsoid = (ellipsoid * 10) + ellipsoidHp;
367
+ // f_ellipsoid = f_ellipsoid / 10000.0; // Convert from mm * 10^-1 to m
368
+
369
+ f_msl = (msl * 10 ) + mslHp;
370
+ f_msl = f_msl / 10000.0 ; // Convert from mm * 10^-1 to m
371
+
372
+ f_accuracy = accuracy;
373
+ f_accuracy = f_accuracy / 10000.0 ; // Convert from mm * 10^-1 to m
374
+
375
+ char systemStatus[100 ];
376
+ sprintf (systemStatus, " %02d%02d%02d.%02d,%02d%02d%02d,%0.3f,%d,%0.9f,%0.9f,%0.2f,%d,%d,%d" ,
377
+ hour, minute, second, mseconds,
378
+ day, month, year,
379
+ f_accuracy, siv,
380
+ d_lat, d_lon,
381
+ f_msl,
382
+ fixType, rtkSolution,
383
+ battLevel
384
+ );
385
+
386
+ char nmeaMessage[100 ]; // Max NMEA sentence length is 82
387
+ createNMEASentence (CUSTOM_NMEA_TYPE_STATUS, nmeaMessage, systemStatus); // textID, buffer, text
388
+ Serial.println (nmeaMessage);
389
+ }
390
+ else
391
+ {
392
+ char nmeaMessage[100 ]; // Max NMEA sentence length is 82
393
+ createNMEASentence (CUSTOM_NMEA_TYPE_STATUS, nmeaMessage, (char *)" OFFLINE" ); // textID, buffer, text
394
+ Serial.println (nmeaMessage);
395
+ }
396
+ }
0 commit comments