Skip to content

Add status report when ~ is received #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Firmware/RTK_Surveyor/RTK_Surveyor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
const int FIRMWARE_VERSION_MAJOR = 1;
const int FIRMWARE_VERSION_MINOR = 11;

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

//Define the RTK board identifier:
Expand Down Expand Up @@ -461,8 +461,7 @@ void loop()

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

//Menu system via ESP32 USB connection
if (Serial.available()) menuMain(); //Present user menu
updateSerial(); //Menu system via ESP32 USB connection

//Convert current system time to minutes. This is used in F9PSerialReadTask()/updateLogs() to see if we are within max log window.
systemTime_minutes = millis() / 1000L / 60;
Expand Down
2 changes: 1 addition & 1 deletion Firmware/RTK_Surveyor/System.ino
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ void createNMEASentence(customNmeaType_e textID, char *nmeaMessage, char *textMe
const uint8_t totalNumberOfSentences = 1;
const uint8_t sentenceNumber = 1;

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

//From: http://engineeringnotes.blogspot.com/2015/02/generate-crc-for-nmea-strings-arduino.html
Expand Down
18 changes: 18 additions & 0 deletions Firmware/RTK_Surveyor/menuMain.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
//Check to see if we've received serial over USB
//Report status if ~ received, otherwise present config menu
void updateSerial()
{
if (Serial.available())
{
byte incoming = Serial.read();

if(incoming == '~')
{
//Output custom GNTXT message with all current system data
printCurrentConditionsNMEA();
}
else
menuMain(); //Present user menu
}
}

//Display the options
//If user doesn't respond within a few seconds, return to main loop
void menuMain()
Expand Down
73 changes: 73 additions & 0 deletions Firmware/RTK_Surveyor/menuSystem.ino
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,76 @@ void printCurrentConditions()
Serial.println();
}
}

void printCurrentConditionsNMEA()
{
if (online.gnss == true)
{
// First, let's collect the position data
uint8_t month = i2cGNSS.getMonth();
uint8_t day = i2cGNSS.getDay();
int year = i2cGNSS.getYear() % 2000; //Limit to last two digits

uint8_t hour = i2cGNSS.getHour();
uint8_t minute = i2cGNSS.getMinute();
uint8_t second = i2cGNSS.getSecond();
int mseconds = ceil(i2cGNSS.getMillisecond() / 10.0); //Limit to first two digits

int32_t latitude = i2cGNSS.getHighResLatitude();
int8_t latitudeHp = i2cGNSS.getHighResLatitudeHp();
int32_t longitude = i2cGNSS.getHighResLongitude();
int8_t longitudeHp = i2cGNSS.getHighResLongitudeHp();
int32_t ellipsoid = i2cGNSS.getElipsoid();
int8_t ellipsoidHp = i2cGNSS.getElipsoidHp();
int32_t msl = i2cGNSS.getMeanSeaLevel();
int8_t mslHp = i2cGNSS.getMeanSeaLevelHp();
uint32_t accuracy = i2cGNSS.getHorizontalAccuracy();
byte siv = i2cGNSS.getSIV();
byte fixType = i2cGNSS.getFixType();
byte rtkSolution = i2cGNSS.getCarrierSolutionType();

// Defines storage for the lat and lon as double
double d_lat; // latitude
double d_lon; // longitude

// Assemble the high precision latitude and longitude
d_lat = ((double)latitude) / 10000000.0; // Convert latitude from degrees * 10^-7 to degrees
d_lat += ((double)latitudeHp) / 1000000000.0; // Now add the high resolution component (degrees * 10^-9 )
d_lon = ((double)longitude) / 10000000.0; // Convert longitude from degrees * 10^-7 to degrees
d_lon += ((double)longitudeHp) / 1000000000.0; // Now add the high resolution component (degrees * 10^-9 )

//float f_ellipsoid;
float f_msl;
float f_accuracy;

//f_ellipsoid = (ellipsoid * 10) + ellipsoidHp;
//f_ellipsoid = f_ellipsoid / 10000.0; // Convert from mm * 10^-1 to m

f_msl = (msl * 10) + mslHp;
f_msl = f_msl / 10000.0; // Convert from mm * 10^-1 to m

f_accuracy = accuracy;
f_accuracy = f_accuracy / 10000.0; // Convert from mm * 10^-1 to m

char systemStatus[100];
sprintf(systemStatus, "%02d%02d%02d.%02d,%02d%02d%02d,%0.3f,%d,%0.9f,%0.9f,%0.2f,%d,%d,%d",
hour, minute, second, mseconds,
day, month, year,
f_accuracy, siv,
d_lat, d_lon,
f_msl,
fixType, rtkSolution,
battLevel
);

char nmeaMessage[100]; //Max NMEA sentence length is 82
createNMEASentence(CUSTOM_NMEA_TYPE_STATUS, nmeaMessage, systemStatus); //textID, buffer, text
Serial.println(nmeaMessage);
}
else
{
char nmeaMessage[100]; //Max NMEA sentence length is 82
createNMEASentence(CUSTOM_NMEA_TYPE_STATUS, nmeaMessage, (char *)"OFFLINE"); //textID, buffer, text
Serial.println(nmeaMessage);
}
}
1 change: 1 addition & 0 deletions Firmware/RTK_Surveyor/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ typedef enum
CUSTOM_NMEA_TYPE_EVENT,
CUSTOM_NMEA_TYPE_SYSTEM_VERSION,
CUSTOM_NMEA_TYPE_ZED_VERSION,
CUSTOM_NMEA_TYPE_STATUS,
} customNmeaType_e;

//Freeze and blink LEDs if we hit a bad error
Expand Down