GPSNet
Classes | Public Member Functions | Protected Member Functions | List of all members
GPSNet Class Reference

Manage reception, storage and update transmission of GPSReports. More...

#include <GPSNet.h>

Public Member Functions

 GPSNet ()
 
void newReport (GPSReport *report)
 
void receivedReport (GPSReport *report)
 
uint8_t numReports ()
 
GPSReportreportWithId (uint8_t *id, uint8_t *index=NULL)
 
GPSReportreportWithIndex (uint8_t index)
 
void printReports ()
 
void poll ()
 
void setTransmitFunction (void(*transmitFunction)(GPSNet *net, GPSReport *report))
 

Protected Member Functions

void unlinkReportWithIndex (uint8_t index)
 
void linkReportWithIndexAfterIndex (uint8_t index, uint8_t after)
 
void scheduleReportForUpdate (uint8_t index)
 
void transmitNextUpdate ()
 
virtual void transmitUpdate (GPSReport *report)
 
void evaluateReceptionRate ()
 
void perSecondTasks ()
 

Detailed Description

Manage reception, storage and update transmission of GPSReports.

GPSNet implements a radio broadcast mesh network among a number of GPS+radio equipped nodes, such that all nodes in the network know the GPS position of all other nodes.

Examples:
gpsnet.ino.

Constructor & Destructor Documentation

GPSNet::GPSNet ( )

Constructor Intialises most members to 0

Member Function Documentation

void GPSNet::evaluateReceptionRate ( )
protected

Recalculate _updateTransmitInterval Based on the average of the recent message arrival rate, with a moving window over a time period given by GPSNET_STATISTICS_WINDOW_SECS.

Referenced by perSecondTasks().

void GPSNet::linkReportWithIndexAfterIndex ( uint8_t  index,
uint8_t  after 
)
protected

Link a report into the report list Connects the report from the doubly linked list of reports in _reports so it apears after the report whose index is given as after param[in] index The index of the report to link in param[in]after the index of the report it is to appear after

Referenced by newReport(), and scheduleReportForUpdate().

void GPSNet::newReport ( GPSReport report)

Tells GPSNet about a new report from the local GPS You should only call this when there is a new position report that is significantly different from the previous position. See GPSReport::isCloseTo() for assistance)

Parameters
[in]reportPointer to the new report
Examples:
gpsnet.ino.

References GPSReport::id, GPSReport::isLaterThan(), linkReportWithIndexAfterIndex(), reportWithId(), reportWithIndex(), and scheduleReportForUpdate().

Referenced by receivedReport().

uint8_t GPSNet::numReports ( )

The number of currently known node reports

Returns
The number of currently known node reports
Examples:
gpsnet.ino.
void GPSNet::perSecondTasks ( )
protected

Execute various housekeeping tasks required to be done once per second. Called automatically by poll() once per second.

References evaluateReceptionRate().

Referenced by poll().

void GPSNet::poll ( )

Do the internal work of the GPSNet node You must call this frequently and often, but at least once a second. It is recomended that this be called in the idle loop of the main sketch. The transmitFunction may be called from within poll().

Examples:
gpsnet.ino.

References perSecondTasks(), and transmitNextUpdate().

void GPSNet::printReports ( )

Prints a basic ASCII dump of all current reports to the Serial port

void GPSNet::receivedReport ( GPSReport report)

Tells GPSNet about a new report received by radio from a remote node. Reports entered this way are used to update the reception rate statistics.

Parameters
[in]reportPointer to the report
Examples:
gpsnet.ino.

References GPSReport::hops, and newReport().

GPSReport * GPSNet::reportWithId ( uint8_t *  id,
uint8_t *  index = NULL 
)

Fetch a report with a given node ID, and optionally its index

Parameters
[in]idPointer to the node ID to match
[in,out]indexIf index is not NULL it points to a uint8_t that is to be set to the index of the matching node (if found)
Returns
Pointer to the matching report if found, else NULL

Referenced by newReport().

GPSReport * GPSNet::reportWithIndex ( uint8_t  index)

Fetch the Report with the given index

Parameters
[in]indexThe index of the report inthe GPSNet report list
Returns
Pointer to the Report at that index, if present, else NULL
Examples:
gpsnet.ino.

Referenced by newReport().

void GPSNet::scheduleReportForUpdate ( uint8_t  index)
protected

Schedules a report in the _reports list for the next update transmission It does this by moving it to the beginning of the linked list after the one indicated by _lastUpdatedReportIndex

References linkReportWithIndexAfterIndex(), and unlinkReportWithIndex().

Referenced by newReport().

void GPSNet::setTransmitFunction ( void(*)(GPSNet *net, GPSReport *report)  transmitFunction)

Tells GPSNet which function to call to broadcast an update report. The calling sketch should implement the transmitFunction in terms of its local radio interface

Parameters
[in]transmitFunctionPointer to a function to call when an update is to be transmitted. The function will be passed a pointer to this instance of GPSNet and the GPSReport to transmit
Examples:
gpsnet.ino.
void GPSNet::transmitNextUpdate ( )
protected

Transmits the next report scheduled for update. Calls transmitUpdate() and passes it the next report. Updates _lastUpdatedReportIndex to indicate the recently transmitted report

References transmitUpdate().

Referenced by poll().

void GPSNet::transmitUpdate ( GPSReport report)
protectedvirtual

Transmit an update. Caller can override this funciton, or else can set a callback function with setTransmitFunction()

Parameters
[in]reportThe report to be transmitted

Referenced by transmitNextUpdate().

void GPSNet::unlinkReportWithIndex ( uint8_t  index)
protected

Unlink a report from the report list Disconnects the report from the doubly linked list of reports in _reports

Parameters
[in]indexIndex of th report to unlink

Referenced by scheduleReportForUpdate().


The documentation for this class was generated from the following files: