11/*
22 * Sim800.h
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
3535#define TRUE 1
3636#define FALSE 0
3737
38- #define SIM800_TX_PIN 8
39- #define SIM800_RX_PIN 7
40- #define SIM800_RESET_PIN 12
41-
4238#define DEFAULT_TIMEOUT 5000
4339
4440
@@ -49,41 +45,42 @@ class SIM800
4945{
5046
5147public:
52- /* * Create SIM800 Instance
53- * @param tx uart transmit pin to communicate with SIM800
54- * @param rx uart receive pin to communicate with SIM800
48+ /* * Create SIM800 Instance
5549 * @param baudRate baud rate of uart communication
50+ * @param rxPin uart receive pin to communicate with SIM800
51+ * @param txPin uart transmit pin to communicate with SIM800
5652 */
57- SIM800 (unsigned int baudRate, bool debug):serialSIM800(SIM800_TX_PIN,SIM800_RX_PIN) {
53+ SIM800 (unsigned int baudRate, unsigned int rxPin, unsigned int txPin, unsigned int rstPin, bool debug):serialSIM800(txPin, rxPin) {
5854 serialSIM800.begin (baudRate);
5955 debugMode = debug;
56+ resetPin = rstPin;
6057 };
61-
58+
6259 /* * Power on SIM800
6360 */
6461 int preInit (void );
65-
62+
6663 /* * Check if SIM800 readable
6764 */
6865 int checkReadable (void );
69-
66+
7067 /* * read from SIM800 module and save to buffer array
7168 * @param buffer buffer array to save what read from SIM800 module
7269 * @param count the maximal bytes number read from SIM800 module
73- * @param timeOut time to wait for reading from SIM800 module
70+ * @param timeOut time to wait for reading from SIM800 module
7471 * @returns
7572 * TRUE on success
7673 * ERROR on error
7774 */
7875 int readBuffer (char * buffer,int count, unsigned int timeOut = DEFAULT_TIMEOUT);
7976
80-
77+
8178 /* * clean Buffer
8279 * @param buffer buffer to clean
8380 * @param count number of bytes to clean
8481 */
8582 void cleanBuffer (char * buffer, int count);
86-
83+
8784 /* * send AT command to SIM800 module
8885 * @param cmd command array which will be send to GPRS module
8986 */
@@ -92,18 +89,18 @@ class SIM800
9289 /* *send "AT" to SIM800 module
9390 */
9491 int sendATTest (void );
95-
92+
9693 /* *send '0x1A' to SIM800 Module
9794 */
9895 void sendEndMark (void );
99-
96+
10097 /* * check SIM800 module response before time out
10198 * @param *resp correct response which SIM800 module will return
10299 * @param *timeout waiting seconds till timeout
103100 * @returns
104101 * TRUE on success
105102 * ERROR on error
106- */
103+ */
107104 int waitForResp (const char * resp, unsigned timeout);
108105
109106 /* * send AT command to GPRS module and wait for correct response
@@ -120,14 +117,15 @@ class SIM800
120117 /* * used for serial debug, you can specify tx and rx pin and then communicate with GPRS module with common AT commands
121118 */
122119 void serialDebug (void );
123-
120+
124121 void purgeSerial ();
125122
126123private:
127-
124+
128125 SoftwareSerial serialSIM800;
129126 bool debugMode;
130-
127+ unsigned int resetPin;
128+
131129};
132130
133131#endif
0 commit comments