11/*
22 * Sim800.cpp
3- * A library for SeeedStudio seeeduino GPRS shield
3+ * A library for SeeedStudio seeeduino GPRS shield
44 *
55 * Original work Copyright (c) 2013 seeed technology inc. [lawliet zou]
66 * Modified work Copyright 2016 Antonio Carrasco
@@ -40,7 +40,7 @@ int SIM800::preInit(void)
4040 delay (3000 );
4141
4242 purgeSerial ();
43-
43+
4444 return TRUE ;
4545}
4646
@@ -56,7 +56,7 @@ int SIM800::readBuffer(char *buffer, int count, unsigned int timeOut)
5656 timerStart = millis ();
5757 while (1 ) {
5858 while (serialSIM800.available ()) {
59- char c = serialSIM800.read ();
59+ char c = serialSIM800.read ();
6060 buffer[i] = c;
6161 buffer[i + 1 ] = ' \0 ' ;
6262 ++i;
@@ -84,6 +84,7 @@ void SIM800::cleanBuffer(char *buffer, int count)
8484
8585void SIM800::sendCmd (const char * cmd)
8686{
87+ serialSIM800.listen ();
8788 serialSIM800.write (cmd);
8889}
8990
@@ -99,7 +100,7 @@ int SIM800::waitForResp(const char *resp, unsigned int timeout)
99100 int sum=0 ;
100101 unsigned long timerStart,timerEnd;
101102 timerStart = millis ();
102-
103+
103104 while (1 ) {
104105 if (serialSIM800.available ()) {
105106 char c = serialSIM800.read ();
@@ -138,8 +139,8 @@ void SIM800::serialDebug(void)
138139 if (serialSIM800.available ()){
139140 Serial.write (serialSIM800.read ());
140141 }
141- if (Serial.available ()){
142- serialSIM800.write (Serial.read ());
142+ if (Serial.available ()){
143+ serialSIM800.write (Serial.read ());
143144 }
144145 }
145146}
0 commit comments