Extracted GPS handling into helper function that allows error propagation

This commit is contained in:
jakeg00dwin 2024-10-04 02:57:45 -07:00
parent 14f6f68eaa
commit 37664251df
1 changed files with 15 additions and 0 deletions

View File

@ -167,6 +167,21 @@ void Radio_Main(MSG *msg_out, MSG *msg_in) {
}
//Returns the result type and updates the global values(coordinates).
uint8_t GPS_GetCoordinates() {
Serial.println("GPS_GetCoordinates()");
if (!gpsSerial.available()) {
Serial.println("INFO: GPS not availble.");
return NoReply;
}
gps.encode(gpsSerial.read()); // Decode the GPS data
if (gps.location.isValid()) { // Check if GPS location data is valid
msg_out.latitude = gps.location.lat();
msg_out.longitude = gps.location.lat();
}
return Ok;
}
void setup(void) {
// Initialize Serial Communication for debugging