Hardware Reference
In-Depth Information
Don't be frightened by the large number of i les. For most applications, you
can simply include the GSM library #include <GSM.h> .
Because the GSM library is complex, its different usage is separated into
classes. There are classes to manage GPRS connections: SMS messages, and
voice calls, to name but a few.
GSM Class
The GSM class is responsible for initializing the shield and the on-board GSM
device. It is initialized like this:
GSM GSMAccess
GSM GSMAccess(debug)
The debug parameter is optional. It is a boolean and is false by default. If set
to true , the GSM device outputs AT commands to the console.
To connect to the GSM network, use the begin() function:
GSMAccess .begin();
GSMAccess .begin(pin);
GSMAccess .begin(pin, restart);
GSMAccess .begin(pin, restart, sync);
The pin parameter is a character array that contains the PIN code for the SIM
card connected to the GSM shield. If your SIM card does not have a PIN code,
you can omit this parameter. The restart parameter is a boolean and specii es
if the modem is to be restarted. By default, this parameter is true , resulting in
a modem restart. The sync parameter is a boolean and sets the synchroniza-
tion to the base station. In a synchronous coni guration, the sketch can tell if
an operation has completed. In an asynchronous coni guration, operations are
scheduled, and their result isn't always immediately available. By default, it is
set to true . All the return codes listed in this chapter correspond to a synchro-
nous coni guration.
This function returns a char indicating the status of the modem: ERROR , IDLE ,
CONNECTING , GSM_READY , GPRS_READY , or TRANSPARENT_CONNECTED .
This can be used as follows:
#include <GSM.h>
#define PINNUMBER "0000" // SIM card PIN
GSM gsm(true); // Debug AT messages
void setup()
{
// initialize serial communications
 
Search WWH ::




Custom Search