From 37664251df8371789f985278d36060046bcdf18d Mon Sep 17 00:00:00 2001 From: jakeg00dwin Date: Fri, 4 Oct 2024 02:57:45 -0700 Subject: [PATCH] Extracted GPS handling into helper function that allows error propagation --- src/multi-tracker.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/multi-tracker.cpp b/src/multi-tracker.cpp index ec9f2d5..46f9823 100644 --- a/src/multi-tracker.cpp +++ b/src/multi-tracker.cpp @@ -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