offer some API for GPRS use, such as call / sms / tcp connect

Dependents:   SDP_Testing

Fork of GPRS by wei zou

Embed: (wiki syntax)

« Back to documentation index

GPRS Class Reference

GPRS Class Reference

GPRS class. More...

#include <gprs.h>

Public Member Functions

 GPRS (PinName tx, PinName rx, int baudRate, char *number)
 Create GPRS instance.
int init (void)
 init GPRS 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)
 gprs 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

GPRS class.

Used for mobile communication. attention that GPRS module communicate with MCU in serial protocol

Definition at line 43 of file gprs.h.


Constructor & Destructor Documentation

GPRS ( PinName  tx,
PinName  rx,
int  baudRate,
char *  number 
)

Create GPRS instance.

Parameters:
txuart transmit pin to communicate with GPRS module
rxuart receive pin to communicate with GPRS module
baudRatebaud rate of uart communication
numberdefault phone number during mobile communication

Definition at line 52 of file gprs.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 gprs.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 gprs.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 gprs.cpp.

int checkSIMStatus ( void   )

check SIM card' Status

Returns:
0 on success -1 on error

Definition at line 117 of file gprs.cpp.

int closeTCP ( void   )

close TCP connection

Returns:
0 on success -1 on error

Definition at line 331 of file gprs.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 gprs.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 gprs.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 gprs.cpp.

int init ( void   )

init GPRS module including SIM card check & signal strength & network check

Returns:
0 on success -1 on error

Definition at line 99 of file gprs.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 gprs.cpp.

int networkInit ( char *  apn,
char *  userName = NULL,
char *  passWord = NULL 
)

gprs network init

Parameters:
*apnAccess Point Name to connect network
*userNamegeneral is empty
*passWordgeneral is empty

Definition at line 293 of file gprs.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 gprs.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 gprs.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 gprs.cpp.

int settingSMS ( void   )

set SMS format and processing mode

Returns:
0 on success -1 on error

Definition at line 158 of file gprs.cpp.

int shutTCP ( void   )

close TCP service

Returns:
0 on success -1 on error

Definition at line 337 of file gprs.cpp.