Mimmofire in questi giorni ho avuto anche io problemi con la funzione callStatus(). Ho quindi modificato la funzione in questo modo:
/**********************************************************
Method checks status of call
return:
CALL_NONE - no call activity
CALL_INCOM_VOICE - incoming voice
CALL_ACTIVE_VOICE - active voice
CALL_NO_RESPONSE - no response to the AT command
CALL_COMM_LINE_BUSY - comm line is not free
**********************************************************/
byte GSM::CallStatus(void)
{
byte ret_val = CALL_NONE;
byte status;
if (CLS_FREE != GetCommLineStatus()) return (CALL_COMM_LINE_BUSY);
SetCommLineStatus(CLS_ATCMD);
Serial.flush();
delay(100);
Serial.println("AT+CPAS");
// 5 sec. for initial comm tmout
// 50 msec. for inter character timeout
if (RX_TMOUT_ERR == WaitResp(5000, 50)) {
// nothing was received (RX_TMOUT_ERR)
// -----------------------------------
ret_val = CALL_NO_RESPONSE;
}
else {
// something was received but what was received?
// ---------------------------------------------
// ready (device allows commands from TA/TE)
// <CR><LF>+CPAS: 0<CR><LF> <CR><LF>OK<CR><LF>
// unavailable (device does not allow commands from TA/TE)
// <CR><LF>+CPAS: 1<CR><LF> <CR><LF>OK<CR><LF>
// unknown (device is not guaranteed to respond to instructions)
// <CR><LF>+CPAS: 2<CR><LF> <CR><LF>OK<CR><LF> - NO CALL
// ringing
// <CR><LF>+CPAS: 3<CR><LF> <CR><LF>OK<CR><LF> - NO CALL
// call in progress
// <CR><LF>+CPAS: 4<CR><LF> <CR><LF>OK<CR><LF> - NO CALL
if(IsStringReceived("+CPAS: 0")) {
// ready - there is no call
// ------------------------
ret_val = CALL_NONE;
}
else if(IsStringReceived("+CPAS: 3")) {
// incoming call
// --------------
ret_val = CALL_INCOM_VOICE;
}
else if(IsStringReceived("+CPAS: 4")) {
// active call
// -----------
ret_val = CALL_ACTIVE_VOICE;
}
else{
// active call
// -----------
ret_val = CALL_NO_RESPONSE;
}
}
SetCommLineStatus(CLS_FREE);
return (ret_val);
}
rispetto a prima viene ricercato anche il +CPAS: oltre il numero ed ora sembra mi funzioni bene mentre prima probabilmente leggeva degli 0 spuri che facevano pensare a nessuna chiamata in arrivo. Non so perchè ma fino a poco tempo fa funzionava anche con la vecchia funzione, forse cambiando qualche cosa nel mio sketch... Ciao