Snorktracker
 All Data Structures Files Functions Variables Macros Pages
Public Member Functions | Data Fields | Protected Member Functions
MyGps Class Reference

#include <Gps.h>

Public Member Functions

 MyGps ()
 
void clear ()
 
bool setRunStatus (const String &data)
 
bool setFixStatus (const String &data)
 
bool setDateTime (const String &data)
 
bool setLatitude (const String &data)
 
bool setLongitude (const String &data)
 
bool setAltitude (const String &data)
 
bool setSpeed (const String &data)
 
bool setCourse (const String &data)
 
bool setFixMode (const String &data)
 
bool setHdop (const String &data)
 
bool setPdop (const String &data)
 
bool setVdop (const String &data)
 
bool setSatellitesInView (const String &data)
 
bool setSatellitesUsed (const String &data)
 
String longitudeString ()
 
String latitudeString ()
 
String altitudeString ()
 
String kmphString ()
 
String satellitesString ()
 
String courseString ()
 
bool getAsGpsJson (char *gpsJson)
 

Data Fields

bool runStatus
 Is the gps modul running?
 
bool fixStatus
 Are the gps is valid received?
 
MyDate date
 The received gps utc date.
 
MyTime time
 The received gps utc time.
 
MyLocation location
 The gps position.
 
double altitude
 The current height.
 
double speed
 The detected moving speed.
 
double course
 The calculated course.
 
int fixMode
 Precission of the gps data.
 
double pdop
 Dilution of precision.
 
double hdop
 Horizontal dilution of precision.
 
double vdop
 Vertical dilution of precision.
 
int satellitesInView
 Sattelites in the View.
 
int satellitesUsed
 Sattelites used for gps position.
 

Protected Member Functions

bool parse (bool &b, const String &data)
 
bool parse (int &i, const String &data)
 
bool parse (double &d, const String &data)
 

Detailed Description

GPS data class with all the data items from the GPS message from the SIM808 module

Definition at line 129 of file Gps.h.

Constructor & Destructor Documentation

MyGps::MyGps ( )

Constructor

Definition at line 392 of file Gps.h.

393  : runStatus(false)
394  , fixStatus(false)
395  , altitude(0)
396  , speed(0)
397  , course(0)
398  , fixMode(0)
399  , hdop(0)
400  , pdop(0)
401  , vdop(0)
402  , satellitesInView(0)
403  , satellitesUsed(0)
404 {
405 }
double vdop
Vertical dilution of precision.
Definition: Gps.h:143
double altitude
The current height.
Definition: Gps.h:137
double pdop
Dilution of precision.
Definition: Gps.h:141
int fixMode
Precission of the gps data.
Definition: Gps.h:140
double hdop
Horizontal dilution of precision.
Definition: Gps.h:142
int satellitesInView
Sattelites in the View.
Definition: Gps.h:144
int satellitesUsed
Sattelites used for gps position.
Definition: Gps.h:145
double speed
The detected moving speed.
Definition: Gps.h:138
bool fixStatus
Are the gps is valid received?
Definition: Gps.h:133
double course
The calculated course.
Definition: Gps.h:139
bool runStatus
Is the gps modul running?
Definition: Gps.h:132

Member Function Documentation

String MyGps::altitudeString ( )

Returns the altitude as a string

Definition at line 552 of file Gps.h.

References altitude.

Referenced by MySmsCmd::cmdStatus(), getAsGpsJson(), MyGsmGps::getGps(), MyWebServer::handleLoadInfoInfo(), and MyWebServer::handleLoadMainInfo().

553 {
554  return String(altitude, 0);
555 }
double altitude
The current height.
Definition: Gps.h:137
void MyGps::clear ( )

Reset the values.

Definition at line 408 of file Gps.h.

References altitude, MyLocation::clear(), MyDate::clear(), MyTime::clear(), course, date, fixMode, fixStatus, hdop, location, pdop, runStatus, satellitesInView, satellitesUsed, speed, time, and vdop.

Referenced by MyGsmSim808::getGps(), and MyGsmSim808::getGsmGps().

