Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

gsm.c File Reference

Talk to the GSM modem. More...

#include "gsm.h"
#include "log.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>

Functions

int get_line (SerialPort *sp, char *const buffer, int buflen)
 Read a CR LF terminated line from the serial port.

int GSMSendCommand (SerialPort *sp, const char *const msg)
 Send a command to the GSM modem, and listen for the echoed response.

int GSMSendMessage (SerialPort *sp, const char *const number, const char *const msg)
int GSMCheckSignal (SerialPort *sp)
 Check the network association and signal strength of the GSM modem.

int GSMSetSMSMode (SerialPort *sp)
int GSMSendFile (SerialPort *sp, const char *const number, const char *const filename)

Variables

const char *const  CREG_MESSAGE = "AT+CREG?\r\n"
 Message to read Network Registration Status.

const char *const  CREG_MESSAGE_RES = "+CREG: "
const int CREG_MESSAGE_RES_LEN = 10
const char *const  CSQ_MESSAGE = "AT+CSQ\r\n"
 Message to read signal strength.

const char *const  CSQ_MESSAGE_RES = "+CSQ: "
const int CSQ_MESSAGE_RES_LEN = 9
const char *const  CMGF_MESSAGE = "AT+CMGF=1\r\n"
 Message to put modem into SMS mode.


Detailed Description

Talk to the GSM modem.

Copyright (C) 2004 Alistair Riddoch, The University of Southampton


Function Documentation

int get_line SerialPort sp,
char *const  buffer,
int  buflen
[static]
 

Read a CR LF terminated line from the serial port.

The CR LF characters are stripped, and the buffer is NULL terminated so the result can be used as a string.

Parameters:
sp serial port to read from
buffer buffer to store the line in
buflen size of buffer to read data into
Returns:
the number of bytes read, or minus one if an error or timeout occured.

int GSMCheckSignal SerialPort sp  ) 
 

Check the network association and signal strength of the GSM modem.

Parameters:
sp pointer to serial port to be used to talk to the modem.
Returns:
zero if the modem is associated with a GSM network, and has good enough signal strength to send messages, or 1 if GSM network is not available, 2 if GSM signal strength is too weak, or -1 if an error occured talking to the modem.

int GSMSendCommand SerialPort sp,
const char *const  msg
 

Send a command to the GSM modem, and listen for the echoed response.

Returns:
zero if the message was echoed back correctly, and one otherwise.


Generated on Mon Aug 9 13:41:45 2004 for Glacsweb by doxygen 1.3.5