perif::GPS class

A GPS peripheral. Tested on Adafruit's Ultimate GPS breakout.

Base classes

class UARTPerif

Constructors, destructors, conversion operators

GPS(uint8_t updateInterval = 2) explicit

Public functions

auto begin() -> bool override
auto isConnected() -> bool override
void update()
void registerHook(function<void(DevMap&)>&& hook)

Public variables

DevMap data
list<function<void(DevMap&)>> hooks

Protected functions

auto getTimer() -> Timer&

Protected variables

int baud
uint8_t txPin
uint8_t rxPin
Timer timer

Private functions

void updateData() override
void representData() override

Function documentation

perif::GPS::GPS(uint8_t updateInterval = 2) explicit

Parameters
updateInterval the update interval in seconds

Explicit value constructor for a GPS sensor.

bool perif::GPS::begin() override

Returns whether the peripheral initialization succeeded

Performs initialization of a peripheral. Necessary to avoid initialization in the constructor which causes many side effects.

bool perif::GPS::isConnected() override

Returns if the sensor is connected

Returns whether the sensor is connected or not.

void perif::GPS::update()

Performs a manual update of peripheral data and notifies observers.

void perif::GPS::registerHook(function<void(DevMap&)>&& hook)

Parameters
hook the observer function

Registers a hook for obtaining sensor data on update in Json format.

Timer& perif::GPS::getTimer() protected

Returns a timer reference

Obtains a reference to this peripheral's timer.

void perif::GPS::updateData() override private

Updates sensor data. Subclasses should maintain a reference to the data obtained from this function so it can be provided to observers.

void perif::GPS::representData() override private

The representation of this peripheral's data in a meaningful way for debugging, caching, and database operations.

Variable documentation

DevMap perif::GPS::data

The key-value mapping of peripheral data.

list<function<void(DevMap&)>> perif::GPS::hooks

Hooks registered to this peripheral so observers can be notified of any necessary changes.

int perif::GPS::baud protected

The baud rate.

uint8_t perif::GPS::txPin protected

The transmit GPIO pins.

uint8_t perif::GPS::rxPin protected

The receive GPIO pins.

Timer perif::GPS::timer protected

A timer for managing peripheral updates.