getVoiceCallStatus()
描述
回传通话目前的状态。
语法
voice.getVoiceCallStatus()
参数
无参数
回传
char : IDLE_CALL, CALLING, RECEIVINGCALL, TALKING
范例
// 函式库
#include <GSM.h>
// PIN 码
#define PINNUMBER ""
// 初始化 GSM 函式库
GSM gsmAccess;
GSMVoiceCall vcs;
// 用来存放电话号码的字元阵列
char numtel[20];
void setup()
{
// 初始化 Serial
Serial.begin(9600);
Serial.println("Receive Voice Call");
// 连线状态
boolean notConnected = true;
// 启动 Arduino GSM shield,如果你的 SIM 卡有 PIN 码,请当作 begin() 的参数
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
// 先挂断通话,避免待会误判
vcs.hangCall();
Serial.println("Waiting Call");
}
void loop()
{
// 检查通话的状态
switch (vcs.getvoiceCallStatus())
{
// 什麽事都没发生
case IDLE_CALL:
break;
// 当没有播打电话的时候,不会发生这个情况
case CALLING:
Serial.println("CALLING");
break;
// 有来电!
case RECEIVINGCALL:
Serial.println("RECEIVING CALL");
// 取得来电号码
vcs.retrieveCallingNumber(numtel, 20);
// 输出来电号码到序列埠监控视窗
Serial.print("Number:");
Serial.println(numtel);
// 接听来电
vcs.answerCall();
break;
// 通话中
case TALKING:
Serial.println("TALKING. Enter line to interrupt.");
while(Serial.read()!='\n')
delay(100);
vcs.hangCall();
Serial.println("HANG. Waiting Call.");
break;
}
delay(1000);
}
See also
- getVoiceCallStatus()
- ready()
- voiceCall()
- answerCall()
- hangCall()
- retrieveCallingNumber()
The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.
