upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions | Protected Attributes

API for the Grove GPRS Module. More...

Detailed Description

Deprecated:
This class is being replaced by GPRS

The driver was tested with the Grove GPRS Module, V2. It's a GSM GPRS module based on the SIM900. This module uses a standard 'AT' command set. See the datasheet for a full list of available commands and their possible responses:

http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf

It is connected via a UART at 19200 baud.

gprs.jpg
// Instantiate a GroveGPRS Module on UART 0
upm::GroveGPRS sensor(0);
// Set the baud rate, 19200 baud is the default.
if (sensor.setBaudRate(19200) != 0) {
cerr << "Failed to set tty baud rate" << endl;
return 1;
}
printUsage(argv[0]);
if (argc > 1) {
cout << "Sending command line argument (" << argv[1] << ")..." << endl;
sendCommand(sensor, argv[1]);
} else {
// query the module manufacturer
cout << "Querying module manufacturer (AT+CGMI)..." << endl;
sendCommand(sensor, "AT+CGMI");
upm_delay(1);
// query the saved profiles
cout << "Querying the saved profiles (AT&V)..." << endl;
sendCommand(sensor, "AT&V");
// A comprehensive list is available from the datasheet at:
// http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf
}

Public Member Functions

 GroveGPRS (int uart=GROVEGPRS_DEFAULT_UART)
 
 ~GroveGPRS ()
 
bool dataAvailable (unsigned int millis)
 
int readData (char *buffer, unsigned int len)
 
std::string readDataStr (int len)
 
int writeData (char *buffer, unsigned len)
 
int writeDataStr (std::string data)
 
int setBaudRate (int baud=19200)
 

Protected Attributes

mraa::Uart m_uart
 

Constructor & Destructor Documentation

GroveGPRS ( int  uart = GROVEGPRS_DEFAULT_UART)

GroveGPRS object constructor

Parameters
uartDefault UART to use (0 or 1). Default is 0.
~GroveGPRS ( )

GroveGPRS object destructor

Member Function Documentation

bool dataAvailable ( unsigned int  millis)

Checks to see if there is data available for reading

Parameters
millisNumber of milliseconds to wait; 0 means no waiting
Returns
true if there is data available for reading
int readData ( char *  buffer,
unsigned int  len 
)

Reads any available data into a user-supplied buffer. Note: the call blocks until data is available for reading. Use dataAvailable() to determine whether there is data available beforehand, to avoid blocking.

Parameters
bufferBuffer to hold the data read
lenLength of the buffer
Returns
Number of bytes read
std::string readDataStr ( int  len)

Reads any available data and returns it in a std::string. Note: the call blocks until data is available for reading. Use dataAvailable() to determine whether there is data available beforehand, to avoid blocking.

Parameters
lenMaximum length of the data to be returned
Returns
Number of bytes read
int writeData ( char *  buffer,
unsigned  len 
)

Writes the data in the buffer to the device. If you are writing a command, be sure to terminate it with a carriage return ()

Parameters
bufferBuffer to hold the data to write
lenLength of the buffer
Returns
Number of bytes written
int writeDataStr ( std::string  data)

Writes the std:string data to the device. If you are writing a command, be sure to terminate it with a carriage return ()

Parameters
dataBuffer to write to the device
Returns
Number of bytes written
int setBaudRate ( int  baud = 19200)

Sets the baud rate for the device. The default is 19200.

Parameters
baudDesired baud rate.
Returns
true if successful

The documentation for this class was generated from the following files: