Bath-Biodevices-Without-Borders / Bath-Biodevices-Without-Borders/System
Improve timeout for gpsInfo functions
- Dominant language
- C++
- Stars
- 1
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
# Improve timeout for gpsInfo functions
## Problem
When running the function, the GPS module will continuously attempt to make a connection with the GPS satellite constellation. However, if a connection cannot be made, the function should timeout after 10 seconds which was manually developed.
Here's the problem, the timeout does not seem to work all the time. An investigation needs to be conducted and then can the problem be solved.
## Current Operation
The function takes five parameters: a reference to a `TinyGPS` object, and pointers to four variables where the latitude, longitude, date, and time will be stored.
The function starts by making the Arduino listen to the GPS module by calling `gpsSerial.listen()`. It then checks if the Arduino is successfully listening to the GPS module by calling `gpsSerial.isListening()`.
Next, the function starts a timer using millis(), which returns the number of milliseconds since the Arduino board began running the current program. This timer is used to implement a timeout for the GPS module. If the GPS module doesn't provide data within a certain amount of time, the function will stop waiting for data.
The function then enters a loop that continues until data is available in the serial buffer or the GPS module times out. Inside the loop, the function checks if there is data available in the serial buffer by calling `gpsSerial.available()`. If data is available, the function reads the data by calling `gpsSerial.read()` and encodes it using `gps.encode()`.
Once the data is encoded, the function stops the loop, prints a message to the serial monitor for debugging purposes, and gets the latitude, longitude, date, and time from the GPS module. The latitude and longitude are rounded to two decimal places.
If the GPS module times out (i.e., if the current time is greater than the start time plus 10 seconds), the function prints a message to the serial monitor, stops the loop, and sets the latitude, longitude, date, and time to 0.
In summary, this function is used to get the current location and time from a GPS module, with a timeout to prevent the function from waiting indefinitely if the GPS module doesn't provide data.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the gpsInfo functions and tracing gpsSerial.listen(), isListening(), available(), read(), and the millis() timeout path. Reproduce a failed GPS connection and inspect whether the 10-second condition is reached consistently. Done means the functions reliably stop waiting after 10 seconds while retaining the documented output behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- arduino, cpp
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100