a library to use GPRS like ethernet or wifi, which makes it possible to connect to the internet with your GPRS module

Dependents:   Seeed_GPRS_Library_HelloWorld Seeed_GPRS_Xively_HelloWorld Seeed_ARCH_GPRS_V2_Xively_HelloWorld Seeed_ARCH_GPRS_V2_ThingSpeak_HelloWorld ... more

Embed: (wiki syntax)

« Back to documentation index

Modem Class Reference

Modem class. More...

#include <modem.h>

Inherited by GPRS.

Public Member Functions

 Modem (PinName tx, PinName rx, int baudRate)
 Create Modem Instance.

Protected Member Functions

void preInit (void)
 Power on Modem.
bool readable ()
 check serialModem is readable or not
char readByte (void)
 read one byte from serialModem
int readBuffer (char *buffer, int count, unsigned int timeOut)
 read from Modem module and save to buffer array
void cleanBuffer (char *buffer, int count)
 clean Buffer
void sendCmd (const char *cmd)
 send AT command to Modem module
void sendATTest (void)
 send "AT" to Modem module
bool respCmp (const char *resp, unsigned int len, unsigned int timeout)
 compare the response from GPRS module with a string
int waitForResp (const char *resp, unsigned int timeout, DataType type)
 check Modem module response before time out
int sendCmdAndWaitForResp (const char *data, const char *resp, unsigned timeout, DataType type)
 send AT command to GPRS module and wait for correct response

Detailed Description

Modem class.

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

Definition at line 38 of file modem.h.


Constructor & Destructor Documentation

Modem ( PinName  tx,
PinName  rx,
int  baudRate 
)

Create Modem Instance.

Parameters:
txuart transmit pin to communicate with Modem
rxuart receive pin to communicate with Modem
baudRatebaud rate of uart communication

Definition at line 47 of file modem.h.


Member Function Documentation

void cleanBuffer ( char *  buffer,
int  count 
) [protected]

clean Buffer

Parameters:
bufferbuffer to clean
countnumber of bytes to clean

Definition at line 55 of file modem.cpp.

void preInit ( void   ) [protected]

Power on Modem.

bool readable ( void   ) [protected]

check serialModem is readable or not

Returns:
true on readable false on not readable

Definition at line 30 of file modem.cpp.

int readBuffer ( char *  buffer,
int  count,
unsigned int  timeOut 
) [protected]

read from Modem module and save to buffer array

Parameters:
bufferbuffer array to save what read from Modem module
countthe maximal bytes number read from Modem module
timeOuttime to wait for reading from Modem module
Returns:
0 on success -1 on error

Definition at line 35 of file modem.cpp.

char readByte ( void   ) [protected]

read one byte from serialModem

Returns:
one byte read from serialModem

Definition at line 25 of file modem.cpp.

bool respCmp ( const char *  resp,
unsigned int  len,
unsigned int  timeout 
) [protected]

compare the response from GPRS module with a string

Parameters:
respbuffer to be compared
lenlength that will be compared
timeoutwaiting seconds till timeout

Definition at line 72 of file modem.cpp.

void sendATTest ( void   ) [protected]

send "AT" to Modem module

Definition at line 67 of file modem.cpp.

void sendCmd ( const char *  cmd ) [protected]

send AT command to Modem module

Parameters:
cmdcommand array which will be send to GPRS module

Definition at line 62 of file modem.cpp.

int sendCmdAndWaitForResp ( const char *  data,
const char *  resp,
unsigned  timeout,
DataType  type 
) [protected]

send AT command to GPRS module and wait for correct response

Parameters:
*cmdAT command which will be send to GPRS module
*respcorrect response which GPRS module will return
*timeoutwaiting seconds till timeout
Returns:
0 on success -1 on error

Definition at line 125 of file modem.cpp.

int waitForResp ( const char *  resp,
unsigned int  timeout,
DataType  type 
) [protected]

check Modem module response before time out

Parameters:
*respcorrect response which Modem module will return
*timeoutwaiting seconds till timeout
Returns:
0 on success -1 on error

Definition at line 95 of file modem.cpp.