409 {
410  date.clear();
411  time.clear();
412  location.clear();
413  runStatus = false;
414  fixStatus = false;
415  altitude = 0.0;
416  speed = 0.0;
417  course = 0.0;
418  fixMode = 0;
419  pdop = 0.0;
420  hdop = 0.0;
421  vdop = 0.0;
422  satellitesInView = 0;
423  satellitesUsed = 0;
424 }
void clear()
Definition: Gps.h:361
double vdop
Vertical dilution of precision.
Definition: Gps.h:143
double altitude
The current height.
Definition: Gps.h:137
double pdop
Dilution of precision.
Definition: Gps.h:141
int fixMode
Precission of the gps data.
Definition: Gps.h:140
void clear()
Definition: Gps.h:331
double hdop
Horizontal dilution of precision.
Definition: Gps.h:142
int satellitesInView
Sattelites in the View.
Definition: Gps.h:144
MyLocation location
The gps position.
Definition: Gps.h:136
int satellitesUsed
Sattelites used for gps position.
Definition: Gps.h:145
MyDate date
The received gps utc date.
Definition: Gps.h:134
double speed
The detected moving speed.
Definition: Gps.h:138
MyTime time
The received gps utc time.
Definition: Gps.h:135
bool fixStatus
Are the gps is valid received?
Definition: Gps.h:133
void clear()
Definition: Gps.h:241
double course
The calculated course.
Definition: Gps.h:139
bool runStatus
Is the gps modul running?
Definition: Gps.h:132
String MyGps::courseString ( )

Returns the course as a string

Definition at line 570 of file Gps.h.

References course.

Referenced by MyGsmGps::getGps(), and MyWebServer::handleLoadInfoInfo().

571 {
572  return String(course);
573 }
double course
The calculated course.
Definition: Gps.h:139
bool MyGps::getAsGpsJson ( char *  gpsJson)

Returns the core gps data as json array

Definition at line 576 of file Gps.h.

References altitudeString(), fixStatus, kmphString(), latitudeString(), and longitudeString().

Referenced by MyMqtt::handleClient().

577 {
578  if (fixStatus) {
579  String gps;
580 
581  gps += "{";
582  gps += "\"long\":\"" + longitudeString() + "\",";
583  gps += "\"lat\":\"" + latitudeString() + "\",";
584  gps += "\"alt\":\"" + altitudeString() + "\",";
585  gps += "\"kmph\":\"" + kmphString() + "\"";
586  gps += "}";
587 
588  gps.toCharArray(gpsJson, (gps.length() + 1));
589  return true;
590  }
591  return false;
592 }
String altitudeString()
Definition: Gps.h:552
String longitudeString()
Definition: Gps.h:540
String kmphString()
Definition: Gps.h:558
String latitudeString()
Definition: Gps.h:546
bool fixStatus
Are the gps is valid received?
Definition: Gps.h:133
String MyGps::kmphString ( )

Returns the kmph as a string

Definition at line 558 of file Gps.h.

References speed.

Referenced by MySmsCmd::cmdStatus(), getAsGpsJson(), MyGsmGps::getGps(), MyWebServer::handleLoadInfoInfo(), and MyWebServer::handleLoadMainInfo().

559 {
560  return String(speed, 0);
561 }
double speed
The detected moving speed.
Definition: Gps.h:138
String MyGps::latitudeString ( )

Returns the latitude as a string

Definition at line 546 of file Gps.h.

References MyLocation::latitudeString(), and location.

Referenced by getAsGpsJson(), MySmsCmd::getGoogleMapGpsUrl(), MyGsmGps::getGps(), MyGsmGps::getGpsFromGsm(), MyWebServer::handleLoadInfoInfo(), and MyWebServer::handleLoadMainInfo().

547 {
548  return location.latitudeString();
549 }
String latitudeString()
Definition: Gps.h:313
MyLocation location
The gps position.
Definition: Gps.h:136
String MyGps::longitudeString ( )

Returns the longitude as a string

Definition at line 540 of file Gps.h.

References location, and MyLocation::longitudeString().

