incoming SMS messages delayed 15-30 minutes

Adafruit cellular platform - SMS and IoT over celluar

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
rskup
 
Posts: 230
Joined: Sat Aug 01, 2020 9:04 pm

Re: incoming SMS messages delayed 15-30 minutes

Post by rskup »

Hey Jim, congrats on getting that ESP32 demo sketch running with the Waveshare and 5483 board! That looks like it would be a very slick combo to have. Glad I could help, I think your boat application is pretty cool!

I've only done a little more coding/testing to try to get the power on/off working, not successful yet, but I think I now know what I've been doing wrong. So will update if/when I get that working right.

Ok, hope things continue to go well!

User avatar
jimk123
 
Posts: 708
Joined: Sun Dec 26, 2010 7:04 pm

Re: incoming SMS messages delayed 15-30 minutes

Post by jimk123 »

morning Rob
making more progress using the TFT color display on the ESP32-S3, set up a font to display 5 rows, and now have it displaying the startup info, RSSI signal strength and once a minute have a timer that gets the time ,modem.getTime(timeBuffer, 23); and number of SMS msgs, int8_t smsnum = modem.getNumSMS(); and updating the display.

I also changed the jumper on the PWR pin to use D6 and confirmed the code powers up the hat on startup.

next on the list is to parse incoming messages and display that on the TFT display and return a 'msg recvd' and then add in the code to check the hour of the day and on certain hours like 8am, 4pm and midnight send out a status message and clear counters at midnight.

Still need to do more hourly testing throughout the day to make sure I do not see any incoming delays. If you end up buying one of those esp32-s3-tft boards let me know and I will be happy to share what I have coded so far, I am only using this for sms msgs so it is pretty simple, I hope :)

User avatar
jimk123
 
Posts: 708
Joined: Sun Dec 26, 2010 7:04 pm

Re: incoming SMS messages delayed 15-30 minutes

Post by jimk123 »

Hi Rob
I have been slowly adding more function to the code but stumped on how to get replies from certain AT commands. I think you said you wrote your own ? As an example I am trying to run commands like:

//on wave share AT+CPSI? returns +CPSI: LTE,Online,310-260,0x50F8,13549826,23,EUTRAN-BAND4,2250,5,5,-109,-1033,-729,12

and get a char array back that I could parse, I was reading the .cpp file and some of their functions appear to use sendParseReply and readLine to return data but way above my coding skills :( I assume AT+ cmds are somewhat asyncrinous so the readline has a timeout value in case it does not return in time ?

thanks

User avatar
rskup
 
Posts: 230
Joined: Sat Aug 01, 2020 9:04 pm

Re: incoming SMS messages delayed 15-30 minutes

Post by rskup »

Hi Jim, yes, I wrote code for my boards, but I would describe it all as very basic without the error checking and etc... that I'm sure the FONAtest sketch incorporates (and also guessing it looks at "timeouts").

If I'm understanding right, you're looking for an example of sending a command and parsing a reply? Here's my "is this thing on" function that sends a simple "AT" to the board and looks for the "OK" back:

Code: Select all

bool isSimOn(void){                     // Check if Sim chip is on
  Serial.println(F(""));
  for (int i = 0; i <= 4; i++) {        // try 5 times to get OK from SIMCOM
    Serial.print(F("is On? - loop "));
    Serial.println(i);
    delay(900);                         
    Serial1.println(F("ATE0"));         // turn off echo
    digitalWrite(13, HIGH);
    delay(100);                        
    digitalWrite(13, LOW);
    Serial1.println("AT");		// send AT command            
    //delay(100);                          
    while (Serial1.available()){           
      FONAstring = Serial1.readString(); // read reply
      Serial.println(FONAstring);
      FONAstring.replace("\r","");
      FONAstring.replace("\n","");
      if (FONAstring.endsWith("OK")) {
        simcom = 1;
        return true;
      }
      return false;
    }
  }
}
As far as parsing something like your CPSI reply, you could use "indexOf", like the example below:

Code: Select all

    index1 = stringToParse.indexOf(',');  // index of first comma
    string1 = stringToParse.substring(0, index1); // would extract "+CPSI: LTE" 

    index2 = stringToParse.indexOf(',', index1+1);  // index of second comma
    string2 = stringToParse.substring(index1+1, index2);  // would extract "Online"

    ...and so on
Are either of these what you were looking for?

User avatar
jimk123
 
Posts: 708
Joined: Sun Dec 26, 2010 7:04 pm

Re: incoming SMS messages delayed 15-30 minutes

Post by jimk123 »

thanks Rob
Looks something like I was doing but as you said I think I am missing some error handling getting back the "OK". It seems like some of their functions call readLine with a 1-3 second time out looking for the "OK" to come back.

here is the code I was trying but it is not always accurate, possibly on longer running commands

Code: Select all

Serial.println(F("try AT+COPS?"));
  flushSerial();
  modemSS.println("AT+COPS?");
  delay(100);
  
  response[0] = (char)0;  // clear buffer
  availableBytes = modemSS.available();
  Serial.print(F("modemSS.available() = "));Serial.println(availableBytes);
  i=0;
  for( i=0; i<availableBytes; i++)
  {
    response[i] = modemSS.read();
  }
  response[i+1] = '\0'; // Add a NULL at end of string

    char *findAT ="+COPS";
  char*found = strstr(response, findAT);
  if (found)
  {
    
    Serial.print(F("response buffer length: "));Serial.println(strlen(response));
    Serial.print("AT+COPS? results = ");Serial.println(response);Serial.println(F("end of cmd"));
  }
  else
  {
    Serial.println("ERROR CMD RESULTS NOT FOUND");
  }

User avatar
jimk123
 
Posts: 708
Joined: Sun Dec 26, 2010 7:04 pm

Re: incoming SMS messages delayed 15-30 minutes

Post by jimk123 »

off topic but wanted to mention I got the GPS to work, I had to use the GPS antenna that came with the waveshare, the PCB antenna version from botelitics did not work, anyway in the code I call:

if (modem.getGPS(&latitude, &longitude, &speed_kph, &heading, &altitude))

and then format at as this:

Code: Select all

sendSMSdataBuffer[0] = (char)0;  // clear buffer
      
      // http://maps.google.com/?q=lat,lon
      // q is the search query followed by lat and lon comma separated 
      // 52.03841,-116.01679
      
      strcat(sendSMSdataBuffer,"http://maps.google.com/?q=");
      strcat(sendSMSdataBuffer,latBuffer);
      strcat(sendSMSdataBuffer,",");
      strcat(sendSMSdataBuffer,lonBuffer);
      #ifdef DEBUG
        Serial.println(sendSMSdataBuffer);
      #endif
      sendSMS();
when I receive the txt msg on my phone it appears as a icon for google maps and when I click on it it pulls up a map and shows me exactly where the waveshare 7600 is !

User avatar
rskup
 
Posts: 230
Joined: Sat Aug 01, 2020 9:04 pm

Re: incoming SMS messages delayed 15-30 minutes

Post by rskup »

Did a little searching for "timeout" in the cpp file, looks like there's an "expectReply" function that uses it. I've never tried modifying a cpp file though, could be interesting.

Thanks for posting the gps code, that sounds pretty cool! Every so often I've tried to set up my small SIM7000 board as a gps tracker, but never successfully made the jump from the coordinate reply to a google map on a phone. Your code is much simpler than the stuff I was trying!

Locked
Please be positive and constructive with your questions and comments.

Return to “FONA”