Skip to content

Commit 49487b3

Browse files
committed
Remove debug parameter to use macro instead
1 parent e6d0539 commit 49487b3

5 files changed

Lines changed: 13 additions & 15 deletions

File tree

Ftp.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ class FTP : public SIM800
3838
FTP(unsigned int baudRate,
3939
unsigned int rxPin,
4040
unsigned int txPin,
41-
unsigned int rstPin,
42-
bool debug = TRUE) : SIM800(baudRate, rxPin, txPin, rstPin, debug){};
41+
unsigned int rstPin) : SIM800(baudRate, rxPin, txPin, rstPin){};
4342

4443
Result putBegin(const char *apn,
4544
const char *fileName,

Geo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ class Geo : public SIM800
3737
Geo(unsigned int baudRate,
3838
unsigned int rxPin,
3939
unsigned int txPin,
40-
unsigned int rstPin,
41-
bool debug = TRUE) : SIM800(baudRate, rxPin, txPin, rstPin, debug){};
40+
unsigned int rstPin) : SIM800(baudRate, rxPin, txPin, rstPin){};
4241
void readGpsLocation(char *gps);
4342
};
4443

Http.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ class HTTP : public SIM800
3838
HTTP(unsigned int baudRate,
3939
unsigned int rxPin,
4040
unsigned int txPin,
41-
unsigned int rstPin,
42-
bool debug = TRUE) : SIM800(baudRate, rxPin, txPin, rstPin, debug){};
41+
unsigned int rstPin) : SIM800(baudRate, rxPin, txPin, rstPin){};
4342
Result connect(const char *apn);
4443
Result disconnect();
4544
Result get(const char *uri, char *response);

Sim800.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ int SIM800::waitForResp(const char *resp, unsigned int timeout)
122122
if (serialSIM800.available())
123123
{
124124
char c = serialSIM800.read();
125-
if (debugMode)
126-
Serial.print(c);
127-
125+
126+
#ifdef DEBUG
127+
Serial.print(c);
128+
#endif
129+
128130
sum = (c == resp[sum] || resp[sum] == 'X') ? sum + 1 : 0;
129131
if (sum == len)
130132
break;
@@ -157,7 +159,7 @@ int SIM800::sendCmdAndWaitForResp(const char *cmd, const char *resp, unsigned ti
157159

158160
int SIM800::sendCmdAndWaitForResp_P(const char *cmd, const char *resp, unsigned timeout)
159161
{
160-
char cmdBuff[128]; // TODO check if I can reduce this to 64
162+
char cmdBuff[128];
161163
char respBuff[32];
162164
strcpy_P(cmdBuff, cmd);
163165
strcpy_P(respBuff, resp);

Sim800.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
#define FALSE 0
3737
#define DEFAULT_TIMEOUT 5000
3838

39+
// Comment or uncomment this to debug the library
40+
#define DEBUG true
41+
3942
/** SIM800 class.
4043
* Used for SIM800 communication. attention that SIM800 module communicate with MCU in serial protocol
4144
*/
@@ -48,16 +51,13 @@ class SIM800
4851
* @param baudRate baud rate of uart communication
4952
* @param rxPin uart receive pin to communicate with SIM800
5053
* @param txPin uart transmit pin to communicate with SIM800
51-
* @param debug indicates if print the AT command sequence
5254
*/
5355
SIM800(unsigned int baudRate,
5456
unsigned int rxPin,
5557
unsigned int txPin,
56-
unsigned int rstPin,
57-
bool debug) : serialSIM800(txPin, rxPin)
58+
unsigned int rstPin) : serialSIM800(txPin, rxPin)
5859
{
5960
serialSIM800.begin(baudRate);
60-
debugMode = debug;
6161
resetPin = rstPin;
6262
};
6363

@@ -139,7 +139,6 @@ class SIM800
139139

140140
protected:
141141
SoftwareSerial serialSIM800;
142-
bool debugMode;
143142
unsigned int resetPin;
144143
};
145144

0 commit comments

Comments
 (0)