Tutorial.GSMToolsPinManagement History

Hide minor edits - Show changes to markup

March 11, 2013, at 10:26 AM by Scott Fitzgerald -
Changed lines 374-385 from:
to:
February 04, 2013, at 10:11 AM by Scott Fitzgerald -
Changed lines 43-44 from:

In setup, open a serial connection to the computer. After opening the connection, send a message to the Serial Monitor indicating the sketch has started. Call @PINManager.begin()@@ to reset the modem.

to:

In setup, open a serial connection to the computer. After opening the connection, send a message to the Serial Monitor indicating the sketch has started. Call PINManager.begin() to reset the modem.

Changed lines 116-117 from:

If there's no PIN number, set the auth flag to @@true@

to:

If there's no PIN number, set the auth flag to true

February 04, 2013, at 10:05 AM by Scott Fitzgerald -
Changed lines 5-6 from:

This example helps you change or remove the PIN of a SIM card.

to:

This example helps you change or remove the PIN of a SIM card with an Arduino and GSM shield.

Changed lines 27-32 from:

SIM cards may have a PIN number that enables their functionality. Define the PIN for your SIM. If your SIM has no PIN, you can leave it blank :

#define PINNUMBER ""

Initialize instances of the classes you're going to use. You're going to need the GSM, GSMScanner, and GSMModem classes.

to:

Initialize an instance of the GSMPin class.

GSMPIN PINManager;

Create your variables, starting with a String to hold input from the serial monitor. Also make a flag for checking f the SIM has been authenticated with a valid PIN, and messages for the serial monitor.

Changed lines 34-36 from:

GSM gsmAccess; GSMScanner scannerNetworks; GSMModem modemTest;

to:

String user_input = "";

boolean auth = false;

String oktext = "OK"; String errortext = "ERROR";

Changed lines 42-43 from:

Create a variable to hold the IMEI number, and a status messages to send to the serial monitor:

to:

In setup, open a serial connection to the computer. After opening the connection, send a message to the Serial Monitor indicating the sketch has started. Call @PINManager.begin()@@ to reset the modem.

Changed lines 46-48 from:

String IMEI = "";

String errortext = "ERROR";

to:

