@@ -142,8 +142,8 @@ bool Sim800L::setSleepMode(bool state)
142
142
143
143
_sleepMode = state;
144
144
145
- if (_sleepMode) this ->print (F (" AT+CSCLK=1\r\n " ));
146
- else this ->print (F (" AT+CSCLK=0\r\n " ));
145
+ if (_sleepMode) this ->SoftwareSerial :: print (F (" AT+CSCLK=1\r\n " ));
146
+ else this ->SoftwareSerial :: print (F (" AT+CSCLK=0\r\n " ));
147
147
148
148
if ( (_readSerial ().indexOf (" ER" )) == -1 )
149
149
{
@@ -175,13 +175,13 @@ bool Sim800L::setFunctionalityMode(uint8_t fun)
175
175
switch (_functionalityMode)
176
176
{
177
177
case 0 :
178
- this ->print (F (" AT+CFUN=0\r\n " ));
178
+ this ->SoftwareSerial :: print (F (" AT+CFUN=0\r\n " ));
179
179
break ;
180
180
case 1 :
181
- this ->print (F (" AT+CFUN=1\r\n " ));
181
+ this ->SoftwareSerial :: print (F (" AT+CFUN=1\r\n " ));
182
182
break ;
183
183
case 4 :
184
- this ->print (F (" AT+CFUN=4\r\n " ));
184
+ this ->SoftwareSerial :: print (F (" AT+CFUN=4\r\n " ));
185
185
break ;
186
186
}
187
187
@@ -211,7 +211,7 @@ bool Sim800L::setPIN(String pin)
211
211
212
212
// Can take up to 5 seconds
213
213
214
- this ->print (command);
214
+ this ->SoftwareSerial :: print (command);
215
215
216
216
if ( (_readSerial (5000 ).indexOf (" ER" )) == -1 )
217
217
{
@@ -225,7 +225,7 @@ bool Sim800L::setPIN(String pin)
225
225
226
226
String Sim800L::getProductInfo ()
227
227
{
228
- this ->print (" ATI\r " );
228
+ this ->SoftwareSerial :: print (" ATI\r " );
229
229
return (_readSerial ());
230
230
}
231
231
@@ -235,7 +235,7 @@ String Sim800L::getOperatorsList()
235
235
236
236
// Can take up to 45 seconds
237
237
238
- this ->print (" AT+COPS=?\r " );
238
+ this ->SoftwareSerial :: print (" AT+COPS=?\r " );
239
239
240
240
return _readSerial (45000 );
241
241
@@ -244,7 +244,7 @@ String Sim800L::getOperatorsList()
244
244
String Sim800L::getOperator ()
245
245
{
246
246
247
- this ->print (" AT+COPS ?\r " );
247
+ this ->SoftwareSerial :: print (" AT+COPS ?\r " );
248
248
249
249
return _readSerial ();
250
250
@@ -262,11 +262,11 @@ bool Sim800L::calculateLocation()
262
262
uint8_t cid = 1 ;
263
263
264
264
265
- this ->print (" AT+CIPGSMLOC=" );
266
- this ->print (type);
267
- this ->print (" ," );
268
- this ->print (cid);
269
- this ->print (" \r " );
265
+ this ->SoftwareSerial :: print (" AT+CIPGSMLOC=" );
266
+ this ->SoftwareSerial :: print (type);
267
+ this ->SoftwareSerial :: print (" ," );
268
+ this ->SoftwareSerial :: print (cid);
269
+ this ->SoftwareSerial :: print (" \r " );
270
270
271
271
272
272
String data = _readSerial (20000 );
@@ -336,10 +336,10 @@ void Sim800L::reset()
336
336
delay (1000 );
337
337
// wait for the module response
338
338
339
- this ->print (F (" AT\r\n " ));
339
+ this ->SoftwareSerial :: print (F (" AT\r\n " ));
340
340
while (_readSerial ().indexOf (" OK" )==-1 )
341
341
{
342
- this ->print (F (" AT\r\n " ));
342
+ this ->SoftwareSerial :: print (F (" AT\r\n " ));
343
343
}
344
344
345
345
// wait for sms ready
@@ -358,7 +358,7 @@ void Sim800L::setPhoneFunctionality()
358
358
4 Disable phone both transmit and receive RF circuits.
359
359
<rst> 1 Reset the MT before setting it to <fun> power level.
360
360
*/
361
- this ->print (F (" AT+CFUN=1\r\n " ));
361
+ this ->SoftwareSerial :: print (F (" AT+CFUN=1\r\n " ));
362
362
}
363
363
364
364
@@ -377,37 +377,37 @@ String Sim800L::signalQuality()
377
377
subclause 7.2.4
378
378
99 Not known or not detectable
379
379
*/
380
- this ->print (F (" AT+CSQ\r\n " ));
380
+ this ->SoftwareSerial :: print (F (" AT+CSQ\r\n " ));
381
381
return (_readSerial ());
382
382
}
383
383
384
384
385
385
void Sim800L::activateBearerProfile ()
386
386
{
387
- this ->print (F (" AT+SAPBR=3,1,\" CONTYPE\" ,\" GPRS\" \r\n " ));
387
+ this ->SoftwareSerial :: print (F (" AT+SAPBR=3,1,\" CONTYPE\" ,\" GPRS\" \r\n " ));
388
388
_buffer=_readSerial (); // set bearer parameter
389
- this ->print (F (" AT+SAPBR=3,1,\" APN\" ,\" internet\" \r\n " ));
389
+ this ->SoftwareSerial :: print (F (" AT+SAPBR=3,1,\" APN\" ,\" internet\" \r\n " ));
390
390
_buffer=_readSerial (); // set apn
391
- this ->print (F (" AT+SAPBR=1,1 \r\n " ));
391
+ this ->SoftwareSerial :: print (F (" AT+SAPBR=1,1 \r\n " ));
392
392
delay (1200 );
393
393
_buffer=_readSerial (); // activate bearer context
394
- this ->print (F (" AT+SAPBR=2,1\r\n " ));
394
+ this ->SoftwareSerial :: print (F (" AT+SAPBR=2,1\r\n " ));
395
395
delay (3000 );
396
396
_buffer=_readSerial (); // get context ip address
397
397
}
398
398
399
399
400
400
void Sim800L::deactivateBearerProfile ()
401
401
{
402
- this ->print (F (" AT+SAPBR=0,1\r\n " ));
402
+ this ->SoftwareSerial :: print (F (" AT+SAPBR=0,1\r\n " ));
403
403
delay (1500 );
404
404
}
405
405
406
406
407
407
408
408
bool Sim800L::answerCall ()
409
409
{
410
- this ->print (F (" ATA\r\n " ));
410
+ this ->SoftwareSerial :: print (F (" ATA\r\n " ));
411
411
// Response in case of data call, if successfully connected
412
412
if ( (_readSerial ().indexOf (" ER" )) == -1 )
413
413
{
@@ -421,9 +421,9 @@ bool Sim800L::answerCall()
421
421
422
422
void Sim800L::callNumber (char * number)
423
423
{
424
- this ->print (F (" ATD" ));
425
- this ->print (number);
426
- this ->print (F (" \r\n " ));
424
+ this ->SoftwareSerial :: print (F (" ATD" ));
425
+ this ->SoftwareSerial :: print (number);
426
+ this ->SoftwareSerial :: print (F (" \r\n " ));
427
427
}
428
428
429
429
@@ -439,7 +439,7 @@ uint8_t Sim800L::getCallStatus()
439
439
4 Call in progress
440
440
441
441
*/
442
- this ->print (F (" AT+CPAS\r\n " ));
442
+ this ->SoftwareSerial :: print (F (" AT+CPAS\r\n " ));
443
443
_buffer=_readSerial ();
444
444
return _buffer.substring (_buffer.indexOf (" +CPAS: " )+7 ,_buffer.indexOf (" +CPAS: " )+9 ).toInt ();
445
445
@@ -449,7 +449,7 @@ uint8_t Sim800L::getCallStatus()
449
449
450
450
bool Sim800L::hangoffCall ()
451
451
{
452
- this ->print (F (" ATH\r\n " ));
452
+ this ->SoftwareSerial :: print (F (" ATH\r\n " ));
453
453
_buffer=_readSerial ();
454
454
if ( (_buffer.indexOf (" ER" )) == -1 )
455
455
{
@@ -466,16 +466,16 @@ bool Sim800L::sendSms(char* number,char* text)
466
466
467
467
// Can take up to 60 seconds
468
468
469
- this ->print (F (" AT+CMGF=1\r " )); // set sms to text mode
469
+ this ->SoftwareSerial :: print (F (" AT+CMGF=1\r " )); // set sms to text mode
470
470
_buffer=_readSerial ();
471
- this ->print (F (" AT+CMGS=\" " )); // command to send sms
472
- this ->print (number);
473
- this ->print (F (" \"\r " ));
471
+ this ->SoftwareSerial :: print (F (" AT+CMGS=\" " )); // command to send sms
472
+ this ->SoftwareSerial :: print (number);
473
+ this ->SoftwareSerial :: print (F (" \"\r " ));
474
474
_buffer=_readSerial ();
475
- this ->print (text);
476
- this ->print (" \r " );
475
+ this ->SoftwareSerial :: print (text);
476
+ this ->SoftwareSerial :: print (" \r " );
477
477
_buffer=_readSerial ();
478
- this ->print ((char )26 );
478
+ this ->SoftwareSerial :: print ((char )26 );
479
479
_buffer=_readSerial (60000 );
480
480
// expect CMGS:xxx , where xxx is a number,for the sending sms.
481
481
if ( (_buffer.indexOf (" ER" )) == -1 )
@@ -511,13 +511,13 @@ String Sim800L::readSms(uint8_t index)
511
511
512
512
// Can take up to 5 seconds
513
513
514
- this ->print (F (" AT+CMGF=1\r " ));
514
+ this ->SoftwareSerial :: print (F (" AT+CMGF=1\r " ));
515
515
516
516
if (( _readSerial (5000 ).indexOf (" ER" )) ==-1 )
517
517
{
518
- this ->print (F (" AT+CMGR=" ));
519
- this ->print (index);
520
- this ->print (" \r " );
518
+ this ->SoftwareSerial :: print (F (" AT+CMGR=" ));
519
+ this ->SoftwareSerial :: print (index);
520
+ this ->SoftwareSerial :: print (" \r " );
521
521
_buffer=_readSerial ();
522
522
if (_buffer.indexOf (" CMGR:" )!=-1 )
523
523
{
@@ -534,7 +534,7 @@ bool Sim800L::delAllSms()
534
534
{
535
535
// Can take up to 25 seconds
536
536
537
- this ->print (F (" at+cmgda=\" del all\"\n\r " ));
537
+ this ->SoftwareSerial :: print (F (" at+cmgda=\" del all\"\n\r " ));
538
538
_buffer=_readSerial (25000 );
539
539
if ( (_buffer.indexOf (" ER" )) == -1 )
540
540
{
@@ -548,13 +548,13 @@ bool Sim800L::delAllSms()
548
548
549
549
void Sim800L::RTCtime (int *day,int *month, int *year,int *hour,int *minute, int *second)
550
550
{
551
- this ->print (F (" at+cclk?\r\n " ));
551
+ this ->SoftwareSerial :: print (F (" at+cclk?\r\n " ));
552
552
// if respond with ERROR try one more time.
553
553
_buffer=_readSerial ();
554
554
if ((_buffer.indexOf (" ERR" ))!=-1 )
555
555
{
556
556
delay (50 );
557
- this ->print (F (" at+cclk?\r\n " ));
557
+ this ->SoftwareSerial :: print (F (" at+cclk?\r\n " ));
558
558
}
559
559
if ((_buffer.indexOf (" ERR" ))==-1 )
560
560
{
@@ -571,7 +571,7 @@ void Sim800L::RTCtime(int *day,int *month, int *year,int *hour,int *minute, int
571
571
// Get the time of the base of GSM
572
572
String Sim800L::dateNet ()
573
573
{
574
- this ->print (F (" AT+CIPGSMLOC=2,1\r\n " ));
574
+ this ->SoftwareSerial :: print (F (" AT+CIPGSMLOC=2,1\r\n " ));
575
575
_buffer=_readSerial ();
576
576
577
577
if (_buffer.indexOf (" OK" )!=-1 )
@@ -627,7 +627,7 @@ bool Sim800L::updateRtc(int utc)
627
627
}
628
628
// for debugging
629
629
// Serial.println("at+cclk=\""+dt.substring(2,4)+"/"+dt.substring(5,7)+"/"+tmp_day+","+tmp_hour+":"+tm.substring(3,5)+":"+tm.substring(6,8)+"-03\"\r\n");
630
- this ->print (" at+cclk=\" " +dt.substring (2 ,4 )+" /" +dt.substring (5 ,7 )+" /" +tmp_day+" ," +tmp_hour+" :" +tm.substring (3 ,5 )+" :" +tm.substring (6 ,8 )+" -03\"\r\n " );
630
+ this ->SoftwareSerial :: print (" at+cclk=\" " +dt.substring (2 ,4 )+" /" +dt.substring (5 ,7 )+" /" +tmp_day+" ," +tmp_hour+" :" +tm.substring (3 ,5 )+" :" +tm.substring (6 ,8 )+" -03\"\r\n " );
631
631
if ( (_readSerial ().indexOf (" ER" ))!=-1 )
632
632
{
633
633
return true ;
@@ -647,18 +647,18 @@ String Sim800L::_readSerial()
647
647
648
648
uint64_t timeOld = millis ();
649
649
650
- while (!this ->available () && !(millis () > timeOld + TIME_OUT_READ_SERIAL))
650
+ while (!this ->SoftwareSerial :: available () && !(millis () > timeOld + TIME_OUT_READ_SERIAL))
651
651
{
652
652
delay (13 );
653
653
}
654
654
655
655
String str;
656
656
657
- while (this ->available ())
657
+ while (this ->SoftwareSerial :: available ())
658
658
{
659
- if (this ->available ()>0 )
659
+ if (this ->SoftwareSerial :: available ()>0 )
660
660
{
661
- str += (char ) this ->read ();
661
+ str += (char ) this ->SoftwareSerial :: read ();
662
662
}
663
663
}
664
664
@@ -671,18 +671,18 @@ String Sim800L::_readSerial(uint32_t timeout)
671
671
672
672
uint64_t timeOld = millis ();
673
673
674
- while (!this ->available () && !(millis () > timeOld + timeout))
674
+ while (!this ->SoftwareSerial :: available () && !(millis () > timeOld + timeout))
675
675
{
676
676
delay (13 );
677
677
}
678
678
679
679
String str;
680
680
681
- while (this ->available ())
681
+ while (this ->SoftwareSerial :: available ())
682
682
{
683
- if (this ->available ()>0 )
683
+ if (this ->SoftwareSerial :: available ()>0 )
684
684
{
685
- str += (char ) this ->read ();
685
+ str += (char ) this ->SoftwareSerial :: read ();
686
686
}
687
687
}
688
688
0 commit comments