#include "SIM900.h"
#include <SoftwareSerial.h>
#include "inetGSM.h"
//#include "sms.h"
#include "call.h"
//To change pins for Software Serial, use the two lines in GSM.cpp.
//GSM Shield for Arduino
//www.open-electronics.org
//this code is based on the example of Arduino Labs.
//Simple sketch to start a connection as client.
InetGSM inet;
CallGSM call;
//SMSGSM sms;
char msg[50];
int numdata;
char inSerial[50];
int i=0;
boolean started=true;
int pin=1;
byte stat=0;
char number[20];
void setup()
{
pinMode(pin,INPUT);
//Serial connection.
Serial.begin(9600);
Serial.println("GSM Shield testing.");
//Start configuration of shield with baudrate.
//For http uses is raccomanded to use 4800 or slower.
if (gsm.begin(4800)){
Serial.println("\nstatus=READY");
}
else Serial.println("\nstatus=IDLE");
};
void loop()
{
stat=call.CallStatusWithAuth(number,0,0);
//If the incoming call is from an authorized number
//saved on SIM in the positions range from 1 to 3.
if(stat==CALL_INCOM_VOICE_AUTH){
//Hang up the call.
call.HangUp();
delay(2000);
started=true;
if(started){
started=false;
// //GPRS attach, put in order APN, username and password.
// //If no needed auth let them blank.
if (inet.attachGPRS("wap.tim.it", "", ""))
Serial.println("status=ATTACHED");
else Serial.println("status=ERROR");
delay(1000);
//
// //Read IP address.
gsm.SimpleWriteln("AT+CIFSR");
delay(5000);
// //Read until serial buffer is empty.
gsm.WhileSimpleRead();
//
// //TCP Client GET, send a GET request to the server and
// //save the reply.
numdata=inet.httpGET("www.google.com", 80, "/", msg, 50);
// //Print the results.
Serial.println("\nNumber of data received:");
Serial.println(numdata);
Serial.println(msg);
}
}
delay(1000);
};