Skip to content

Commit

Permalink
Remove debug parameter to use macro instead
Browse files Browse the repository at this point in the history
  • Loading branch information
carrascoacd committed Dec 12, 2019
1 parent e6d0539 commit 49487b3
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
3 changes: 1 addition & 2 deletions Ftp.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class FTP : public SIM800
FTP(unsigned int baudRate,
unsigned int rxPin,
unsigned int txPin,
unsigned int rstPin,
bool debug = TRUE) : SIM800(baudRate, rxPin, txPin, rstPin, debug){};
unsigned int rstPin) : SIM800(baudRate, rxPin, txPin, rstPin){};

Result putBegin(const char *apn,
const char *fileName,
Expand Down
3 changes: 1 addition & 2 deletions Geo.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ class Geo : public SIM800
Geo(unsigned int baudRate,
unsigned int rxPin,
unsigned int txPin,
unsigned int rstPin,
bool debug = TRUE) : SIM800(baudRate, rxPin, txPin, rstPin, debug){};
unsigned int rstPin) : SIM800(baudRate, rxPin, txPin, rstPin){};
void readGpsLocation(char *gps);
};

Expand Down
3 changes: 1 addition & 2 deletions Http.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class HTTP : public SIM800
HTTP(unsigned int baudRate,
unsigned int rxPin,
unsigned int txPin,
unsigned int rstPin,
bool debug = TRUE) : SIM800(baudRate, rxPin, txPin, rstPin, debug){};
unsigned int rstPin) : SIM800(baudRate, rxPin, txPin, rstPin){};
Result connect(const char *apn);
Result disconnect();
Result get(const char *uri, char *response);
Expand Down
10 changes: 6 additions & 4 deletions Sim800.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ int SIM800::waitForResp(const char *resp, unsigned int timeout)
if (serialSIM800.available())
{
char c = serialSIM800.read();
if (debugMode)
Serial.print(c);


#ifdef DEBUG
Serial.print(c);
#endif

sum = (c == resp[sum] || resp[sum] == 'X') ? sum + 1 : 0;
if (sum == len)
break;
Expand Down Expand Up @@ -157,7 +159,7 @@ int SIM800::sendCmdAndWaitForResp(const char *cmd, const char *resp, unsigned ti

int SIM800::sendCmdAndWaitForResp_P(const char *cmd, const char *resp, unsigned timeout)
{
char cmdBuff[128]; // TODO check if I can reduce this to 64
char cmdBuff[128];
char respBuff[32];
strcpy_P(cmdBuff, cmd);
strcpy_P(respBuff, resp);
Expand Down
9 changes: 4 additions & 5 deletions Sim800.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
#define FALSE 0
#define DEFAULT_TIMEOUT 5000

// Comment or uncomment this to debug the library
#define DEBUG true

/** SIM800 class.
* Used for SIM800 communication. attention that SIM800 module communicate with MCU in serial protocol
*/
Expand All @@ -48,16 +51,13 @@ class SIM800
* @param baudRate baud rate of uart communication
* @param rxPin uart receive pin to communicate with SIM800
* @param txPin uart transmit pin to communicate with SIM800
* @param debug indicates if print the AT command sequence
*/
SIM800(unsigned int baudRate,
unsigned int rxPin,
unsigned int txPin,
unsigned int rstPin,
bool debug) : serialSIM800(txPin, rxPin)
unsigned int rstPin) : serialSIM800(txPin, rxPin)
{
serialSIM800.begin(baudRate);
debugMode = debug;
resetPin = rstPin;
};

Expand Down Expand Up @@ -139,7 +139,6 @@ class SIM800

protected:
SoftwareSerial serialSIM800;
bool debugMode;
unsigned int resetPin;
};

Expand Down

0 comments on commit 49487b3

Please sign in to comment.