Referenced by getAsGpsJson(), MySmsCmd::getGoogleMapGpsUrl(), MyGsmGps::getGps(), MyGsmGps::getGpsFromGsm(), MyWebServer::handleLoadInfoInfo(), and MyWebServer::handleLoadMainInfo().

541 {
542  return location.longitudeString();
543 }
String longitudeString()
Definition: Gps.h:307
MyLocation location
The gps position.
Definition: Gps.h:136
bool MyGps::parse ( bool &  b,
const String &  data 
)
protected

Parse a bool value from a string '0' or '1'

Definition at line 427 of file Gps.h.

Referenced by setAltitude(), setCourse(), setDateTime(), setFixMode(), setFixStatus(), setHdop(), setPdop(), setRunStatus(), setSatellitesInView(), setSatellitesUsed(), setSpeed(), and setVdop().

428 {
429  if (data == F("0")) {
430  b = false;
431  return true;
432  } else if (data == F("1")) {
433  b = true;
434  return true;
435  }
436  return false;
437 }
bool MyGps::parse ( int &  i,
const String &  data 
)
protected

Parse a int value from a string

Definition at line 440 of file Gps.h.

441 {
442  i = atol(data.c_str());
443  return true;
444 }
bool MyGps::parse ( double &  d,
const String &  data 
)
protected

Parse a double value from a string

Definition at line 447 of file Gps.h.

448 {
449  d = atof(data.c_str());
450  return true;
451 }
String MyGps::satellitesString ( )

Returns the satellites as a string

Definition at line 564 of file Gps.h.

References satellitesUsed.

Referenced by MySmsCmd::cmdStatus(), MyGsmGps::getGps(), MyWebServer::handleLoadInfoInfo(), and MyWebServer::handleLoadMainInfo().

565 {
566  return String(satellitesUsed);
567 }
int satellitesUsed
Sattelites used for gps position.
Definition: Gps.h:145
bool MyGps::setAltitude ( const String &  data)

Sets the altitude from the data string

Definition at line 486 of file Gps.h.

References altitude, and parse().

Referenced by MyGsmSim808::getGps().

487 {
488  return parse(altitude, data);
489 }
bool parse(bool &b, const String &data)
Definition: Gps.h:427
double altitude
The current height.
Definition: Gps.h:137
bool MyGps::setCourse ( const String &  data)

Sets the course value from the data string

Definition at line 498 of file Gps.h.

References course, and parse().

Referenced by MyGsmSim808::getGps().

499 {
500  return parse(course, data);
501 }
bool parse(bool &b, const String &data)
Definition: Gps.h:427
double course
The calculated course.
Definition: Gps.h:139
bool MyGps::setDateTime ( const String &  data)

Sets the date and time from the data string

Definition at line 466 of file Gps.h.

References MyDate::date, date, parse(), MyTime::time, and time.

Referenced by MyGsmSim808::getGps(), and MyGsmSim808::getGsmGps().

467 {
468  parse(date.date, data.substring(0, 8));
469  parse(time.time, data.substring(8));
470  return true;
471 }
bool parse(bool &b, const String &data)
Definition: Gps.h:427
int time
Time in the form of HoursMinutesSecons i.e. 120135.
Definition: Gps.h:101
int date
Date in the form of YearMonthDay i.e. 20170115.
Definition: Gps.h:77
MyDate date
The received gps utc date.
Definition: Gps.h:134
MyTime time
The received gps utc time.
Definition: Gps.h:135
bool MyGps::setFixMode ( const String &  data)

Sets the fix mode from the data string

Definition at line 504 of file Gps.h.

References fixMode, and parse().

Referenced by MyGsmSim808::getGps().

505 {
506  return parse(fixMode, data);
507 }
bool parse(bool &b, const String &data)
Definition: Gps.h:427
int fixMode
Precission of the gps data.
Definition: Gps.h:140
bool MyGps::setFixStatus ( const String &  data)

Sets the fix status from the data string

Definition at line 460 of file Gps.h.

References fixStatus, and parse().

Referenced by MyGsmSim808::getGps().

