aboutsummaryrefslogtreecommitdiff
path: root/libraries/GSM/examples/ReceiveVoiceCall/ReceiveVoiceCall.ino
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@bug.st>2013-04-03 13:51:04 +0200
committerCristian Maglie <c.maglie@bug.st>2013-04-03 13:51:04 +0200
commitee90e68e86dd61d86f5d17b69080338328765b22 (patch)
treee620c0edc2690ab789b665e567910640597aa6fe /libraries/GSM/examples/ReceiveVoiceCall/ReceiveVoiceCall.ino
parent0ecdc5ebc96ad4c7c548c438a03d9ce00679db8b (diff)
parentf50c307be280dc6ece9e70c43b301c1db36291a0 (diff)
Merged 1.0.5
Merge remote-tracking branch 'arduino/master' into ide-1.5.x Conflicts: app/src/processing/app/Base.java build/shared/revisions.txt hardware/arduino/avr/cores/arduino/malloc.c hardware/arduino/cores/arduino/avr-libc/malloc.c hardware/arduino/cores/arduino/malloc.c todo.txt
Diffstat (limited to 'libraries/GSM/examples/ReceiveVoiceCall/ReceiveVoiceCall.ino')
-rw-r--r--libraries/GSM/examples/ReceiveVoiceCall/ReceiveVoiceCall.ino105
1 files changed, 105 insertions, 0 deletions
diff --git a/libraries/GSM/examples/ReceiveVoiceCall/ReceiveVoiceCall.ino b/libraries/GSM/examples/ReceiveVoiceCall/ReceiveVoiceCall.ino
new file mode 100644
index 0000000..14dbc5e
--- /dev/null
+++ b/libraries/GSM/examples/ReceiveVoiceCall/ReceiveVoiceCall.ino
@@ -0,0 +1,105 @@
+/*
+ Receive Voice Call
+
+ This sketch, for the Arduino GSM shield, receives voice calls,
+ displays the calling number, waits a few seconds then hangs up.
+
+ Circuit:
+ * GSM shield
+ * Voice circuit. Refer to to the GSM shield getting started guide
+ at http://arduino.cc/en/Guide/ArduinoGSMShield#toc11
+ * SIM card that can accept voice calls
+
+ With no voice circuit the call will connect, but will not send or receive sound
+
+ created Mar 2012
+ by Javier Zorzano
+
+ This example is in the public domain.
+
+ http://arduino.cc/en/Tutorial/GSMExamplesReceiveVoiceCall
+
+ */
+
+// Include the GSM library
+#include <GSM.h>
+
+// PIN Number
+#define PINNUMBER ""
+
+// 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);
+ while (!Serial) {
+ ; // wait for serial port to connect. Needed for Leonardo 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 number
+ vcs.retrieveCallingNumber(numtel, 20);
+
+ // Print the calling number
+ Serial.print("Number:");
+ 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;
+ }
+ delay(1000);
+}
+
+