A library for the SIM900 module to enable calling, answering, sending and receiving SMS messages
Dependents:
Seeed_GPRS_Shield_GSM
BluetoothNONIN
HealthCare_Graduation
Fork of
GSM
by Components
« Back to documentation index
GSM Class Reference
GSM class.
More...
#include <GSM.h >
Public Member Functions
GSM (PinName tx, PinName rx, int baudRate, char *number)
Create GSM instance.
int init (void)
init GSM module including SIM card check & signal strength & network check
int checkSIMStatus (void)
Check SIM card' Status.
int checkSignalStrength (void)
Check signal strength.
int settingSMS (void)
Set SMS format and processing mode.
int sendSMS (char *number, char *data)
Send text SMS.
int readSMS (char *message, int index)
Read SMS by index.
int deleteSMS (int index)
Delete SMS message on SIM card.
int getSMS (char *message)
Read SMS when coming a message,it will be store in messageBuffer.
int callUp (char *number)
Call someone.
int answer (void)
Auto answer if coming a call.
int loopHandle (void)
A loop to wait for some event.
int networkInit (char *apn, char *userName=NULL, char *passWord=NULL)
GSM network init.
int connectTCP (char *ip, char *port)
Build TCP connect.
int sendTCPData (char *data)
Send data to TCP server.
int closeTCP (void)
Close TCP connection.
int shutTCP (void)
Close TCP service.
Detailed Description
GSM class.
Used for mobile communication. attention that GSM module communicate with MCU in serial protocol
Definition at line 43 of file GSM.h .
Constructor & Destructor Documentation
GSM
(
PinName
tx ,
PinName
rx ,
int
baudRate ,
char *
number
)
Create GSM instance.
Parameters:
tx uart transmit pin to communicate with GSM module
rx uart receive pin to communicate with GSM module
baudRate baud rate of uart communication
number default phone number during mobile communication
Definition at line 52 of file GSM.h .
Member Function Documentation
Auto answer if coming a call.
Returns: 0 on success, -1 on error
Definition at line 232 of file GSM.cpp .
int callUp
(
char *
number )
Call someone.
Parameters:
*number the phone number which you want to call
Returns: 0 on success, -1 on error
Definition at line 222 of file GSM.cpp .
int checkSignalStrength
(
void
)
Check signal strength.
Returns: signal strength in number(ex 3,4,5,6,7,8...) on success, -1 on error
Definition at line 138 of file GSM.cpp .
int checkSIMStatus
(
void
)
Check SIM card' Status.
Returns: 0 on success, -1 on error
Definition at line 117 of file GSM.cpp .
Close TCP connection.
Returns: 0 on success, -1 on error
Definition at line 331 of file GSM.cpp .
int connectTCP
(
char *
ip ,
char *
port
)
Build TCP connect.
Parameters:
*ip ip address which will connect to
*port TCP server' port number
Returns: 0 on success, -1 on error
Definition at line 303 of file GSM.cpp .
int deleteSMS
(
int
index )
Delete SMS message on SIM card.
Parameters:
*index the index number which SMS message will be delete
Returns: 0 on success, -1 on error
Definition at line 206 of file GSM.cpp .
int getSMS
(
char *
message )
Read SMS when coming a message,it will be store in messageBuffer.
Parameters:
message buffer used to get SMS message
Definition at line 214 of file GSM.cpp .
init GSM module including SIM card check & signal strength & network check
Returns: 0 on success, -1 on error
Definition at line 99 of file GSM.cpp .
A loop to wait for some event.
if a call comes in, it will auto answer it and if a SMS message comes in, it will read the message
Parameters:
*check whether to check phone number when get event
Returns: 0 on success, -1 on error
Definition at line 238 of file GSM.cpp .
int networkInit
(
char *
apn ,
char *
userName = NULL
,
char *
passWord = NULL
)
GSM network init.
Parameters:
*apn Access Point Name to connect network
*userName general is empty
*passWord general is empty
Definition at line 293 of file GSM.cpp .
int readSMS
(
char *
message ,
int
index
)
Read SMS by index.
Parameters:
*message buffer used to get SMS message
index which SMS message to read
Returns: 0 on success, -1 on error
Definition at line 185 of file GSM.cpp .
int sendSMS
(
char *
number ,
char *
data
)
Send text SMS.
Parameters:
*number phone number which SMS will be send to
*data message that will be send to
Returns: 0 on success, -1 on error
Definition at line 169 of file GSM.cpp .
int sendTCPData
(
char *
data )
Send data to TCP server.
Parameters:
*data data that will be send to TCP server
Returns: 0 on success, -1 on error
Definition at line 317 of file GSM.cpp .
Set SMS format and processing mode.
Returns: 0 on success, -1 on error
Definition at line 158 of file GSM.cpp .
Close TCP service.
Returns: 0 on success, -1 on error
Definition at line 337 of file GSM.cpp .