Snorktracker
 All Data Structures Files Functions Variables Macros Pages
Public Member Functions
MyGsmSim808 Class Reference

#include <Sim808.h>

Inheritance diagram for MyGsmSim808:

Public Member Functions

 MyGsmSim808 (Stream &stream)
 
bool getGps (MyGps &gps)
 
bool getGsmGps (MyGps &gps)
 
bool getSMS (SmsData &sms)
 
bool deleteSMS (long index)
 

Detailed Description

Extension class of the TinyGsmSim808 base class. Implements the special gps call and some sms functions.

Definition at line 47 of file Sim808.h.

Constructor & Destructor Documentation

MyGsmSim808::MyGsmSim808 ( Stream &  stream)

Constructor

Definition at line 61 of file Sim808.h.

62  : TinyGsmSim808(stream)
63 {
64 }

Member Function Documentation

bool MyGsmSim808::deleteSMS ( long  index)

Delete a specific sms from the sim card.

Definition at line 164 of file Sim808.h.

Referenced by MyGsmGps::deleteSMS().

165 {
166  sendAT(GF("+CMGD=") + String(index));
167  if (waitResponse() != 1) {
168  return false;
169  }
170 
171  return true;
172 }
bool MyGsmSim808::getGps ( MyGps gps)

Read and parse a gps information from the sim808 modul in the own MyGps data class

Definition at line 67 of file Sim808.h.

References MyGps::clear(), MyGps::fixStatus, MyGps::setAltitude(), MyGps::setCourse(), MyGps::setDateTime(), MyGps::setFixMode(), MyGps::setFixStatus(), MyGps::setHdop(), MyGps::setLatitude(), MyGps::setLongitude(), MyGps::setPdop(), MyGps::setRunStatus(), MyGps::setSatellitesInView(), MyGps::setSatellitesUsed(), MyGps::setSpeed(), and MyGps::setVdop().

Referenced by MyGsmGps::getGps().

68 {
69  gps.clear();
70 
71  sendAT(GF("+CGNSINF"));
72  if (waitResponse(GF(GSM_NL "+CGNSINF:")) != 1) {
73  return false;
74  }
75 
76  gps.setRunStatus (stream.readStringUntil(','));
77  gps.setFixStatus (stream.readStringUntil(','));
78  gps.setDateTime (stream.readStringUntil(','));
79  gps.setLatitude (stream.readStringUntil(','));
80  gps.setLongitude (stream.readStringUntil(','));
81  gps.setAltitude (stream.readStringUntil(','));
82  gps.setSpeed (stream.readStringUntil(','));
83  gps.setCourse (stream.readStringUntil(','));
84  gps.setFixMode (stream.readStringUntil(','));
85  /* reserved */ (stream.readStringUntil(','));
86  gps.setHdop (stream.readStringUntil(','));
87  gps.setPdop (stream.readStringUntil(','));
88  gps.setVdop (stream.readStringUntil(','));
89  /* reserved */ (stream.readStringUntil(','));
90  gps.setSatellitesInView (stream.readStringUntil(','));
91  gps.setSatellitesUsed (stream.readStringUntil(','));
92  stream.readStringUntil('\n');
93  waitResponse();
94 
95  return gps.fixStatus;
96 }
bool setLongitude(const String &data)
Definition: Gps.h:480
bool setAltitude(const String &data)
Definition: Gps.h:486
bool setHdop(const String &data)
Definition: Gps.h:516
bool setCourse(const String &data)
Definition: Gps.h:498
bool setVdop(const String &data)
Definition: Gps.h:522
bool setRunStatus(const String &data)
Definition: Gps.h:454
void clear()
Definition: Gps.h:408
bool setSatellitesInView(const String &data)
Definition: Gps.h:528
bool setDateTime(const String &data)
Definition: Gps.h:466
bool setSatellitesUsed(const String &data)
Definition: Gps.h:534
bool setFixMode(const String &data)
Definition: Gps.h:504
bool setSpeed(const String &data)
Definition: Gps.h:492
bool setLatitude(const String &data)
Definition: Gps.h:474
bool setPdop(const String &data)
Definition: Gps.h:510
bool fixStatus
Are the gps is valid received?
Definition: Gps.h:133
bool setFixStatus(const String &data)
Definition: Gps.h:460
bool MyGsmSim808::getGsmGps ( MyGps gps)

