@@ -40,6 +40,12 @@ GPSHardware::~GPSHardware() {
40
40
* @returns True if the message was handled successfully, False otherwise.
41
41
*/
42
42
bool GPSHardware::Handle_GPSConfig (wippersnapper_gps_GPSConfig *gps_config) {
43
+ WS_DEBUG_PRINTLN (" [gps] Handling GPSConfig message..." );
44
+ if (gps_config == nullptr )
45
+ return false ;
46
+ // Set the polling period for GPS data
47
+ SetPollPeriod (gps_config->period );
48
+
43
49
// Attempt to decode the GPSConfig message
44
50
if (_driver_type == GPS_DRV_MTK) {
45
51
WS_DEBUG_PRINTLN (" [gps] Handling GPSConfig for MediaTek driver..." );
@@ -206,6 +212,8 @@ bool GPSHardware::DetectMediatek() {
206
212
return false ;
207
213
}
208
214
_driver_type = GPS_DRV_MTK;
215
+ _nmea_baud_rate = DEFAULT_MTK_NMEA_BAUD_RATE;
216
+ _nmea_update_rate = DEFAULT_MTK_NMEA_UPDATE_RATE;
209
217
return true ;
210
218
}
211
219
@@ -231,7 +239,13 @@ bool GPSHardware::BuildPmtkAck(char *msg_cmd, char *msg_resp) {
231
239
* @param poll_period
232
240
* The polling period in milliseconds.
233
241
*/
234
- void GPSHardware::SetPollPeriod (ulong poll_period) { _period = poll_period; }
242
+ void GPSHardware::SetPollPeriod (ulong poll_period) {
243
+ if (poll_period < 0 ) {
244
+ _period = 0 ;
245
+ return ;
246
+ }
247
+ _period = (unsigned long )(poll_period * 1000 .0f );
248
+ }
235
249
236
250
/* !
237
251
* @brief Sets the previous polling period for GPS data.
@@ -252,4 +266,40 @@ ulong GPSHardware::GetPollPeriod() { return _period; }
252
266
* @brief Gets the previous polling period for GPS data.
253
267
* @returns The previous polling period in milliseconds.
254
268
*/
255
- ulong GPSHardware::GetPollPeriodPrv () { return _period_prv; }
269
+ ulong GPSHardware::GetPollPeriodPrv () { return _period_prv; }
270
+
271
+ /* !
272
+ * @brief Returns the Adafruit_GPS instance.
273
+ * @returns Pointer to the Adafruit_GPS instance.
274
+ */
275
+ Adafruit_GPS *GPSHardware::GetAdaGps () { return _ada_gps; }
276
+
277
+ /* !
278
+ * @brief Sets the NMEA update rate for GPS data.
279
+ * @param nmea_update_rate
280
+ * The NMEA update rate, in Hz.
281
+ */
282
+ void GPSHardware::SetNmeaUpdateRate (int nmea_update_rate) {
283
+ _nmea_update_rate = nmea_update_rate;
284
+ }
285
+
286
+ /* !
287
+ * @brief Returns the NMEA port update rate for GPS data.
288
+ * @returns The NMEA update rate, in Hz.
289
+ */
290
+ int GPSHardware::GetNmeaUpdateRate () { return _nmea_update_rate; }
291
+
292
+ /* !
293
+ * @brief Sets the NMEA baud rate for GPS data.
294
+ * @param nmea_baud_rate
295
+ * The NMEA baud rate, in bits per second.
296
+ */
297
+ void GPSHardware::SetNmeaBaudRate (int nmea_baud_rate) {
298
+ _nmea_baud_rate = nmea_baud_rate;
299
+ }
300
+
301
+ /* !
302
+ * @brief Returns the NMEA port baud rate for GPS data.
303
+ * @returns The NMEA baud rate, in bits per second.
304
+ */
305
+ int GPSHardware::GetNmeaBaudRate () { return _nmea_baud_rate; }
0 commit comments