Hello,
My code :
// include the GSM library
#include <GSM.h>// PIN Number for the SIM
#define PINNUMBER ""// initialize the library instances
GSM gsmAccess;
//GSM_SMS sms;
GSMVoiceCall vcs;
// Array to hold the number a SMS is retreived from
char senderNumber[20];
// Array to hold the number for the incoming call
char numtel[20];void setup() {
// put your setup code here, to run once:
// 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("gsmserver|message|SERIAL READY");
// 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("gsmserver|message|GSM MODEM NOT CONNECTING");
delay(1000);
}
}
// This makes sure the modem correctly reports incoming events
vcs.hangCall();
Serial.println("gsmserver|message|GSM SERVER READY");}
void loop() {
// put your main code here, to run repeatedly:
// Check the status of the voice call
char c;
switch (vcs.getvoiceCallStatus()) {
case IDLE_CALL: // Nothing is happeningbreak;
case RECEIVINGCALL: // Yes! Someone is calling us
// Serial.println("RECEIVING CALL");
// Retrieve the calling number
vcs.retrieveCallingNumber(numtel, 20);// Print the calling number
Serial.print("gsmserver|command|receivecall|");
Serial.println(numtel);// Answer the call, establish the call
// vcs.answerCall();
break;case TALKING: // In this case the call would be established
Serial.println("TALKING. Press enter to hang up.");
while (Serial.read() != '\n') {
delay(100);
}
vcs.hangCall();
Serial.println("Hanging up and waiting for the next call.");
break;
}
// If there are any SMSs available()
/*
if (sms.available()) {
Serial.print("gsmserver|command|receivesms|");// Get remote number
sms.remoteNumber(senderNumber, 20);
Serial.print(senderNumber);
Serial.print("|");// An example of message disposal
// Any messages starting with # should be discarded
if (sms.peek() == '#') {
Serial.println("Discarded SMS");
sms.flush();
}// Read message bytes and print them
while (c = sms.read()) {
Serial.print(c);
}Serial.println("");
// Delete message from modem memory
sms.flush();
//Serial.println("MESSAGE DELETED");
}*/delay(1000);
}
It is a combination of the recievecall and recievesms example.
When I use both GSM_SMS and GSM_voicecall classes, the program doens't show GSM SERVER READY.
When i command out GSM_SMS and command out the functions from the sms (like example here on top) then it workes?
It seems like I can't receive calls and receive sms at the same time?
Somebody who can help?
Greets John