If a call is coming in, the serial terminal will print a message saying so.
Press any key to answer it. While the call is active, press any key to hang
up.
Using the Library: Phone
Once again, to segment out the library, a separate class is defined for
phone functions:
phone
. Here is a quick rundown of functions made
available:
Incoming/Outgoing Phone Call Status
You can use
phone.status()
to check whether the phone is ringing,
dialing, active or idle. This function will return one of the following
constants:
• CALL_ACTIVE – Active phone call. Either an outgoing call has been
picked up or an incoming call was
phone.answer()
‘ed and hasn’t
been hung up yet.
• CALL_DIALING – An outgoing call is in the process of dialing. This
status precedes ringing.
• CALL_DIALED_RINGING – An outgoing call has been dialed and is
ringing on the other end.
• CALL_INCOMING – A call is coming in. If a speaker is attached it
should be ringing.
Check out the comments in the example sketch for help using this function.
Caller ID
If a call is coming in, you can use the
callerID(char
*
phoneNumber)
function to attempt to get the number. This function only returns an error
code, it requires a character array be passed to it by reference so it can
store the calling number there.
Here’s a simple function from the example that gets the caller ID and prints
it to the serial monitor:
void printCallerID()
{
char yourPhone[15];
phone.callerID(yourPhone);
Serial.print("Phone
call
coming
in
from:
");
Serial.println(yourPhone);
Serial.println("Press
any
key
to
answer.");
}
Page 19 of 22