0

FONA 808 Not Receiveing
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

FONA 808 Not Receiveing

by silverstar on Tue Jul 09, 2019 12:45 pm

I have been having a boatload of trouble with my FONA. Suspecting that it was my code, i modified FONA_SMS_RESPONSE to use the RX and TX pins my FONA uses and to set hardware serial rather than software serial. I am using a mega 2560.
Code: Select all | TOGGLE FULL SIZE
/***************************************************
  This is an example for our Adafruit FONA Cellular Module

  Designed specifically to work with the Adafruit FONA
  ----> http://www.adafruit.com/products/1946
  ----> http://www.adafruit.com/products/1963
  ----> http://www.adafruit.com/products/2468
  ----> http://www.adafruit.com/products/2542

  These cellular modules use TTL Serial to communicate, 2 pins are
  required to interface
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ****************************************************/

/*
THIS CODE IS STILL IN PROGRESS!

Open up the serial console on the Arduino at 115200 baud to interact with FONA


This code will receive an SMS, identify the sender's phone number, and automatically send a response

For use with FONA 800 & 808, not 3G
*/

#include "Adafruit_FONA.h"

#define FONA_RX 18
#define FONA_TX 19
#define FONA_RST 4

// this is a large buffer for replies
char replybuffer[255];

// We default to using software serial. If you want to use hardware serial
// (because softserial isnt supported) comment out the following three lines
// and uncomment the HardwareSerial line
//#include <SoftwareSerial.h>
//SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
//SoftwareSerial *fonaSerial = &fonaSS;

// Hardware serial is also possible!
  HardwareSerial *fonaSerial = &Serial1;

// Use this for FONA 800 and 808s
Adafruit_FONA fona = Adafruit_FONA(FONA_RST);
// Use this one for FONA 3G
//Adafruit_FONA_3G fona = Adafruit_FONA_3G(FONA_RST);

uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0);

void setup() {
  while (!Serial);

  Serial.begin(115200);
  Serial.println(F("FONA SMS caller ID test"));
  Serial.println(F("Initializing....(May take 3 seconds)"));

  // make it slow so its easy to read!
  fonaSerial->begin(4800);
  if (! fona.begin(*fonaSerial)) {
    Serial.println(F("Couldn't find FONA"));
    while(1);
  }
  Serial.println(F("FONA is OK"));

  // Print SIM card ???? number.
  char ????[16] = {0}; // MUST use a 16 character buffer for ????!
  uint8_t imeiLen = fona.get????(????);
  if (????Len > 0) {
    Serial.print("SIM card ????: "); Serial.println(????);
  }

  fonaSerial->print("AT+CNMI=2,1\r\n");  //set up the FONA to send a +CMTI notification when an SMS is received

  Serial.println("FONA Ready");
}

 
char fonaNotificationBuffer[64];          //for notifications from the FONA
char smsBuffer[250];

void loop() {
 
  char* bufPtr = fonaNotificationBuffer;    //handy buffer pointer
 
  if (fona.available())      //any data available from the FONA?
  {
    int slot = 0;            //this will be the slot number of the SMS
    int charCount = 0;
    //Read the notification into fonaInBuffer
    do  {
      *bufPtr = fona.read();
      Serial.write(*bufPtr);
      delay(1);
    } while ((*bufPtr++ != '\n') && (fona.available()) && (++charCount < (sizeof(fonaNotificationBuffer)-1)));
   
    //Add a terminal NULL to the notification string
    *bufPtr = 0;

    //Scan the notification string for an SMS received notification.
    //  If it's an SMS message, we'll get the slot number in 'slot'
    if (1 == sscanf(fonaNotificationBuffer, "+CMTI: " FONA_PREF_SMS_STORAGE ",%d", &slot)) {
      Serial.print("slot: "); Serial.println(slot);
     
      char callerIDbuffer[32];  //we'll store the SMS sender number in here
     
      // Retrieve SMS sender address/phone number.
      if (! fona.getSMSSender(slot, callerIDbuffer, 31)) {
        Serial.println("Didn't find SMS message in slot!");
      }
      Serial.print(F("FROM: ")); Serial.println(callerIDbuffer);

        // Retrieve SMS value.
        uint16_t smslen;
        if (fona.readSMS(slot, smsBuffer, 250, &smslen)) { // pass in buffer and max len!
          Serial.println(smsBuffer);
        }

      //Send back an automatic response
      Serial.println("Sending reponse...");
      if (!fona.sendSMS(callerIDbuffer, "Hey, I got your text!")) {
        Serial.println(F("Failed"));
      } else {
        Serial.println(F("Sent!"));
      }
     
      // delete the original msg after it is processed
      //   otherwise, we will fill up all the slots
      //   and then we won't be able to receive SMS anymore
      if (fona.deleteSMS(slot)) {
        Serial.println(F("OK!"));
      } else {
        Serial.print(F("Couldn't delete SMS in slot ")); Serial.println(slot);
        fona.print(F("AT+CMGD=?\r\n"));
      }
    }
  }
}


