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

Embed: (wiki syntax)

« Back to documentation index

GSM Class Reference

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:
txuart transmit pin to communicate with GSM module
rxuart receive pin to communicate with GSM module
baudRatebaud rate of uart communication
numberdefault phone number during mobile communication

Definition at line 52 of file GSM.h.


Member Function Documentation

int answer ( void   )

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:
*numberthe 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.

int closeTCP ( void   )

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:
*ipip address which will connect to
*portTCP 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:
*indexthe 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:
messagebuffer used to get SMS message

Definition at line 214 of file GSM.cpp.

int init ( void   )

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.

int loopHandle ( void   )

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:
*checkwhether 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:
*apnAccess Point Name to connect network
*userNamegeneral is empty
*passWordgeneral is empty

Definition at line 293 of file GSM.cpp.

int readSMS ( char *  message,
int  index 
)

Read SMS by index.

Parameters:
*messagebuffer used to get SMS message
indexwhich 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:
*numberphone number which SMS will be send to
*datamessage 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:
*datadata that will be send to TCP server
Returns:
0 on success, -1 on error

Definition at line 317 of file GSM.cpp.

int settingSMS ( void   )

Set SMS format and processing mode.

Returns:
0 on success, -1 on error

Definition at line 158 of file GSM.cpp.

int shutTCP ( void   )

Close TCP service.

Returns:
0 on success, -1 on error

Definition at line 337 of file GSM.cpp.