buon di a tutti, ho fatto questo semplice antifurto che viene attivato mediante un squillo, e se nel caso il pin in ingresso va alto chiama 2 numeri.
e qui funziona.
avrei bisogno di capire come posso creare una variabile che mi indica se in gsm e' connesso in rete ,
e in base a questa variabile faccio delle azioni, cosi divise;
che nel caso affermativo parte con le chiamate , altrimenti mi va in reset la scheda con la sim .
vi ringrazio per qualche informazioni in merito , buona giornata
//SIM800L
// tx pin 2
// rx pin 3
unsigned long Tempo = 0;
//int voiceCall(10000);
// Include the GSM library
#include <GSM.h>
GSM_SMS sms;
boolean allarme = 1;
boolean presenza = 0;
#define LED 13
#define PULSANTE 10
// PIN Number
#define PINNUMBER //""
int fase = 0;
int all = 1;
// initialize the library instance
GSM gsmAccess;
GSMVoiceCall vcs;
// Array to hold the number for the incoming call
char numtel[20];
void setup() {
// initialize serial communications and wait for port to open:
Serial.begin(9600);
pinMode(10, INPUT_PULLUP);
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("connessione rete gsm");
// connection state
boolean notConnected = true;
// 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) {
notConnected = false;
} else {
Serial.println("Not connected");
delay(1000);
}
}
// This makes sure the modem correctly reports incoming events
vcs.hangCall();
Serial.println("attesa evento");
}
void loop() {
switch (allarme) {
case 0:
digitalWrite(LED, LOW);
break;
case 1:
digitalWrite(LED, HIGH);
break;
}
if (digitalRead(10) == LOW) {
presenza = 1;
}
else {
presenza = 0;
}
if ( presenza == 1 && all == 1) {
all = 0;
fase = 1;
}
switch (fase) {
case 1: {
Serial.println(" 1 chiamo daniele");
vcs.voiceCall("+393294156602", 5000);
Tempo = millis();
fase = 2;
}
break;
case 2: {
if (millis() - Tempo > 5500) {
Serial.println(" 2 fine chiamata daniele");
vcs.hangCall(); //serve per far cadere la chiamata
fase = 3;
Tempo = millis();
}
}
break;
case 3: {
if (millis() - Tempo > 1500) {
Serial.println(" 3 chiamo olindo");
vcs.voiceCall("+393294156602", 5000);
Tempo = millis();
fase = 4;
}
}
break;
case 4: {
if (millis() - Tempo > 7000) {
Tempo = millis();
Serial.println("4 fine chiamata olindo");
vcs.hangCall(); //serve per far cadere la chiamata
fase = 5;
}
}
break;
case 5: {
if (millis() - Tempo > 1000) {
all = 1;
//Serial.println("fine fasi");
}
}
break;
}
// Check the status of the voice call
switch (vcs.getvoiceCallStatus()) {
case IDLE_CALL: // Nothing is happening
break;
case RECEIVINGCALL: // Yes! Someone is calling us
Serial.println("RECEIVING CALL");
// Retrieve the calling number
vcs.retrieveCallingNumber(numtel, 20);
if ((strcmp(numtel, "+390185358719") == 0) || (strcmp(numtel, "+393381231212") == 0)) {
Serial.println(allarme);
allarme = !allarme;
vcs.hangCall(); //serve per far cadere la chiamata
}
else
Serial.println(" => non riconosciuto!");
vcs.hangCall();
}
}