generated from TDD-Templates/cmake_cpputest_template
Extracted GPS handling into helper function that allows error propagation
This commit is contained in:
parent
14f6f68eaa
commit
37664251df
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue