0

Auto answer call FONA 3G
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Auto answer call FONA 3G

by adafruit_support_rick on Wed Apr 19, 2017 10:19 am

Ohhhhhh! You're got an XBee! That's a problem.

But first, if fona begin fails, then you'll go into an infinite loop and nothing else will happen. So that's why you're not seeing it pick up.
Code: Select all | TOGGLE FULL SIZE
  if (! fona.begin(*fonaSerial)) {
    Serial.println(F("Couldn't find FONA"));
    while (1);      //infinite loop.  Everything stops here
  }


Now, the problem with the XBee: The way Software Serial works, you can only receive from one device at a time. You have to explicitly tell it which device to listen to.
https://www.arduino.cc/en/Reference/Sof ... rialListen
What seems to be happening is that Software Serial is listening to the XBee and not to the Fona. So nothing is received from the Fona, and the Fona initialization fails.

Try this:
Code: Select all | TOGGLE FULL SIZE
{
 Serial.begin(115200);
 XBee.begin(9600);
 Serial.println("Start listening");

   fonaSerial->begin(4800);  //added for FONA
  fonaSerial->listen();   //ADD THIS LINE
  if (! fona.begin(*fonaSerial)) {
    Serial.println(F("Couldn't find FONA"));
    while (1);
  }

  attachInterrupt(RING_PIN, RingInterrupt, FALLING);
}


If I'm right, then the fona initialization will succeed. But you won't be receiving anything from the xbee. I don't know what the xbee is supposed to be doing. Maybe you can get away with listening to the xbee all the time, except when you get a ring interrupt. If you're only transmitting from the xbee, then you don't have a problem. Just do the fonaSerial->listen(), and you're done. Otherwise, you'll have to put in calls to listen to switch between the XBee and the Fona.

Let me know what you're doing with the XBee, and if you need to be listening to it all the time.

adafruit_support_rick
 
Posts: 33058
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Auto answer call FONA 3G

by craver2000 on Wed Apr 19, 2017 1:12 pm

Thanks for your reply. Yes, from what you told me, I think the Xbee softserial seemed to be interfering. Now my serial monitor shows a more encouraging response during initialisation:
Code: Select all | TOGGLE FULL SIZE
Start listening
Attempting to open comm with ATs
   ---> AT
   <---
   ---> AT
   <---
   ---> AT
   <---
   ---> AT
   <---
   ---> AT
   <---
   ---> AT
   <---
   ---> AT
   <--- AT
   ---> AT
   <--- AT
   ---> ATE0
   <--- +CPIN: READY
   ---> ATE0
   <--- OK
   ---> AT+CVHU=0
   <--- OK
   ---> ATI
   <--- Manufacturer: SIMCOM INCORPORATED
Model: SIMCOM_SIM5320A
Revision: SIM5320A_V1.5
XXX: XXXXXXXXXXXX //exact numbers not stated here
+GCAP: +CGSM,+FCLASS,+DS

OK

PNN DONE

SMS DONE


I then tried to call FONA 3G module and it rings but there is no auto answer.

The current pin defintions are:
Code: Select all | TOGGLE FULL SIZE
#define RING_PIN 2
#define FONA_TX 4
#define FONA_RX 3
#define FONA_RST 5

DTMF dtmf(12, 11, 10, 9, 8, 15, 16);

SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
SoftwareSerial *fonaSerial = &fonaSS;
Adafruit_FONA_3G fona = Adafruit_FONA_3G(FONA_RST);

SoftwareSerial XBee(18, 19);

and I have included the line that you recommended for addition as well. Changing ring pin from 2 to 1 does not work as well.

craver2000
 
Posts: 11
Joined: Wed Jan 11, 2017 5:57 am

Re: Auto answer call FONA 3G

by adafruit_support_rick on Wed Apr 19, 2017 2:19 pm

You need to configure the RING_PIN as an input. Also, you should use the digitalPinToInterrupt function:
Code: Select all | TOGGLE FULL SIZE
  pinMode(RING_PIN, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt (RING_PIN), RingInterrupt, FALLING);

adafruit_support_rick
 
Posts: 33058
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Auto answer call FONA 3G

by craver2000 on Thu Apr 20, 2017 12:05 am

I've added those lines as well but there is still no auto answer when ringing. My updated code is shown below.

Code: Select all | TOGGLE FULL SIZE
#include "SoftwareSerial.h"
#include "dtmf.h"
#include "Adafruit_FONA.h"

#define RING_PIN 2
#define FONA_TX 4
#define FONA_RX 3
#define FONA_RST 5

DTMF dtmf(12, 11, 10, 9, 8, 15, 16);

SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
SoftwareSerial *fonaSerial = &fonaSS;
Adafruit_FONA_3G fona = Adafruit_FONA_3G(FONA_RST);

SoftwareSerial XBee(18, 19);
 
volatile bool ringing = false;

void RingInterrupt()
{
  ringing = true;
}

