Hi.
I am working with the Arduino GSM Shield and hit an dead end:
it seems the voiceCall() function of the GSM library opens a loop that is just interrupted by someone taking the call on the other line.
Is there any way I can hang up while calling another device that does not answer?
the .hangCall() function cant be called before someone took the call. Or can it?
Have you tried it?
I'm assuming (always dangerous) that the voiceCall() function uses one of the ATD variants to initiate the call. The M10 command set says:
Note: This command may be aborted generally by receiving an ATH
command or character during execution. The aborting is not possible
during some states of connection establishment such as handshaking.
i tried it with the example sketch from the library.
this is the critical part:
//(...)
if(vcs.voiceCall(charbuffer))
{
Serial.println("Call Established. Enter line to end");
// Wait for some input from the line
while(Serial.read()!='\n' && (vcs.getvoiceCallStatus()==TALKING));
// And hang up
vcs.hangCall();
}
Serial.println("Call Finished");
remoteNumber="";
//(...)
because the code just proceeds to the while loop AFTER somebody on the other side actually answers the call or hangs up.
at least thats what it looks like in my serial monitor.
does that make any sense with the AT commands? i dont really understand what that could tell me...
To be honest I don't really know why people want to use libraries for relatively trivial tasks. A simple piece of code to test the theory. Use ATD to initiate the call and ATH to disconnect.
#include <SoftwareSerial.h>
SoftwareSerial GPRS(2, 3); // RX, TX
void setup()
{
Serial.begin(19200);
GPRS.begin(19200);
Serial.println("Connecting to network");
delay(20000);
Serial.println("Should be connected to network by now");
GPRS.print("ATD+447751123456;\r");
Serial.println("Dialied");
delay(12000); //Give it time to connect
GPRS.print("ATH\r"); // And disconnect
Serial.println("Disconnect");
}
void loop()
{
}
thanks for the code. of course you are right: it works with the ATH command.
sigh
the thing is just, that for the project i was hoping to be able to rely on the library for i am sending and recieving texts as well as placing calls and being called. to do all that through AT commands i would have to build my own library in the end... and my skill set is not really up to that task, yet.
:-/
i am gonna check out the GSM library (if i find it - where are those build in library files?) to understand what the problem of the .hangCall() method is. Something must prevent it from doing the ATH... maybe it is in the while loop of the GSM VoiceCall Example, but just leaving it out did not do the trick.
or maybe there is a way to send AT commands through the library while still using it? i cant find a method for that in the documentation though...
thanks again for the help. i took a look at the at command pdf and was just overwhelmed by the number of pages. helps a lot, if sb shows you that its quite a straight forward process.
im kinda dissapointed that the GSM lib does not have a propper method for that. i mean: the .getVoiceCallStatus() method can even return "CALLING". what is that good for if the method that does the call waits in a loop until it established the call. this way the calling feedback of .getVoiceCallStatus() is rendered useless. that made me think it should be possible to do that.
but i probably just dont see the solution...
edit: the wonderful johnwasser solved my problem by pointing out that the library can do it: GSM library: What is the voiceCallStatus "CALLING" good for? - #3 by machinaeX - Arduino GSM Shield - Arduino Forum