Bonjour,
je suis actuellement en train de tester un module gsm sim900.
Mon but est de lire un appel entrant et de le comparer avec des numéros que j'ai autorisé ou non.
J'ai réalisé un programme à partir de l'exemple du module gsm dans arduino, le voici:
#include <GSM.h>
#define PINNUMBER ""
// initialize the library instance
GSM gsmAccess;
GSMVoiceCall vcs;
// Array to hold the number for the incoming call
String fichier_tel[] = {"0265383785", "0693008050", "0160201524"};
char numtel[20];
String num_entrant;
int i;
int led = 3;
void setup() {
// initialize serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Receive Voice Call");
// 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("Waiting for a call");
}
void loop() {
// 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 8
vcs.retrieveCallingNumber(numtel, 20);
// Print the calling number
Serial.print("Number:");
Serial.println(numtel);
break;
i = 0 ;
while (Serial.available() > 0) {
numtel[i] = Serial.read();
num_entrant += numtel[i];
i++;
delay(100);
}
if (i > 0) {
Serial.println(num_entrant);
for (int j = 0; j < 9; j++) {
if (num_entrant == fichier_tel[j]) {
digitalWrite(led, HIGH);
} else {
digitalWrite(led, LOW);
}
}
}
}
}
Cependant il ne fonctionne pas et je ne comprend pas pourquoi..
Pourriez-vous m'aider svp ?