void setup()
{
  Serial.begin(115200);
  XBee.begin(9600);
  Serial.println("Start listening");

   fonaSerial->begin(4800);  //added for FONA
   fonaSerial->listen();   //ADD THIS LINE
  if (! fona.begin(*fonaSerial)) {
    Serial.println(F("Couldn't find FONA"));
    while (1);
  }
  pinMode(RING_PIN, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt (RING_PIN), RingInterrupt, FALLING);
}

void loop()
{
  if (ringing)    //added for FONA
  {
    delay(1000);  //let it ring for a second
    // pick up!
    if (! fona.pickUp()) {
      Serial.println(F("Failed"));
    } else {
      Serial.println(F("OK!"));
    }
    ringing = false;
  }
 
  // Read DTMF codes one by one and print it on Serial
  int myDtmf;
  myDtmf = dtmf.getDTMF();

  if(myDtmf != -1) Serial.println(myDtmf);

    if (myDtmf == 9)
   {
    delay(80); // to avoid getting repeated output.
    XBee.write('G');
    Serial.println("activated");

}
}

craver2000
 
Posts: 11
Joined: Wed Jan 11, 2017 5:57 am

Re: Auto answer call FONA 3G

by adafruit_support_rick on Thu Apr 20, 2017 9:03 am

Ohhh! You need to call fona.setSMSInterrupt(1); to enable the ring interrupt. Call it in setup when you attach the interrupt.

adafruit_support_rick
 
Posts: 33058
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Auto answer call FONA 3G

by craver2000 on Thu Apr 20, 2017 11:58 am

Added that line but still not auto answering. My updated code is:

Code: Select all | TOGGLE FULL SIZE
    #include "SoftwareSerial.h"
    #include "dtmf.h"
    #include "Adafruit_FONA.h"

    #define RING_PIN 2
    #define FONA_TX 4
    #define FONA_RX 3
    #define FONA_RST 5

    DTMF dtmf(12, 11, 10, 9, 8, 15, 16);

    SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
    SoftwareSerial *fonaSerial = &fonaSS;
    Adafruit_FONA_3G fona = Adafruit_FONA_3G(FONA_RST);

    SoftwareSerial XBee(18, 19);
     
    volatile bool ringing = false;

    void RingInterrupt()
    {
      ringing = true;
    }

    void setup()
    {
      Serial.begin(115200);
      XBee.begin(9600);
      Serial.println("Start listening");

       fonaSerial->begin(4800);  //added for FONA
       fonaSerial->listen();   //ADD THIS LINE
      if (! fona.begin(*fonaSerial)) {
        Serial.println(F("Couldn't find FONA"));
        while (1);
      }
      pinMode(RING_PIN, INPUT_PULLUP);
      attachInterrupt(digitalPinToInterrupt (RING_PIN), RingInterrupt, FALLING);
     fona.setSMSInterrupt(1); //Just added this
    }

    void loop()
    {
      if (ringing)    //added for FONA
      {
        delay(1000);  //let it ring for a second
        // pick up!
        if (! fona.pickUp()) {
          Serial.println(F("Failed"));
        } else {
          Serial.println(F("OK!"));
        }
        ringing = false;
      }
     
      // Read DTMF codes one by one and print it on Serial
      int myDtmf;
      myDtmf = dtmf.getDTMF();

      if(myDtmf != -1) Serial.println(myDtmf);

        if (myDtmf == 9)
       {
        delay(80); // to avoid getting repeated output.
        XBee.write('G');
        Serial.println("activated");

    }
    }


Also when I use the serilal monitor, it shows:
Code: Select all | TOGGLE FULL SIZE
Start listening
Attempting to open comm with ATs
   ---> AT
   <---
   ---> AT
   <---
   ---> AT
   <---
   ---> AT
   <---
   ---> AT
   <---
   ---> AT
   <---
   ---> AT
   <--- START
   ---> AT
   <--- AT
   ---> ATE0
   <--- ATE0
   ---> ATE0
   <--- OK
   ---> AT+CVHU=0
   <--- HÒ(RJ’e5
   ---> ATI
   <--- Manufacturer: SIMCOM INCORPORATED
Model: SIMCOM_SIM5320A
Revision: SIM5320A_V1.5
IMEX:XXXXXXXXX
+GCAP: +CGSM,+FCLASS,+DS

OK

OPL DONE

PNN DONE

   ---> AT+CFGRI=1
   <--- OK
   ---> ATA
   <--- NO CARRIER
Failed

Does the last part mean something? Nevertheless, there is still ringing, so I assume there is actually cellular reception.

craver2000
 
Posts: 11
Joined: Wed Jan 11, 2017 5:57 am

Re: Auto answer call FONA 3G

by adafruit_support_rick on Thu Apr 20, 2017 1:02 pm

OK, that's interesting. The interrupt is working. You're actually calling fona.pickup(), but that's failing with NO CARRIER. I don't understand why it would ring if it has no connection to the network.

In FonaTest, what do you get from the 'n' command? (get network status)

Also in FonaTest, what happens if you use the 'p' command to pick up the phone when it's ringing?

adafruit_support_rick
 
Posts: 33058
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Please be positive and constructive with your questions and comments.