Skip to content

Commit 7c3e551

Browse files
authored
Merge pull request #87 from sparkfun/StatusQuery
Add status report when ~ is received
2 parents 36356bd + 3a89ac9 commit 7c3e551

File tree

5 files changed

+96
-5
lines changed

5 files changed

+96
-5
lines changed

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
const int FIRMWARE_VERSION_MAJOR = 1;
5151
const int FIRMWARE_VERSION_MINOR = 11;
5252

53-
#define COMPILE_WIFI //Comment out to remove all WiFi functionality
54-
#define COMPILE_BT //Comment out to disable all Bluetooth
53+
//#define COMPILE_WIFI //Comment out to remove all WiFi functionality
54+
//#define COMPILE_BT //Comment out to disable all Bluetooth
5555
#define ENABLE_DEVELOPER //Uncomment this line to enable special developer modes (don't check power button at startup)
5656

5757
//Define the RTK board identifier:
@@ -461,8 +461,7 @@ void loop()
461461

462462
reportHeap(); //If debug enabled, report free heap
463463

464-
//Menu system via ESP32 USB connection
465-
if (Serial.available()) menuMain(); //Present user menu
464+
updateSerial(); //Menu system via ESP32 USB connection
466465

467466
//Convert current system time to minutes. This is used in F9PSerialReadTask()/updateLogs() to see if we are within max log window.
468467
systemTime_minutes = millis() / 1000L / 60;

Firmware/RTK_Surveyor/System.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ void createNMEASentence(customNmeaType_e textID, char *nmeaMessage, char *textMe
737737
const uint8_t totalNumberOfSentences = 1;
738738
const uint8_t sentenceNumber = 1;
739739

740-
char nmeaTxt[82]; //Max NMEA sentence length is 82
740+
char nmeaTxt[200]; //Max NMEA sentence length is 82
741741
sprintf(nmeaTxt, "$GNTXT,%02d,%02d,%02d,%s*", totalNumberOfSentences, sentenceNumber, textID, textMessage);
742742

743743
//From: http://engineeringnotes.blogspot.com/2015/02/generate-crc-for-nmea-strings-arduino.html

Firmware/RTK_Surveyor/menuMain.ino

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
//Check to see if we've received serial over USB
2+
//Report status if ~ received, otherwise present config menu
3+
void updateSerial()
4+
{
5+
if (Serial.available())
6+
{
7+
byte incoming = Serial.read();
8+
9+
if(incoming == '~')
10+
{
11+
//Output custom GNTXT message with all current system data
12+
printCurrentConditionsNMEA();
13+
}
14+
else
15+
menuMain(); //Present user menu
16+
}
17+
}
18+
119
//Display the options
220
//If user doesn't respond within a few seconds, return to main loop
321
void menuMain()

Firmware/RTK_Surveyor/menuSystem.ino

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,3 +321,76 @@ void printCurrentConditions()
321321
Serial.println();
322322
}
323323
}
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+
}

Firmware/RTK_Surveyor/settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ typedef enum
8989
CUSTOM_NMEA_TYPE_EVENT,
9090
CUSTOM_NMEA_TYPE_SYSTEM_VERSION,
9191
CUSTOM_NMEA_TYPE_ZED_VERSION,
92+
CUSTOM_NMEA_TYPE_STATUS,
9293
} customNmeaType_e;
9394

9495
//Freeze and blink LEDs if we hit a bad error

0 commit comments

Comments
 (0)