Skip to content

Commit 9e8fcfc

Browse files
authored
Add files via upload
1 parent adbe558 commit 9e8fcfc

File tree

2 files changed

+63
-60
lines changed

2 files changed

+63
-60
lines changed

Sim800L.cpp

Lines changed: 55 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -251,53 +251,54 @@ String Sim800L::getOperator()
251251
}
252252

253253

254-
bool Sim800L::calculateLocation()
255-
{
256-
/*
257-
Type: 1 To get longitude and latitude
258-
Cid = 1 Bearer profile identifier refer to AT+SAPBR
259-
*/
260-
261-
uint8_t type = 1;
262-
uint8_t cid = 1;
263-
264-
265-
this->print("AT+CIPGSMLOC=");
266-
this->print(type);
267-
this->print(",");
268-
this->print(cid);
269-
this->print("\r");
270-
271-
272-
String data = _readSerial(20000);
273-
274-
if (data.indexOf("ER")!=(-1)) return false;
275-
276-
uint8_t indexOne;
277-
uint8_t indexTwo;
278-
279-
indexOne = data.indexOf(":") + 1;
280-
indexTwo = data.indexOf(",");
281-
282-
_locationCode = data.substring(indexOne , indexTwo);
283-
284-
indexOne = data.indexOf(",") + 1;
285-
indexTwo = data.indexOf("," , indexOne);
286-
287-
_longitude = data.substring(indexOne , indexTwo);
288-
289-
indexOne = data.indexOf(",", indexTwo) + 1;
290-
indexTwo = data.indexOf("," , indexOne);
291-
292-
_latitude = data.substring(indexOne , indexTwo);
293-
294-
return true;
295-
296-
}
297-
298-
String Sim800L::getLocationCode() {
299-
return _locationCode;
300-
/*
254+
bool Sim800L::calculateLocation()
255+
{
256+
/*
257+
Type: 1 To get longitude and latitude
258+
Cid = 1 Bearer profile identifier refer to AT+SAPBR
259+
*/
260+
261+
uint8_t type = 1;
262+
uint8_t cid = 1;
263+
264+
265+
this->print("AT+CIPGSMLOC=");
266+
this->print(type);
267+
this->print(",");
268+
this->print(cid);
269+
this->print("\r");
270+
271+
272+
String data = _readSerial(20000);
273+
274+
if (data.indexOf("ER")!=(-1)) return false;
275+
276+
uint8_t indexOne;
277+
uint8_t indexTwo;
278+
279+
indexOne = data.indexOf(":") + 1;
280+
indexTwo = data.indexOf(",");
281+
282+
_locationCode = data.substring(indexOne, indexTwo);
283+
284+
indexOne = data.indexOf(",") + 1;
285+
indexTwo = data.indexOf(",", indexOne);
286+
287+
_longitude = data.substring(indexOne, indexTwo);
288+
289+
indexOne = data.indexOf(",", indexTwo) + 1;
290+
indexTwo = data.indexOf(",", indexOne);
291+
292+
_latitude = data.substring(indexOne, indexTwo);
293+
294+
return true;
295+
296+
}
297+
298+
String Sim800L::getLocationCode()
299+
{
300+
return _locationCode;
301+
/*
301302
Location Code:
302303
0 Success
303304
404 Not Found
@@ -307,15 +308,17 @@ String Sim800L::getLocationCode() {
307308
603 DNS Error
308309
604 Stack Busy
309310
65535 Other Error
310-
*/
311+
*/
311312
}
312313

313-
String Sim800L::getLongitude() {
314-
return _longitude;
314+
String Sim800L::getLongitude()
315+
{
316+
return _longitude;
315317
}
316318

317-
String Sim800L::getLatitude() {
318-
return _latitude;
319+
String Sim800L::getLatitude()
320+
{
321+
return _latitude;
319322
}
320323

321324

Sim800L.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ class Sim800L : public SoftwareSerial
8484
String _buffer;
8585
bool _sleepMode;
8686
uint8_t _functionalityMode;
87-
String _locationCode;
88-
String _longitude;
89-
String _latitude;
87+
String _locationCode;
88+
String _longitude;
89+
String _latitude;
9090

9191
String _readSerial();
9292
String _readSerial(uint32_t timeout);
@@ -119,11 +119,11 @@ class Sim800L : public SoftwareSerial
119119

120120
String getOperatorsList();
121121
String getOperator();
122-
123-
bool calculateLocation();
124-
String getLocationCode();
125-
String getLongitude();
126-
String getLatitude();
122+
123+
bool calculateLocation();
124+
String getLocationCode();
125+
String getLongitude();
126+
String getLatitude();
127127

128128
bool answerCall();
129129
void callNumber(char* number);

0 commit comments

Comments
 (0)