Answering, Rejecting, and Hanging Up
If a call is coming in –
phone.status()
is returning
CALL_INCOMING
– you
can use
phone.answer()
to pick it up.
If you’ve checked the caller ID and don’t really feel like talking to the
individual paired with that number, you have two options: ignore the call
until they hang up or run
phone.hangUp()
to reject the call.
Likewise, if you’ve answered the call and want to end it, call
phone.hangUp()
to close the line.
Dialing
If you want to initiate a phone call, use
phone.dial(char
*
phoneNumber)
to start dialing.
phoneNumber
should be a character array formatted like any
phone number you would dial from a normal phone. If you’re in the same
area code, it may be as few as 7 digits (assuming it’s a U.S. number). On
the other end of the spectrum, with international codes included, the
number can be as long as 15 digits.
Here’s a quick example:
char destinationPhone[]
= "13032840979";
//
SparkFun
HQ
1
30
3
284
0979
phone.dial(destinationPhone);
//
Dial
the
phone
number
Serial.println("Dialing");
do
{
int phoneStatus
= phone.status();
Serial.print(".");
}
while ((phoneStatus
!= CALL_ACTIVE)
|| (phoneStatus
!= CALL_
IDLE))
if (callStatus
== CALL_ACTIVE)
Serial.println("Other
end
picked
up!");
Again, you can use
phone.hangUp()
to end the call, unless the other party
does so first.
Example Bonus: Posting to Phant
The motivating factor behind us seeking out a solid cellular module was
finding a reliable tool to remotely post environment data to our data service
running Phant. We’d be remiss if we didn’t show at least one example of
how to use the hardware and IoT service together.
Download the Phant Library
A sketch included with the library – MG2639_Phant – requires an additional
library to take care of Phant posts. Download the library from our Phant-
Arduino repo, or by clicking the button below:
DOWNLO AD THE PHAN T ARDUINO LIBRARY
Again, follow the Installing an Arduino Library tutorial for help installing it.
If you already have the Phant Arduino library, make sure it's updated
to the latest version -- this sketch takes advantage of some flash-string
storage recently added to the library. Memory is at a real premium.
You'll get a compile error if the library isn't updated.
Running the Example
Open the MG2639_Phant example sketch by going to File > Examples >
SparkFun MG2639 CellShield > MG2639_Phant.
Page 20 of 22