Loading...

This page is outdated. For information on using the GSM library with the current GSM shield, visit the GSM library reference pages.


GSM LIBRARY

INTRODUCTION

This document is intended to be a guide for using the GSM library for Arduino with a modem shield connected.

First we will describe the contents of the library directory, the installation, and how to invoke it. Then we will explain the functions inside the library and their mainly uses.

INSTALLATION

The library is a zip file containing a directory with several .h and .cpp files inside. The zip file must be extracted in the arduino-0022/libraries directory.

You must add the next lines for being able to use the GSM library functions: If you are using Quectel modem include:

  1. include “QuectelM10.h”
  2. include “inetGSM.h”

There are two main classes that are to be used with this library: QuectelM10, whose object “gsm” is already defined in the own library, and inetGSM.

FUNCTIONS

“”Class QuectelM10″” - start() This function starts (physically) the modem, registers to GSM and GPRS network, and configure SMSs in text mode. Important: the modem starts with the power off.

- shutdown() This function makes a shutdown of the modem. The modem will spend no power in this mode.

- sendSMS(const char* to, const char* msg) This function sends an SMS to the mobile number “to” with the text “msg”.

- readSMS (char* msg, int msglength, char* number, int nlength) Checks if there are available messages. Takes the first one and deletes it from modem memory. Returns message in msg, and original phone number in “number”. Msglength and nlength must hold the corresponding buffer size.

- boolean call(char* number, unsigned int milliseconds) Make a voice call. After milliseconds, hang it.

- boolean readCall(char* number, int nlength) Check if there is or there has been an incoming call. If true, fills number (up to nlength characters)

- attachGPRS(char* domain, char* dom1, char* dom2) This function attaches the modem to GPRS and configures it with the domain (APN) “domain”, user name “dom1” and password “dom2”.

- dettachGPRS() This function dettaches theGPRS connection.

- connectTCP(const char* server, int port) This function makes the connection of a TCP client to a DNS server “server” to a port “port”.

- disconnectTCP() This function cuts the connection of a TCP client.

- connectTCPServer(int port) This function connects the modem as a server in the port “port”.

- connectedClient() This function informs when the modem as a server, accepts a client.

- write(const uint8_t* buffer, size_t sz) This function is used to send data directly to the modem in data mode. Must be used after a connection is created (either as client or server)

- read(char* result, int resultlength) This function is used to read data from the modem in data mode. Must be used after a connection is created (either as client or server)

“”Class inetGSM”“

- httpGET(const char* server, int port, const char* path, char* result, int resultlength)

This function makes a get command as a TCPclient to a server “server” in port “port”, with the path “path”. The read data are returned in “result”.

- httpPOST(const char* server, int port, const char* path, const char* parameters, char* result, int resultlength)

This function makes a post command as a TCPclient to a server “server” in port “port”, with the path “path” and parameters “parameters”. The read data are returned in “result”.

- tweet(const char* token, const char* msg)

This function sends a message to twitter with the text “msg” and the token “token”. Get the token from http://arduino-tweet.appspot.com/