void setup(){

  Serial.begin(9600); 
  Serial.println("Change PIN example\n");
  PINManager.begin();
Changed lines 52-54 from:

In setup, open a serial connection to the computer. After opening the connection, send a message to the Serial Monitor indicating the sketch has started. Call @scannerNetworks.begin()@@ to reset the modem.

to:

Check to see if the SIM is locked with a PIN

Changed lines 55-58 from:

void setup(){

  Serial.begin(9600); 
  Serial.println("GSM networks scanner");
  scannerNetworks.begin();
to:
  while(!auth){
    int pin_query = PINManager.isPIN();
    if(pin_query == 1)
    {
Changed lines 61-62 from:

Create a local variable to track the connection status. You'll use this to keep the sketch from starting until the SIM is connected to the network :

to:

If locked, ask for the PIN via the serial monitor. You'll use a custom function named readSerial() to parse the information.

Changed lines 64-65 from:
  boolean notConnected = true;
to:
      Serial.print("Enter PIN code: ");
      user_input = readSerial();
Changed lines 68-69 from:

Connect to the network by calling gsmAccess.begin(). It takes the SIM card's PIN as an argument. By placing this inside a while() loop, you can continually check the status of the connection. When the modem does connect, gsmAccess() will return GSM_READY. Use this as a flag to set the notConnected variable to true or false. Once connected, the remainder of setup will run.

to:

If the PIN is valid, set the auth flag to true. Send a status message to the serial monitor indicating the result. If you enter the wrong PIN, you can try again. After 3 missed attempts, the PIN will be locked, and you'll need the PUK number to unlock.

Changed lines 71-78 from:
  while(notConnected)
  {
    if(gsmAccess.begin(PINNUMBER)==GSM_READY)
      notConnected = false;
    else
    {
      Serial.println("Not connected");
      delay(1000);
to:
      if(PINManager.checkPIN(user_input) == 0)
      {
        auth = true;
        PINManager.setPINUsed(true);
        Serial.println(oktext);
      }
      else
      {  
        Serial.println("Incorrect PIN. Remember that you have 3 opportunities.");
      }
Deleted line 81:
  }
Changed lines 84-85 from:

Get the IMEI of the modem with modemTest.getIMEI() and print it out to the serial monitor.

to:

If the SIM is in PUK lock mode, ask for the PUK code and a new PIN

Changed lines 87-91 from:
  Serial.print("Modem IMEI: ");
  IMEI = modemTest.getIMEI();
  IMEI.replace("\n","");
  if(IMEI != NULL)
    Serial.println(IMEI);
to:
    else if(pin_query == -1)
    {
      Serial.println("PIN locked. Enter PUK code: ");
      String puk = readSerial();
      Serial.print("Now, enter a new PIN code: ");
      user_input = readSerial();
      if(PINManager.checkPUK(puk, user_input) == 0)
      {
        auth = true;
        PINManager.setPINUsed(true);
        Serial.println(oktext);
      }
      else
      {
        Serial.println("Incorrect PUK or invalid new PIN. Try again!.");
      }
    }
Changed lines 106-108 from:

In loop(), scan and print out all available networks. This may take some time

to:

If there is an error, and the PIN number and PUK are both locked, send an appropriate status message :

Changed lines 109-110 from:
  Serial.println("Scanning available networks. May take some seconds.");
  Serial.println(scannerNetworks.readNetworks());
to:
    else if(pin_query == -2)
    {
      Serial.println("PIN & PUK locked. Use PIN2/PUK2 in a mobile phone.");
      while(true);
    }
Changed lines 116-117 from:

Print out the current connected carrier, and the strength of the signal. Signal strength is on a scale of 0-31, where 0 is the lowest, and 31 is the highest. close the loop().

to:

If there's no PIN number, set the auth flag to @@true@

Changed lines 119-124 from:
  Serial.print("Current carrier: ");
  Serial.println(scannerNetworks.getCurrentCarrier());

  Serial.print("Signal Strength: ");
  Serial.print(scannerNetworks.getSignalStrength());
  Serial.println(" [0-31]");
to:
    else
    {
      // SIM does not requires authetication 
      Serial.println("No pin necessary.");
      auth = true;
    }
  }
Changed lines 128-130 from:
to:

Check the registration on the GSM network, and indicate if you're connected or not, and if you're roaming.

Changed lines 131-158 from:

/*

 This example helps you change your pin or remove it.

 Circuit:
 * GSM shield attached

 Created 12 Jun 2012
 by David del Peral
 */

// libraries

  1. include <GSM.h>

// pin manager object GSMPIN PINManager;

// save input in serial by user String user_input = "";

// authenticated with PIN code boolean auth = false;

// serial monitor result messages String oktext = "OK"; String errortext = "ERROR";

void setup()

to:
Changed lines 149-158 from:
  // initialize serial communications
  Serial.begin(9600);

  Serial.println("Change PIN example\n");
  PINManager.begin();

  // check if the SIM have pin lock
  while(!auth){
    int pin_query = PINManager.isPIN();
    if(pin_query == 1)
to:
Changed lines 160-164 from:
      // if SIM is locked, enter PIN code
      Serial.print("Enter PIN code: ");
      user_input = readSerial();
      // check PIN code
      if(PINManager.checkPIN(user_input) == 0)
to:
      char inChar = Serial.read();
      if (inChar == '\n')
Changed lines 163-165 from:
        auth = true;
        PINManager.setPINUsed(true);
        Serial.println(oktext);
to:
        return text;
Changed lines 165-169 from:
      else
      {  
        // if PIN code was incorrected
        Serial.println("Incorrect PIN. Remember that you have 3 opportunities.");
      }
to:
      if(inChar!='\r')
        text += inChar;
Deleted lines 167-198:
    else if(pin_query == -1)
    {
      // PIN code is locked, user must enter PUK code
      Serial.println("PIN locked. Enter PUK code: ");
      String puk = readSerial();
      Serial.print("Now, enter a new PIN code: ");
      user_input = readSerial();
      // check PUK code
      if(PINManager.checkPUK(puk, user_input) == 0)
      {
        auth = true;
        PINManager.setPINUsed(true);
        Serial.println(oktext);
      }
      else
      {
        // if PUK o the new PIN are incorrect
        Serial.println("Incorrect PUK or invalid new PIN. Try again!.");
      }
    }
    else if(pin_query == -2)
    {
      // the worst case, PIN and PUK are locked
      Serial.println("PIN & PUK locked. Use PIN2/PUK2 in a mobile phone.");
      while(true);
    }
    else
    {
      // SIM does not requires authetication 
      Serial.println("No pin necessary.");
      auth = true;
    }
Deleted lines 168-181:
  // start GSM shield
  Serial.print("Checking register in GSM network...");
  if(PINManager.checkReg() == 0)
    Serial.println(oktext);
  // if you are connect by roaming
  else if(PINManager.checkReg() == 1)
    Serial.println("ROAMING " + oktext);  
  else
  {
    // error connection
    Serial.println(errortext);
    while(true);
  }
Changed lines 170-174 from:
to:
Changed lines 177-180 from:
  // Function loop implements pin management user menu
  // Only if you SIM use pin lock, you can change PIN code
  // user_op variables save user option
to:
Changed line 186 from:
    // activate/deactivate PIN lock
to:
Changed line 195 from:
    // change PIN
to:
Changed lines 204-209 from:
to:
Changed lines 211-218 from:
  Read input serial
to:
 This example helps you change your pin or remove it.

 Circuit:
 * GSM shield attached

 Created 12 Jun 2012
 by David del Peral
Changed lines 220-237 from:

String readSerial()

to:

// libraries

  1. include <GSM.h>

// pin manager object GSMPIN PINManager;

// save input in serial by user String user_input = "";

// authenticated with PIN code boolean auth = false;

// serial monitor result messages String oktext = "OK"; String errortext = "ERROR";

void setup()

Changed lines 239-242 from:
  String text = "";
  while(1)
  {
    while (Serial.available() > 0)
to:
  // initialize serial communications
  Serial.begin(9600);

  Serial.println("Change PIN example\n");
  PINManager.begin();

  // check if the SIM have pin lock
  while(!auth){
    int pin_query = PINManager.isPIN();
    if(pin_query == 1)
Changed lines 250-251 from:
      char inChar = Serial.read();
      if (inChar == '\n')
to:
      // if SIM is locked, enter PIN code
      Serial.print("Enter PIN code: ");
      user_input = readSerial();
      // check PIN code
      if(PINManager.checkPIN(user_input) == 0)
Changed lines 256-258 from:
        return text;
to:
        auth = true;
        PINManager.setPINUsed(true);
        Serial.println(oktext);
Changed lines 260-261 from:
      if(inChar!='\r')
        text += inChar;
to:
      else
      {  
        // if PIN code was incorrected
        Serial.println("Incorrect PIN. Remember that you have 3 opportunities.");
      }
Added lines 266-297:
    else if(pin_query == -1)
    {
      // PIN code is locked, user must enter PUK code
      Serial.println("PIN locked. Enter PUK code: ");
      String puk = readSerial();
      Serial.print("Now, enter a new PIN code: ");
      user_input = readSerial();
      // check PUK code
      if(PINManager.checkPUK(puk, user_input) == 0)
      {
        auth = true;
        PINManager.setPINUsed(true);
        Serial.println(oktext);
      }
      else
      {
        // if PUK o the new PIN are incorrect
        Serial.println("Incorrect PUK or invalid new PIN. Try again!.");
      }
    }
    else if(pin_query == -2)
    {
      // the worst case, PIN and PUK are locked
      Serial.println("PIN & PUK locked. Use PIN2/PUK2 in a mobile phone.");
      while(true);
    }
    else
    {
      // SIM does not requires authetication 
      Serial.println("No pin necessary.");
      auth = true;
    }
Added lines 299-312:
  // start GSM shield
  Serial.print("Checking register in GSM network...");
  if(PINManager.checkReg() == 0)
    Serial.println(oktext);
  // if you are connect by roaming
  else if(PINManager.checkReg() == 1)
    Serial.println("ROAMING " + oktext);  
  else
  {
    // error connection
    Serial.println(errortext);
    while(true);
  }
Added lines 314-367:

void loop() {

  // Function loop implements pin management user menu
  // Only if you SIM use pin lock, you can change PIN code
  // user_op variables save user option

  Serial.println("Choose an option:\n1 - On/Off PIN.");
  if(PINManager.getPINUsed())
    Serial.println("2 - Change PIN.");
  String user_op = readSerial();
  if(user_op == "1")
  {
    Serial.println("Enter your PIN code:");
    user_input = readSerial();
    // activate/deactivate PIN lock
    PINManager.switchPIN(user_input);
  }
  else if(user_op == "2" & PINManager.getPINUsed())
  {
    Serial.println("Enter your actual PIN code:");
    String oldPIN = readSerial();
    Serial.println("Now, enter your new PIN code:");
    String newPIN = readSerial();
    // change PIN
    PINManager.changePIN(oldPIN, newPIN);
  }
  else
  {
    Serial.println("Incorrect option. Try again!.");
  }
  delay(1000);

}

/*

  Read input serial
 */

String readSerial() {

  String text = "";
  while(1)
  {
    while (Serial.available() > 0)
    {
      char inChar = Serial.read();
      if (inChar == '\n')
      {
        return text;
      }
      if(inChar!='\r')
        text += inChar;
    }
  }

}

February 04, 2013, at 09:34 AM by Scott Fitzgerald -
Changed lines 3-6 from:

GSM PIN management

This sketch allows you to get information about the PIN of your SIM card. You can also change the PIN if necessary.

to:

GSM PIN Management

This example helps you change or remove the PIN of a SIM card.

Changed line 11 from:
  • SIM card with a data connection
to:
  • SIM card
Changed lines 31-32 from:

Define a number of constants that contain information about the GPRS network you're going to connect to. You'll need the Access Point Name (APN), login, and password. To obtain this information, contact your network provider for the most up to date information. This page has some information about various carrier settings, but it may not be current.

to:

Initialize instances of the classes you're going to use. You're going to need the GSM, GSMScanner, and GSMModem classes.

Changed lines 34-36 from:
  1. define GPRS_APN "GPRS_APN"
  2. define GPRS_LOGIN "login"
  3. define GPRS_PASSWORD "password"
to:

GSM gsmAccess; GSMScanner scannerNetworks; GSMModem modemTest;

Changed lines 39-40 from:

Initialize instances of the classes you're going to use. You're going to need the GSM, GPRS, GSMServer, and GSMClient classes. When you instantiate the GSMServer class, you'll need to tell it which port to listen for incoming connections. Port 80 is the default port for HTTP requests.

to:

Create a variable to hold the IMEI number, and a status messages to send to the serial monitor:

Changed lines 42-45 from:

GSMClient client; GPRS gprs; GSM gsmAccess; GSMServer server(80);

to:

String IMEI = "";

String errortext = "ERROR";

Changed lines 47-48 from:

Create some variables to set a timeout period, flag incoming client messages, and a buffer to read incoming bytes. to hold the server, path, and port you wish to connect to.

to:

In setup, open a serial connection to the computer. After opening the connection, send a message to the Serial Monitor indicating the sketch has started. Call @scannerNetworks.begin()@@ to reset the modem.

Changed lines 51-53 from:

char server[] = "arduino.cc"; char path[] = "/"; int port = 80;

to:

void setup(){

  Serial.begin(9600); 
  Serial.println("GSM networks scanner");
  scannerNetworks.begin();
Changed lines 57-58 from:

In setup, open a serial connection to the computer. After opening the connection, send a message indicating the sketch has started.

to:

Create a local variable to track the connection status. You'll use this to keep the sketch from starting until the SIM is connected to the network :

Changed lines 60-62 from:

void setup(){

  Serial.begin(9600); 
  Serial.println("Starting Arduino web client.");
to:
  boolean notConnected = true;
Changed lines 63-64 from:

Create a local variable to track the connection status. You'll use this to keep the sketch from starting until the SIM is connected to the network :

to:

Connect to the network by calling gsmAccess.begin(). It takes the SIM card's PIN as an argument. By placing this inside a while() loop, you can continually check the status of the connection. When the modem does connect, gsmAccess() will return GSM_READY. Use this as a flag to set the notConnected variable to true or false. Once connected, the remainder of setup will run.

Deleted lines 65-72:
Deleted line 68:
        (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
Changed lines 78-79 from:

Attempt to connect to the server using client.connect(). connect() requires two arguments, the server and port. Once connected to the server, make a HTTP request by calling client.print(). A typical web request looks like "GET pathname HTTP/1.0". print will send the message, just as a browser would.

to:

Get the IMEI of the modem with modemTest.getIMEI() and print it out to the serial monitor.

Changed lines 81-88 from:
  if (client.connect(server, port))
  {
    Serial.println("connected");
    client.print("GET ");
    client.print(path);
    client.println(" HTTP/1.0");
    client.println();
  } 
to:
  Serial.print("Modem IMEI: ");
  IMEI = modemTest.getIMEI();
  IMEI.replace("\n","");
  if(IMEI != NULL)
    Serial.println(IMEI);
Changed lines 88-89 from:

If the connection to the server failed, make a note of it in the serial monitor, and close up setup.

to:

In loop(), scan and print out all available networks. This may take some time

Changed lines 92-96 from:
  else
  {
    Serial.println("connection failed");
  }

}

to:
  Serial.println("Scanning available networks. May take some seconds.");
  Serial.println(scannerNetworks.readNetworks());
Changed lines 96-97 from:

Inside loop, check to see if there are bytes returned from the server. If so, read them and print them to the serial monitor.

to:

Print out the current connected carrier, and the strength of the signal. Signal strength is on a scale of 0-31, where 0 is the lowest, and 31 is the highest. close the loop().

Changed lines 99-103 from:
  if (client.available())
  {
    char c = client.read();
    Serial.print(c);
  }
to:
  Serial.print("Current carrier: ");
  Serial.println(scannerNetworks.getCurrentCarrier());

  Serial.print("Signal Strength: ");
  Serial.print(scannerNetworks.getSignalStrength());
  Serial.println(" [0-31]");
Changed lines 107-108 from:

If the server disconnects, which it will typically do once it has completed the HTTP request, stop the client locally and close the loop.

to:
Changed lines 111-125 from:
to:

/*

Changed lines 113-116 from:
to:
 This example helps you change your pin or remove it.
Deleted lines 114-120:
 This sketch connects an analog sensor to Pachube (http://www.pachube.com)
 using a Telefonica GSM/GPRS shield.

 This example has been updated to use version 2.0 of the Pachube.com API. 
 To make it work, create a feed with a datastream, and give it the ID
 sensor1. Or change the code below to match your feed.
Changed lines 116-117 from:
 * Analog sensor attached to analog in 0
 * GSM shield attached to pins 10, 11, 12, 13
to:
 * GSM shield attached
Changed lines 118-123 from:
 created 4 March 2012
 by Tom Igoe
 and adapted for GSM shield by David Del Peral

 This code is in the public domain.
to:
 Created 12 Jun 2012
 by David del Peral
Changed lines 125-151 from:

// Pachube Client data

  1. define APIKEY "YOUR API KEY GOES HERE" // replace your pachube api key here
  2. define FEEDID 00000 // replace your feed ID
  3. define USERAGENT "My Project" // user agent is the project name

// PIN Number

  1. define PINNUMBER ""

// APN data

  1. define GPRS_APN "GPRS_APN" // replace your GPRS APN
  2. define GPRS_LOGIN "login" // replace with your GPRS login
  3. define GPRS_PASSWORD "password" // replace with your GPRS password

// initialize the library instance: GSMClient client; GPRS gprs; GSM gsmAccess; // include a 'true' parameter for debug enabled

// if you don't want to use DNS (and reduce your sketch size) // use the numeric IP instead of the name for the server: //IPAddress server(216,52,233,121); // numeric IP for api.pachube.com char server[] = "api.pachube.com"; // name address for pachube API

unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds boolean lastConnected = false; // state of the connection last time through the main loop const unsigned long postingInterval = 10*1000; //delay between updates to Pachube.com

to:

// pin manager object GSMPIN PINManager;

// save input in serial by user String user_input = "";

// authenticated with PIN code boolean auth = false;

// serial monitor result messages String oktext = "OK"; String errortext = "ERROR";

Changed lines 143-144 from:
  // connection state
  boolean notConnected = true;
to:
  Serial.println("Change PIN example\n");
  PINManager.begin();
Changed lines 146-153 from:
  // Start GSM shield
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  while(notConnected)
  {
    if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
        (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
      notConnected = false;
    else
to:
  // check if the SIM have pin lock
  while(!auth){
    int pin_query = PINManager.isPIN();
    if(pin_query == 1)
Changed lines 151-152 from:
      Serial.println("Not connected");
      delay(1000);
to:
      // if SIM is locked, enter PIN code
      Serial.print("Enter PIN code: ");
      user_input = readSerial();
      // check PIN code
      if(PINManager.checkPIN(user_input) == 0)
      {
        auth = true;
        PINManager.setPINUsed(true);
        Serial.println(oktext);
      }
      else
      {  
        // if PIN code was incorrected
        Serial.println("Incorrect PIN. Remember that you have 3 opportunities.");
      }
Added lines 167-198:
    else if(pin_query == -1)
    {
      // PIN code is locked, user must enter PUK code
      Serial.println("PIN locked. Enter PUK code: ");
      String puk = readSerial();
      Serial.print("Now, enter a new PIN code: ");
      user_input = readSerial();
      // check PUK code
      if(PINManager.checkPUK(puk, user_input) == 0)
      {
        auth = true;
        PINManager.setPINUsed(true);
        Serial.println(oktext);
      }
      else
      {
        // if PUK o the new PIN are incorrect
        Serial.println("Incorrect PUK or invalid new PIN. Try again!.");
      }
    }
    else if(pin_query == -2)
    {
      // the worst case, PIN and PUK are locked
      Serial.println("PIN & PUK locked. Use PIN2/PUK2 in a mobile phone.");
      while(true);
    }
    else
    {
      // SIM does not requires authetication 
      Serial.println("No pin necessary.");
      auth = true;
    }
Added lines 200-213:
  // start GSM shield
  Serial.print("Checking register in GSM network...");
  if(PINManager.checkReg() == 0)
    Serial.println(oktext);
  // if you are connect by roaming
  else if(PINManager.checkReg() == 1)
    Serial.println("ROAMING " + oktext);  
  else
  {
    // error connection
    Serial.println(errortext);
    while(true);
  }
Changed lines 217-224 from:

{

  // read the analog sensor:
  int sensorReading = analogRead(A0);   

  // if there's incoming data from the net connection.
  // send it out the serial port.  This is for debugging
  // purposes only:
  if (client.available())
to:

{

  // Function loop implements pin management user menu
  // Only if you SIM use pin lock, you can change PIN code
  // user_op variables save user option

  Serial.println("Choose an option:\n1 - On/Off PIN.");
  if(PINManager.getPINUsed())
    Serial.println("2 - Change PIN.");
  String user_op = readSerial();
  if(user_op == "1")
Changed lines 228-229 from:
     char c = client.read();
     Serial.print(c);
to:
    Serial.println("Enter your PIN code:");
    user_input = readSerial();
    // activate/deactivate PIN lock
    PINManager.switchPIN(user_input);
Changed lines 233-236 from:
  // if there's no net connection, but there was one last time
  // through the loop, then stop the client:
  if (!client.connected() && lastConnected)
to:
  else if(user_op == "2" & PINManager.getPINUsed())
Changed lines 235-240 from:
    client.stop();
to:
    Serial.println("Enter your actual PIN code:");
    String oldPIN = readSerial();
    Serial.println("Now, enter your new PIN code:");
    String newPIN = readSerial();
    // change PIN
    PINManager.changePIN(oldPIN, newPIN);
Changed lines 242-245 from:
  // if you're not connected, and ten seconds have passed since
  // your last connection, then connect again and send data:
  if(!client.connected() && ((millis() - lastConnectionTime) > postingInterval))
to:
  else
Changed line 244 from:
  sendData(sensorReading);
to:
    Serial.println("Incorrect option. Try again!.");
Changed lines 246-249 from:
  // store the state of the connection for next time through
  // the loop:
  lastConnected = client.connected();
to:
  delay(1000);
Changed lines 250-252 from:
  This method makes a HTTP connection to the server.
  • /

void sendData(int thisData)

to:
  Read input serial
 */

String readSerial()

Changed lines 254-255 from:
  // if there's a successful connection:
  if (client.connect(server, 80))
to:
  String text = "";
  while(1)
Changed lines 257-290 from:
    Serial.println("connecting...");

    // send the HTTP PUT request:
    client.print("PUT /v2/feeds/");
    client.print(FEEDID);
    client.println(".csv HTTP/1.1");
    client.print("Host: api.pachube.com\n");
    client.print("X-ApiKey: ");
    client.println(APIKEY);
    client.print("User-Agent: ");
    client.println(USERAGENT);
    client.print("Content-Length: ");

    // calculate the length of the sensor reading in bytes:
    // 8 bytes for "sensor1," + number of digits of the data:
    int thisLength = 8 + getLength(thisData);
    client.println(thisLength);

    // last pieces of the HTTP PUT request:
    client.print("Content-Type: text/csv\n");
    client.println("Connection: close");
    client.println();

    // here's the actual content of the PUT request:
    client.print("sensor1,");
    client.println(thisData);
  } 
  else
  {
    // if you couldn't make a connection:
    Serial.println("connection failed");
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
to:
    while (Serial.available() > 0)
    {
      char inChar = Serial.read();
      if (inChar == '\n')
      {
        return text;
      }
      if(inChar!='\r')
        text += inChar;
    }
Deleted lines 267-268:
  // note the time that the connection was made or attempted
  lastConnectionTime = millis();
Deleted lines 268-293:

/*

  This method calculates the number of digits in the
  sensor reading.  Since each digit of the ASCII decimal
  representation is a byte, the number of digits equals
  the number of bytes.
  • /

int getLength(int someValue) {

  // there's at least one byte:
  int digits = 1;

  // continually divide the value by ten, 
  // adding one to the digit count for each
  // time you divide, until you're at 0:
  int dividend = someValue /10;
  while (dividend > 0)
  {
    dividend = dividend /10;
    digits++;
  }

  // return the number of digits:
  return digits;

}

February 03, 2013, at 07:27 PM by Scott Fitzgerald -
Changed lines 1-6 from:

Examples > Make Voice Call

Using the GSM Shield to Make Calls

This example shows how to use the GSM Shield and Library to make voice calls. Please click here for more information on the GSM library.

to:

Examples > GSM library

GSM PIN management

This sketch allows you to get information about the PIN of your SIM card. You can also change the PIN if necessary.

Changed line 11 from:
  • SIM card
to:
  • SIM card with a data connection
Changed lines 23-25 from:

The code below is configured for use with a GSM/GPRS shield. In the variable declaration area, you need to instantiate both the GSM and GSMVoiceCall classes. Inside setup(), call GSM.begin(), with the PINNUMBER of your SIM card as parameter. GSM.begin() will return whether the shield managed to connect to the GSM network or not.

In the loop(), the input from the Serial Monitor is used to tell the GSM Shield a phone number to call to. The code waits until the call is over before performing any other actions.

to:
Changed lines 141-322 from:
to:
Changed line 328 from:
to:
November 16, 2012, at 07:58 PM by Scott Fitzgerald -
Added lines 1-34:

Share