-
Notifications
You must be signed in to change notification settings - Fork 46
/
Sim800L.h
151 lines (128 loc) · 4.38 KB
/
Sim800L.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
* This library was written by Vittorio Esposito
* https://github.com/VittorioEsposito
*
* Designed to work with the GSM Sim800L.
*
* ENG
* This library uses SoftwareSerial, you can define RX and TX pins
* in the header "Sim800L.h", by default pins are RX=10 and TX=11.
* Be sure that GND is connected to arduino too.
* You can also change the RESET_PIN as you prefer.
*
* ESP
* Esta libreria usa SoftwareSerial, se pueden cambiar los pines de RX y TX
* en el archivo header, "Sim800L.h", por defecto los pines vienen configurado en
* RX=10 TX=11.
* Tambien se puede cambiar el RESET_PIN por otro que prefiera
*
* ITA
* Questa libreria utilizza la SoftwareSerial, si possono cambiare i pin di RX e TX
* dall' intestazione "Sim800L.h", di default essi sono impostati come RX=10 RX=11
* Assicurarsi di aver collegato il dispositivo al pin GND di Arduino.
* E' anche possibile cambiare il RESET_PIN.
*
*
* DEFAULT PINOUT:
* _____________________________
* | ARDUINO UNO >>> Sim800L |
* -----------------------------
* GND >>> GND
* RX 10 >>> TX
* TX 11 >>> RX
* RESET 2 >>> RST
*
* POWER SOURCE 4.2V >>> VCC
*
*
* SOFTWARE SERIAL NOTES:
*
* PINOUT
* The library has the following known limitations:
* 1. If using multiple software serial ports, only one can receive data at a time.
* 2. Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).
* 3. Not all pins on the Leonardo and Micro support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
* 4. On Arduino or Genuino 101 the current maximum RX speed is 57600bps
* 5. On Arduino or Genuino 101 RX doesn't work on Pin 13
*
* BAUD RATE
* Supported baud rates are 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, and 115200.
*
*
* Edited on: December 24, 2016
* Editor: Vittorio Esposito
*
* Original version by: Cristian Steib
*
*
*/
#ifndef Sim800L_h
#define Sim800L_h
#include <SoftwareSerial.h>
#include "Arduino.h"
#define DEFAULT_RX_PIN 10
#define DEFAULT_TX_PIN 11
#define DEFAULT_RESET_PIN 2 // pin to the reset pin Sim800L
#define DEFAULT_LED_FLAG true // true: use led. false: don't user led.
#define DEFAULT_LED_PIN 13 // pin to indicate states.
#define BUFFER_RESERVE_MEMORY 255
#define DEFAULT_BAUD_RATE 9600
#define TIME_OUT_READ_SERIAL 5000
class Sim800L : public SoftwareSerial
{
private:
uint32_t _baud;
int _timeout;
String _buffer;
bool _sleepMode;
uint8_t _functionalityMode;
String _locationCode;
String _longitude;
String _latitude;
String _readSerial();
String _readSerial(uint32_t timeout);
public:
uint8_t RX_PIN;
uint8_t TX_PIN;
uint8_t RESET_PIN;
uint8_t LED_PIN;
bool LED_FLAG;
Sim800L(void);
Sim800L(uint8_t rx, uint8_t tx);
Sim800L(uint8_t rx, uint8_t tx, uint8_t rst);
Sim800L(uint8_t rx, uint8_t tx, uint8_t rst, uint8_t led);
void begin(); //Default baud 9600
void begin(uint32_t baud);
void reset();
bool setSleepMode(bool state);
bool getSleepMode();
bool setFunctionalityMode(uint8_t fun);
uint8_t getFunctionalityMode();
bool setPIN(String pin);
String getProductInfo();
String getOperatorsList();
String getOperator();
bool calculateLocation();
String getLocationCode();
String getLongitude();
String getLatitude();
bool answerCall();
void callNumber(char* number);
bool hangoffCall();
uint8_t getCallStatus();
const uint8_t checkForSMS();
bool prepareForSmsReceive();
bool sendSms(char* number,char* text);
String readSms(uint8_t index);
String getNumberSms(uint8_t index);
bool delAllSms();
String signalQuality();
void setPhoneFunctionality();
void activateBearerProfile();
void deactivateBearerProfile();
bool setMode();
void RTCtime(int *day,int *month, int *year,int *hour,int *minute, int *second);
String dateNet();
bool updateRtc(int utc);
};
#endif