Testing the module's internet connection (spoiler: it doesn't work) WARNING: this code has been written in a hurry during an hackathon. It's total crap.

Dependencies:   GPS_CanSat mbed

Embed: (wiki syntax)

« Back to documentation index

Modem Class Reference

Modem Class Reference

Modem class. More...

#include <modem.h>

Public Member Functions

 Modem (PinName tx, PinName rx, int baudRate)
 Create Modem Instance.
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 42 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 51 of file modem.h.


Member Function Documentation

void cleanBuffer ( char *  buffer,
int  count 
)

clean Buffer

Parameters:
bufferbuffer to clean
countnumber of bytes to clean

Definition at line 55 of file modem.cpp.

void preInit ( void   )

Power on Modem.

bool readable (  )

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 
)

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   )

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 
)

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   )

send "AT" to Modem module

Definition at line 67 of file modem.cpp.

void sendCmd ( const char *  cmd )

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 
)

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 130 of file modem.cpp.

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

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.