When I run the program, the setup appears to work as intended but when I attempt to send in a text, my screen displays

CMTI: "SM , # (the number # advances by one with each attempted send NOTE: the "????" covers the characters I was told were not allowed

Is my FONA broken?????

silverstar
 
Posts: 247
Joined: Tue Feb 04, 2014 10:46 pm

Re: FONA 808 Not Receiveing

by adafruit_support_mike on Tue Jul 09, 2019 9:33 pm

No, those are 'unsolicited' messages saying the FONA received the message. 'Unsolicited' means the FONA emits the message without you sending it a command asking for status.

That means the FONA is working as it should.

adafruit_support_mike
 
Posts: 59172
Joined: Thu Feb 11, 2010 2:51 pm

Re: FONA 808 Not Receiveing

by silverstar on Wed Jul 10, 2019 4:55 pm

That program is supposed to read an incoming text, print out the callers number and message and then send a response. Its not doing any of that. It seems to me that the FONA is not properly responding to an incoming message. (The system that I have that uses the FONA also seems to to ignore incoming texts, so I am wondering if my FONA is okay or not).

silverstar
 
Posts: 247
Joined: Tue Feb 04, 2014 10:46 pm

Re: FONA 808 Not Receiveing

by adafruit_support_mike on Thu Jul 11, 2019 12:17 pm

If you drop back to the ‘fonatest’ example sketch that came with the FONA library, does it display the messages you sent the FONA when you enter a slot number?

adafruit_support_mike
 
Posts: 59172
Joined: Thu Feb 11, 2010 2:51 pm

Re: FONA 808 Not Receiveing

by silverstar on Thu Jul 11, 2019 7:27 pm

I have used this sketch in the past as an example of how to code the FONA. I just tried it and it said that I had 7 texts (which sounded correct). I then told it to read all of them and it did and they were all the messages that I could not get before. It seems as though its working. I am including the first few lines of my code. I always get 1 message of zero length which (as you can see) I discard.
Code: Select all | TOGGLE FULL SIZE
 int8_t smsnum = fona.getNumSMS();
  uint16_t smslen;
  int8_t smsn;
  int i;
  String m;
  Serial.print ("##########################  type: ");Serial.print(type);Serial.print (" smsnum: ");Serial.print(smsnum); Serial.print (" smslen: ");Serial.print(smslen);

  if (smsnum == 0)return;                                      // get out if there are no messages
  if (smsnum == 1 && smslen == 0) return;                      // get out if a single zero length message appears


Thank you for your help. I will take another long hard look at my code (which worked up until a day or so ago).

silverstar
 
Posts: 247
Joined: Tue Feb 04, 2014 10:46 pm

Re: FONA 808 Not Receiveing

by adafruit_support_mike on Fri Jul 12, 2019 5:23 pm

Okay, that confirms the hardware is working.

Take a look at the code in the ‘fonatest’ sketch, and in the FONA library which generates the actual AT-commands.

adafruit_support_mike
 
Posts: 59172
Joined: Thu Feb 11, 2010 2:51 pm

Re: FONA 808 Not Receiveing

by silverstar on Fri Jul 12, 2019 11:13 pm

I have never looked at code in a library before. Can you suggest something I might read to get me started?

I have been thinking about taking the code that reads ('R') all messages in the example and using that as a basis for my cell interface, My application will receive very few text messages (1 or 2 per day would be a good average).

Thanks again for your help - its much appreciated.

silverstar
 
Posts: 247
Joined: Tue Feb 04, 2014 10:46 pm

Re: FONA 808 Not Receiveing

by adafruit_support_mike on Sun Jul 14, 2019 3:22 pm

Reading libraries is the same as reading any other code: you look through the source and try to figure out what the functions are doing.

The FONA library isn’t too complicated. Most of the functions are short, and do little more that print AT-commands to the FONA’s Serial interface.

adafruit_support_mike
 
Posts: 59172
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.