« 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 29 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 38 of file GSM.h .
Member Function Documentation
Auto answer if coming a call.
Returns: 0 on success, -1 on error
Definition at line 239 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 229 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 145 of file GSM.cpp .
int checkSIMStatus
(
void
)
Check SIM card' Status.
Returns: 0 on success, -1 on error
Definition at line 124 of file GSM.cpp .
Close TCP connection.
Returns: 0 on success, -1 on error
Definition at line 338 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 310 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 213 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 221 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 106 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 245 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 300 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 192 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 176 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 324 of file GSM.cpp .
Set SMS format and processing mode.
Returns: 0 on success, -1 on error
Definition at line 165 of file GSM.cpp .
Close TCP service.
Returns: 0 on success, -1 on error
Definition at line 344 of file GSM.cpp .