Go Down

Topic: GSM library: What is the voiceCallStatus "CALLING" good for? (Read 4743 times) previous topic - next topic

machinaeX

Sep 05, 2014, 07:54 pm Last Edit: Sep 05, 2014, 08:16 pm by machinaeX Reason: 1
I was working with the getvoiceCallStatus() method of the GSM library and was placing calls through the voiceCall() method.

While doing that I realized that the voiceCall() method gets stuck in a loop until the other side answers the call in some way.
That leads me to the question why the getvoiceCallStatus() method even has the ability to return a status called "CALLING" (see: http://arduino.cc/en/Reference/GSMVCSGetVoiceCallStatus ) for the voiceCall() method seems to be the only way to place a call with the library.

Is that a flaw or a work-in-progress of the library or am i overseeing something? Is there a reason for that function?

an example code that should show the problem that i have:


Code: [Select]
// libraries
#include <GSM.h>

#define PINNUMBER ""

GSM gsmAccess;
GSMVoiceCall vcs;

String remoteNumber = "";  // the number you will call
char charbuffer[20];

void setup()
{
 Serial.begin(9600);
 while (!Serial) {
   ; // wait for serial port to connect. Needed for Leonardo only
 }

 Serial.println("Make Voice Call");
 
 boolean notConnected = true;
 
 while(notConnected)
 {
   if(gsmAccess.begin(PINNUMBER)==GSM_READY)
     notConnected = false;
   else
   {
     Serial.println("Not connected");
     delay(1000);
   }
 }
 
 Serial.println("GSM initialized.");
 Serial.println("Enter phone number to call.");

}

void loop()
{

 while (Serial.available() > 0)
 {
   char inChar = Serial.read();
   // if it's a newline, that means you should make the call:
   if (inChar == '\n')
   {
     // make sure the phone number is not too long:
     if (remoteNumber.length() < 20)
     {
       // let the user know you're calling:
       Serial.print("Calling to : ");
       Serial.println(remoteNumber);
       Serial.println();

       // Call the remote number
       remoteNumber.toCharArray(charbuffer, 20);
       
       vcs.voiceCall(charbuffer))
       remoteNumber="";
       Serial.println(vcs.getvoiceCallStatus());
       
     }
     else
     {
       Serial.println("That's too long for a phone number. I'm forgetting it");
       remoteNumber = "";
     }
   }
   else
   {
     // add the latest character to the message to send:
     if(inChar!='\r')
       remoteNumber += inChar;
   }
 }
}


more to read up on the problem in particular here:
http://forum.arduino.cc/index.php?topic=264959.0

johnwasser

There is a 'synch' flag passed when you create a GSM3VoiceCallService object.  It defaults to 'true' but you can pass 'false' if you want the functions to return immediately.  If the flag is set to 'false' you will get an immediate return from .voiceCall() and can later check to see if the call is CALLING, TALKING or IDLE_CALL (failed?).
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

machinaeX

wow. thank you so much!
you cant believe how happy you just made me. it works wonderfully.

i could not find that in the documentation and im still working on my code reading skills...
thank you!

machinaeX

so. i tested it further and it works perfectly this way. but there is a downsite to setting the synch flag to 'false':

you get immediate and correct report about CALLING or not from .getVoiceCallStatus() after using .voiceCall();

but

you also dont get appropiate response after using the .hang() method

it sorta makes sense, but it doesnt. i mean, one has to be able to change the voiceCallStatus through hangCall() as well as through voiceCall() to build a device that always knows its status, right?

so two ways i could imagine but not quite make out how to approach this:


a) finding a way to set the VoiceCallStatus inside of my GSMVoiceCall object (is there a hidden public method for that?)
b) ignoring the CALLING response and build my own report function for it (appears as if i am building sth that probably is already build into the library)

any ideas? does anyone know if there is a setter function for the VoiceCallStatus and how to apply it correctly?

johnwasser


you also dont get appropiate response after using the .hang() method

it sorta makes sense, but it doesnt. i mean, one has to be able to change the voiceCallStatus through hangCall() as well as through voiceCall() to build a device that always knows its status, right?


You should read:
    libraries/GSM/GSM3VoiceCallService.h
    libraries/GSM/GSM3VoiceCallService.cpp

Those will show you how the library implements synchronous voice calls.  After the call to .hang() it will call .ready() until it returns true or until a timeout occurs.  Perhaps if you do that the .getvoiceCallStatus() will return IDLE_CALL.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

mourad94

hi !
i need som help about the program :
/*
 Make Voice Call

 This sketch, for the Arduino GSM shield, puts a voice call to
 a remote phone number that you enter through the serial monitor.
 To make it work, open the serial monitor, and when you see the
 READY message, type a phone number. Make sure the serial monitor
 is set to send a just newline when you press return.

 Circuit:
 * GSM shield
 * Voice circuit.
 With no voice circuit the call will send nor receive any sound


 created Mar 2012
 by Javier Zorzano

 This example is in the public domain.
 */

// libraries
#include <GSM.h>

// PIN Number
#define PINNUMBER ""

// initialize the library instance
GSM gsmAccess; // include a 'true' parameter for debug enabled
GSMVoiceCall vcs;

String remoteNumber = "";  // the number you will call
char charbuffer[20];

void setup()
{

  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  Serial.println("Make Voice Call");

  // connection state
  boolean notConnected = true;

  // Start GSM shield
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  while (notConnected)
  {
    if (gsmAccess.begin(PINNUMBER) == GSM_READY)
      notConnected = false;
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }

  Serial.println("GSM initialized.");
  Serial.println("Enter phone number to call.");

}

void loop()
{

  // add any incoming characters to the String:
  while (Serial.available() > 0)
  {
    char inChar = Serial.read();
    // if it's a newline, that means you should make the call:
    if (inChar == '\n')
    {
      // make sure the phone number is not too long:
      if (remoteNumber.length() < 20)
      {
        // let the user know you're calling:
        Serial.print("Calling to : ");
        Serial.println(remoteNumber);
        Serial.println();

        // Call the remote number
        remoteNumber.toCharArray(charbuffer, 20);


        // Check if the receiving end has picked up the call
        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 = "";
        Serial.println("Enter phone number to call.");
      }
      else
      {
        Serial.println("That's too long for a phone number. I'm forgetting it");
        remoteNumber = "";
      }
    }
    else
    {
      // add the latest character to the message to send:
      if (inChar != '\r')
        remoteNumber += inChar;
    }
  }
}

i want to call tow number in the same time with a table but i can't ,can some one help me !!

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy