LoRaWAN-Signal-Mapping/iot/main/gps.h

39 lines
1.1 KiB
C
Raw Permalink Normal View History

#pragma once
#include <SoftwareSerial.h>
#include "settings.h"
// A lightweight struct to hold location information.
// TinyGPS++ actually uses a *ton* of RAM so we can't keep the instance around as a global variable
2019-06-28 13:11:25 +00:00
// FUTURE: Rewrite this to use TinyGPS's integer system instead?
struct GPSLocation {
float lat;
float lng;
#ifdef SD_DEBUG_ENABLED
char time[20];
#endif
};
/**
* Initialises the connection to the GPS device.
*/
SoftwareSerial gps_begin();
/**
* Fetches new data from the GPS module.
* May take a moment, as the GPS device needs time to acquire a satellite fix.
*/
GPSLocation gps_fetch();
/**
* Ends the connection to the GPS device and puts it to sleep in order to save
* power.
* Note that the GPS device is connected directly to the power management
* system and so doesn't get turned off after each measurement, as it takes
* ~30s to reacquire a lock when it first starts up - hence why we put it to
* sleep instead.
* TODO: Connect the gps module to the timed power rail instead, as its; got an onboard battery.
*/
void gps_end(SoftwareSerial gps);