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.