SIM900
sim900.h
1/*
2 * This file is part of the SIM900 Arduino Shield library.
3 * Copyright (c) 2023 Nathanne Isip
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 */
23
24#ifndef SIM900_H
25#define SIM900_H
26
27#include <Arduino.h>
28
29#include "sim900_defs.h"
30
41class SIM900 {
42private:
44 Stream& sim900;
45
47 bool hasAPN = false;
48
50 void sendCommand(String message);
51
53 bool isSuccessCommand();
54
56 String getResponse();
57
59 String getReturnedMode();
60
62 String rawQueryOnLine(uint16_t line);
63
65 String queryResult();
66
67public:
75 SIM900(Stream& _sim900);
76
84 bool handshake();
85
91 void close();
92
100 bool isCardReady();
101
110 bool changeCardPin(uint8_t pin);
111
120
129 SIM900DialResult dialUp(String number);
130
140 SIM900DialResult redialUp();
141
151 SIM900DialResult acceptIncomingCall();
152
162 bool hangUp();
163
175 bool sendSMS(String number, String message);
176
187 bool connectAPN(SIM900APN apn);
188
198 bool enableGPRS();
199
211
222
234
245 SIM900RTC rtc();
246
257 bool updateRtc(SIM900RTC config);
258
270 bool savePhonebook(uint8_t index, SIM900CardAccount account);
271
282 bool deletePhonebook(uint8_t index);
283
295
307
315 String manufacturer();
316
324 String softwareRelease();
325
333 String imei();
334
342 String chipModel();
343
351 String chipName();
352
360 String ipAddress();
361};
362
363#endif
A class for interfacing with the SIM900 GSM/GPRS module using Arduino and SoftwareSerial.
Definition: sim900.h:41
bool savePhonebook(uint8_t index, SIM900CardAccount account)
Save a contact in the SIM card's phonebook.
Definition: sim900.cpp:332
String manufacturer()
Get the manufacturer name of the SIM900 module.
Definition: sim900.cpp:413
SIM900DialResult redialUp()
Redial the last outgoing call.
Definition: sim900.cpp:145
String chipName()
Get the chip name of the SIM900 module.
Definition: sim900.cpp:437
SIM900PhonebookCapacity phonebookCapacity()
Get information about the capacity of the SIM card's phonebook.
Definition: sim900.cpp:370
SIM900DialResult acceptIncomingCall()
Accept an incoming call.
Definition: sim900.cpp:165
SIM900DialResult dialUp(String number)
Initiate an outgoing call to a phone number.
Definition: sim900.cpp:125
bool enableGPRS()
Enable the General Packet Radio Service (GPRS) for data communication.
Definition: sim900.cpp:235
String ipAddress()
Get the IP address assigned to the SIM900 module.
Definition: sim900.cpp:442
SIM900CardAccount cardNumber()
Get the SIM card number.
Definition: sim900.cpp:388
String chipModel()
Get the chip model of the SIM900 module.
Definition: sim900.cpp:432
bool deletePhonebook(uint8_t index)
Delete a contact from the SIM card's phonebook.
Definition: sim900.cpp:365
SIM900Operator networkOperator()
Get information about the current network operator.
Definition: sim900.cpp:198
bool sendSMS(String number, String message)
Send an SMS (Short Message Service).
Definition: sim900.cpp:184
bool updateRtc(SIM900RTC config)
Update the SIM900 module's real-time clock (RTC).
Definition: sim900.cpp:282
String softwareRelease()
Get the software release version of the SIM900 module.
Definition: sim900.cpp:418
void close()
Close the communication with the SIM900 module.
bool hangUp()
Hang up an active call.
Definition: sim900.cpp:179
bool connectAPN(SIM900APN apn)
Connect to an Access Point Name (APN) for mobile data.
Definition: sim900.cpp:217
bool changeCardPin(uint8_t pin)
Change the PIN code of the SIM card.
Definition: sim900.cpp:96
SIM900(Stream &_sim900)
Constructor for the SIM900 class.
Definition: sim900.cpp:84
SIM900RTC rtc()
Get the real-time clock (RTC) information.
Definition: sim900.cpp:296
bool handshake()
Initialize communication with the SIM900 module and perform a handshake.
Definition: sim900.cpp:86
bool isCardReady()
Check if the SIM card is ready.
Definition: sim900.cpp:91
String imei()
Get the International Mobile Equipment Identity (IMEI) number of the SIM900 module.
Definition: sim900.cpp:427
SIM900CardAccount retrievePhonebook(uint8_t index)
Retrieve a contact from the SIM card's phonebook.
Definition: sim900.cpp:342
SIM900Signal signal()
Get the signal strength and bit error rate of the network connection.
Definition: sim900.cpp:104
SIM900HTTPResponse request(SIM900HTTPRequest request)
Send an HTTP request to a remote server.
Definition: sim900.cpp:245
A structure representing Access Point Name (APN) configuration for mobile data.
A structure representing a card account, including name, number, type, and service information.
A structure representing an HTTP request.
A structure representing an HTTP response.
A structure representing mobile network operator information.
A structure representing the capacity of a phonebook memory type.
A structure representing real-time clock (RTC) information.
A structure representing signal strength and bit error rate information.