461 {
462  return parse(fixStatus, data);
463 }
bool parse(bool &b, const String &data)
Definition: Gps.h:427
bool fixStatus
Are the gps is valid received?
Definition: Gps.h:133
bool MyGps::setHdop ( const String &  data)

Sets the hdop mode from the data string

Definition at line 516 of file Gps.h.

References hdop, and parse().

Referenced by MyGsmSim808::getGps().

517 {
518  return parse(hdop, data);
519 }
bool parse(bool &b, const String &data)
Definition: Gps.h:427
double hdop
Horizontal dilution of precision.
Definition: Gps.h:142
bool MyGps::setLatitude ( const String &  data)

Set the latitude from the data string

Definition at line 474 of file Gps.h.

References MyLocation::latitude_, location, and MyDegrees::set().

Referenced by MyGsmSim808::getGps(), and MyGsmSim808::getGsmGps().

475 {
476  return location.latitude_.set(data);
477 }
bool set(const String &data)
Definition: Gps.h:217
MyDegrees latitude_
Latitude.
Definition: Gps.h:50
MyLocation location
The gps position.
Definition: Gps.h:136
bool MyGps::setLongitude ( const String &  data)

Sets the longitude from the data string

Definition at line 480 of file Gps.h.

References location, MyLocation::longitude_, and MyDegrees::set().

Referenced by MyGsmSim808::getGps(), and MyGsmSim808::getGsmGps().

481 {
482  return location.longitude_.set(data);
483 }
bool set(const String &data)
Definition: Gps.h:217
MyLocation location
The gps position.
Definition: Gps.h:136
MyDegrees longitude_
Longitude.
Definition: Gps.h:51
bool MyGps::setPdop ( const String &  data)

Sets the pdop mode from the data string

Definition at line 510 of file Gps.h.

References parse(), and pdop.

Referenced by MyGsmSim808::getGps().

511 {
512  return parse(pdop, data);
513 }
bool parse(bool &b, const String &data)
Definition: Gps.h:427
double pdop
Dilution of precision.
Definition: Gps.h:141
bool MyGps::setRunStatus ( const String &  data)

Sets the run status from the data string

Definition at line 454 of file Gps.h.

References parse(), and runStatus.

Referenced by MyGsmSim808::getGps().

455 {
456  return parse(runStatus, data);
457 }
bool parse(bool &b, const String &data)
Definition: Gps.h:427
bool runStatus
Is the gps modul running?
Definition: Gps.h:132
bool MyGps::setSatellitesInView ( const String &  data)

Sets the satellites in view value from the data string

Definition at line 528 of file Gps.h.

References parse(), and satellitesInView.

Referenced by MyGsmSim808::getGps().

529 {
530  return parse(satellitesInView, data);
531 }
bool parse(bool &b, const String &data)
Definition: Gps.h:427
int satellitesInView
Sattelites in the View.
Definition: Gps.h:144
bool MyGps::setSatellitesUsed ( const String &  data)

Sets the satellites used value from the data string

Definition at line 534 of file Gps.h.

References parse(), and satellitesUsed.

Referenced by MyGsmSim808::getGps().

535 {
536  return parse(satellitesUsed, data);
537 }
bool parse(bool &b, const String &data)
Definition: Gps.h:427
int satellitesUsed
Sattelites used for gps position.
Definition: Gps.h:145
bool MyGps::setSpeed ( const String &  data)

Sets the speed value from the data string

Definition at line 492 of file Gps.h.

References parse(), and speed.

Referenced by MyGsmSim808::getGps().

493 {
494  return parse(speed, data);
495 }
bool parse(bool &b, const String &data)
Definition: Gps.h:427
double speed
The detected moving speed.
Definition: Gps.h:138
bool MyGps::setVdop ( const String &  data)

Sets the vdop mode from the data string

Definition at line 522 of file Gps.h.

References parse(), and vdop.

Referenced by MyGsmSim808::getGps().

523 {
524  return parse(vdop, data);
525 }
double vdop
Vertical dilution of precision.
Definition: Gps.h:143
bool parse(bool &b, const String &data)
Definition: Gps.h:427

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