Skip to content

Commit 002da0f

Browse files
committed
New debug mode without the need of modifying the library
1 parent 9f9db75 commit 002da0f

3 files changed

Lines changed: 6 additions & 13 deletions

File tree

Http.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ enum Result {
5353
class HTTP : public SIM800 {
5454

5555
public:
56-
HTTP(int baudRate = 9600):SIM800(baudRate){};
56+
HTTP(unsigned int baudRate = 9600, bool debug = TRUE):SIM800(baudRate, debug){};
5757
Result configureBearer(const char *apn);
5858
Result connect();
5959
Result disconnect();

Sim800.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ int SIM800::waitForResp(const char *resp, unsigned int timeout)
103103
while(1) {
104104
if(serialSIM800.available()) {
105105
char c = serialSIM800.read();
106-
Serial.print(c);
106+
if (debugMode) Serial.print(c);
107107
sum = (c==resp[sum]) ? sum+1 : 0;
108108
if(sum == len)break;
109109
}

Sim800.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,8 @@
3939
#define SIM800_RX_PIN 7
4040
#define SIM800_RESET_PIN 12
4141

42-
#define UART_DEBUG
42+
#define DEFAULT_TIMEOUT 5000
4343

44-
#ifdef UART_DEBUG
45-
#define ERROR(x) Serial.println(x)
46-
#define DEBUG(x) Serial.println(x);
47-
#else
48-
#define ERROR(x)
49-
#define DEBUG(x)
50-
#endif
51-
52-
#define DEFAULT_TIMEOUT 5000
5344

5445
/** SIM800 class.
5546
* Used for SIM800 communication. attention that SIM800 module communicate with MCU in serial protocol
@@ -63,8 +54,9 @@ class SIM800
6354
* @param rx uart receive pin to communicate with SIM800
6455
* @param baudRate baud rate of uart communication
6556
*/
66-
SIM800(int baudRate):serialSIM800(SIM800_TX_PIN,SIM800_RX_PIN){
57+
SIM800(unsigned int baudRate, bool debug):serialSIM800(SIM800_TX_PIN,SIM800_RX_PIN){
6758
serialSIM800.begin(baudRate);
59+
debugMode = debug;
6860
};
6961

7062
/** Power on SIM800
@@ -134,6 +126,7 @@ class SIM800
134126
private:
135127

136128
SoftwareSerial serialSIM800;
129+
bool debugMode;
137130

138131
};
139132

0 commit comments

Comments
 (0)