Place call Arduino MKR GSM 1400

Hello, Arduino people! I am implementing a GSM project using the Arduino MKR GSM 1400 board. I want to place a call to a specific phone number, wait a certain amount of time (3 seconds for example) and then hang the call. Long story short I want to place an unanswered call. I have written the below code in order to do this:

/* Essential Libraries */
#include <MKRGSM.h>

/* SIM Card PIN Number */
#define PINNUMBER ""

/* Initialize libraries instances */
GSM gsmAccess;
GSM_SMS sms;
GSMVoiceCall vcs;

String received_order;
String number_sent_message;
const String accepted_number = "";
char remote_number[14];
const char number_to_send[14] = "";
const char security_number[14] = "";
char c;
int i = 0;

void setup()
{
   
  Serial.begin(9600);
  while (!Serial) {
    Serial.println("Waiting for Serial Port!");
  }
  Serial.println("Serial Port is now available for communication!");
 
  /* Connection State */
  boolean notConnected = true;
  int telephone_number = 0;

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

  int is_called = vcs.voiceCall(number_to_send);
  Serial.println(is_called);
  if (is_called == 1) {
    delay(10000);
    vcs.hangCall();
  } else {
    Serial.println("Something is wrong");
  }

  sms.flush();
  delay(2000);
  
}

void loop {
      // whatever code
}

Well, the problem is that although the call is placed, the commands inside the if statement won't execute. I am using the synchronous mode and even though the call is placed the variable is_called gets the value 0, which as stated at the documentation is the case when the call is not placed. The other fact is that while calling the program remains at the int is_called = vcs.voiceCall(number_to_send) instruction. After a certain amount of time has passed, the call is hung and at the is_called variable the value 0 is stored and as a result the else statement is executed. Why is that happening and I wonder if there is any workaround for this issue ?

You would get better help if you posted all of the code!

In asynchronous mode, voiceCall() returns 0 if last command is still executing, 1 if successful, and >1 in case of an error. In synchronous mode, it returns 1 if the call is placed, 0 if not.

We don’t know your specifics ...

Don’t post snippets (Snippets R Us!)

@gilshultz I have edited the question with the code. If there are any suggestions, I would be glad to see them.

@J-M-L I have edited the question with more specifics. If there are any suggestions, I would be glad to see them.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.