mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
@ -1,24 +1,24 @@
|
||||
/*
|
||||
Receive Voice Call
|
||||
|
||||
This sketch, for the Arduino GSM shield, receives voice calls,
|
||||
|
||||
This sketch, for the Arduino GSM shield, receives voice calls,
|
||||
displays the calling number, waits a few seconds then hangs up.
|
||||
|
||||
|
||||
Circuit:
|
||||
* GSM shield
|
||||
* 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
|
||||
@ -32,7 +32,7 @@ GSM gsmAccess;
|
||||
GSMVoiceCall vcs;
|
||||
|
||||
// Array to hold the number for the incoming call
|
||||
char numtel[20];
|
||||
char numtel[20];
|
||||
|
||||
void setup()
|
||||
{
|
||||
@ -43,15 +43,15 @@ void setup()
|
||||
}
|
||||
|
||||
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)
|
||||
while (notConnected)
|
||||
{
|
||||
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
|
||||
if (gsmAccess.begin(PINNUMBER) == GSM_READY)
|
||||
notConnected = false;
|
||||
else
|
||||
{
|
||||
@ -59,44 +59,44 @@ void setup()
|
||||
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())
|
||||
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();
|
||||
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')
|
||||
while (Serial.read() != '\n')
|
||||
delay(100);
|
||||
vcs.hangCall();
|
||||
Serial.println("Hanging up and waiting for the next call.");
|
||||
Serial.println("Hanging up and waiting for the next call.");
|
||||
break;
|
||||
}
|
||||
delay(1000);
|
||||
|
Reference in New Issue
Block a user