Read and parse a gsm-gps information from the sim808 modul in the own MyGps data class Sample: AT+CIPGSMLOC=1,1 +CIPGSMLOC: 0,23.7798,61.496052,2019/01/26,08:21:47

Definition at line 102 of file Sim808.h.

References MyGps::clear(), MyGps::fixStatus, MyGps::setDateTime(), MyGps::setLatitude(), and MyGps::setLongitude().

Referenced by MyGsmGps::getGpsFromGsm().

103 {
104  gps.clear();
105 
106  sendAT(GF("+CIPGSMLOC=1,1"));
107  if (waitResponse(10000L, GF(GSM_NL "+CIPGSMLOC:")) != 1) {
108  return false;
109  }
110 
111  String locationCode = stream.readStringUntil(',');
112  String longitude = stream.readStringUntil(',');
113  String latitude = stream.readStringUntil(',');
114  String gsmDate = stream.readStringUntil(',');
115  String gsmTime = stream.readStringUntil(',');
116  stream.readStringUntil('\n');
117  waitResponse();
118 
119  locationCode.trim();
120  if (locationCode == "0") {
121  String dateTime = gsmDate + gsmTime;
122 
123  dateTime.replace("/", "");
124  dateTime.replace(":", "");
125  dateTime += ".000";
126  gps.setLatitude(latitude);
127  gps.setLongitude(longitude);
128  gps.setDateTime(dateTime);
129  gps.fixStatus = true;
130  }
131 
132  return gps.fixStatus;
133 }
bool setLongitude(const String &data)
Definition: Gps.h:480
void clear()
Definition: Gps.h:408
bool setDateTime(const String &data)
Definition: Gps.h:466
bool setLatitude(const String &data)
Definition: Gps.h:474
bool fixStatus
Are the gps is valid received?
Definition: Gps.h:133
bool MyGsmSim808::getSMS ( SmsData sms)

Read one SMS from the sim card into the own SmsData class.

Definition at line 136 of file Sim808.h.

References SmsData::dateTime, SmsData::index, SmsData::message, SmsData::phoneNumber, SmsData::referenceNumber, SmsData::status, and Trim().

Referenced by MyGsmGps::getSMS().

137 {
138  // PDU Mode (Hex)
139  sendAT(GF("+CMGF=1"));
140  if (waitResponse() != 1) {
141  return false;
142  }
143 
144  // Read unread sms
145  sendAT(GF("+CMGL=\"REC UNREAD\""));
146  int status = waitResponse(GFP(GSM_OK), GF("+CMGL:"));
147 
148  if (status == 2) {
149  sms.index = atoi(stream.readStringUntil(',').c_str());
150  sms.status = stream.readStringUntil(',');
151  sms.phoneNumber = stream.readStringUntil(',');
152  sms.referenceNumber = stream.readStringUntil(',');
153  sms.dateTime = stream.readStringUntil('\n');
154  sms.message = stream.readStringUntil('\n');
155  sms.message = Trim(sms.message, F("\r\n"));
156  waitResponse();
157  return true;
158  }
159 
160  return false;
161 }
String dateTime
DateTime of the sms.
Definition: Sim808.h:39
String phoneNumber
Sms sender number.
Definition: Sim808.h:37
String message
Sms content.
Definition: Sim808.h:40
long index
Sms index on sim card.
Definition: Sim808.h:35
String status
Sms status like read or not.
Definition: Sim808.h:36
String referenceNumber
???
Definition: Sim808.h:38
String Trim(const String &data, const String &chars)
Definition: Utils.h:168

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