GPSNet
|
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 () |
GPSReport * | reportWithId (uint8_t *id, uint8_t *index=NULL) |
GPSReport * | reportWithIndex (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 () |
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.
GPSNet::GPSNet | ( | ) |
Constructor Intialises most members to 0
|
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().
|
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)
[in] | report | Pointer to the new report |
References GPSReport::id, GPSReport::isLaterThan(), linkReportWithIndexAfterIndex(), reportWithId(), reportWithIndex(), and scheduleReportForUpdate().
Referenced by receivedReport().
uint8_t GPSNet::numReports | ( | ) |
The number of currently known node reports
|
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().
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.
[in] | report | Pointer to the report |
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
[in] | id | Pointer to the node ID to match |
[in,out] | index | If index is not NULL it points to a uint8_t that is to be set to the index of the matching node (if found) |
Referenced by newReport().
GPSReport * GPSNet::reportWithIndex | ( | uint8_t | index | ) |
Fetch the Report with the given index
[in] | index | The index of the report inthe GPSNet report list |
Referenced by newReport().
|
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().
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
[in] | transmitFunction | Pointer 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 |
|
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().
|
protectedvirtual |
Transmit an update. Caller can override this funciton, or else can set a callback function with setTransmitFunction()
[in] | report | The report to be transmitted |
Referenced by transmitNextUpdate().
|
protected |
Unlink a report from the report list Disconnects the report from the doubly linked list of reports in _reports
[in] | index | Index of th report to unlink |
Referenced by scheduleReportForUpdate().