File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ enum Result {
5353class 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 ();
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 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
134126private:
135127
136128 SoftwareSerial serialSIM800;
129+ bool debugMode;
137130
138131};
139132
You can’t perform that action at this time.
0 commit comments