Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Any way to block incoming sms?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Any way to block incoming sms?

by mromero on Sun Sep 27, 2020 8:26 am

I have a freezer alarm system and its only coded to send SMS if an alarm condition is met. It consists of a Fona 800H shield on arduino uno with 0V or 4V signal going into digital pin 9 to trigger the alarm SMS when it goes high =4V. I use Ting network.

My issue is i am receiving robo-sms's as many as 10 in a day from various numbers. Since Ting changes by usage levels it seems as my usage is very high when it should not be, unless there is an alarm most months nothing should go out. Sometimes they come in 2 sec appart 6 in a row from the same unkown numbers. When i call the numbers with my cell they are not in service or verizon. I did not put the receive.SMS code in the program so dont know why its receiving them. Is there a way to block the FONA from receiving SMS without affecting the sending part? I have attached my code the numbers have been XXXXXXXXXX out.

Any help welcomed. I used the same code in the past and never received any SMS that I did not innitiate so dont know what is going on?


Code: Select all | TOGGLE FULL SIZE
//-----------------(Import Libraries used)------------------------------------------
#include "Adafruit_FONA.h"
#include <SoftwareSerial.h>

#define FONA_RX 2
#define FONA_TX 3
#define FONA_RST 4
//-----------------(Declare Constants & Pin #'s and initialize variables)--------------
const int threshold = 1;// alarm state to send txt
int loopcounter=0;// how many times through the Void loop
int ShawnAlarmPin = 9;// Ao4-2#1
int CharlieAlarmPin = 10;//AO4-2#2 (master CR1000)
int ShawnAlarmState=0;
int CharlieAlarmState=0;
//--------------------(Declare Variables)-----------------------------------------------------------
// count[] is an array of 2 elements for 2 ultralows that starts with index 0
int count[2] = {0, 0}; //used to only send 1 txt when the alarm pin goes to 4V)removed extra comma at end of last array 0
int i; // reply counter 0 to 1

char replybufferShawn[] = "Shawn Lab Ultralow overheating";
char replybufferCharlie[] = "Chembug Lab Ultralow overheating";

//9/8/2020 commenting phone number out so it cant send text while testing if ok comment me out and
// change call out to Shawn and Charlie

char phone_numberMaritza[] = "+##########"; // put scientist phone number here
char phone_numberShawn[] = "+##########"; // put scientist phone number here
char phone_numberCharlie[] = "+##########"; // put scientist phone number here

//--------------------(Declare Objects)-------------------------------------------------------------
// We default to using software serial.
SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
SoftwareSerial *fonaSerial = &fonaSS;

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

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

void setup() {
  while (!Serial);

  Serial.begin(115200); // for FONA may not need separete serial.begin for alarm
  Serial.println(F("FONA basic test"));
  Serial.println(F("Initializing....(May take 3 seconds)"));

  fonaSerial->begin(4800);
  if (! fona.begin(*fonaSerial)) { //open if 1
    Serial.println(F("Couldn't find FONA"));
    while (1);
  } //close if 1
 
  Serial.println(F("FONA is OK"));

  //make AlarmPins and input
  pinMode(ShawnAlarmPin, INPUT);
  pinMode(CharlieAlarmPin, INPUT);
 
  delay(3000);// 3 seconds delay is in milisec there are 1000 ms=1sec

}//close void setup loop

void loop() {
  //read the "Person" AlarmPin and save into variable state print to Serial
  int ShawnAlarmState = digitalRead(ShawnAlarmPin);
  int CharlieAlarmState = digitalRead(CharlieAlarmPin);
 
  Serial.print(F("ShawnAlarmState=")); Serial.println(ShawnAlarmState);
  Serial.print(F("count[0]=")); Serial.println(count[0]);
  delay (500);
  Serial.print(F("CharlieAlarmState=")); Serial.println(CharlieAlarmState);
  Serial.print(F("count[1]=")); Serial.println(count[1]);
  delay (500);// half second dely
  Serial.print(F("                   "));
  delay (500);
 
  //--------------------------------------- send an SMS! based on alarm condition--------
 
  if (ShawnAlarmState == threshold && count[0] == 0) { // test for when it is equal to 1
  //  flushSerial();
    Serial.print(F("                   "));
    Serial.print(F("threshold="));  Serial.println(threshold);
    Serial.print(F("count[0]="));  Serial.println(count[0]);
    Serial.println(F("sending sms to:"));
    Serial.println(phone_numberShawn);//replace with phone_numberShawn if it works
    Serial.println(replybufferShawn);
    Serial.print(F("                   "));
    delay(500);
    count[0]=1;
    loopcounter=0;
//---------------- this is actual SMS code part===============   

    if (!fona.sendSMS(phone_numberShawn, replybufferShawn)) {// put phone_numberShawn
      Serial.println(F("Failed"));
      } else {
      Serial.println(F("Sent!"));
      }     // close else

    }   // end if ShawnAlarmStat==...statement
//======================================================================
   
  if (CharlieAlarmState == threshold && count[1] == 0) {
   // flushSerial();
    Serial.print(F("                   "));
    Serial.print(F("threshold="));  Serial.println(threshold);
    Serial.print(F("count[1]="));  Serial.println(count[1]);
    Serial.println(F("sending sms to:"));
    Serial.println(phone_numberCharlie);
    Serial.println(replybufferCharlie);
    Serial.print(F("                   "));
     delay(500);
    count[1]=1;
    loopcounter=0;
//
//commented our actual call to test from here to ===========================

    if (!fona.sendSMS(phone_numberCharlie, replybufferCharlie)) { //replace to phone_numberCharlie after testing
      Serial.println(F("Failed"));
    } else {
      Serial.println(F("Sent!"));
    }

  }//close if(CharlieAlarmState=threshold...

  ////--------------------------------------------------------------------------------------------------------

  loopcounter++;
  Serial.print(F("loopcounter")); Serial.println(loopcounter);


  if (loopcounter == 72000) {// originally used 500 about every 5 min resets system to send another txt now 6000 for every 1hr
      loopcounter = 0;//reset loop counter 3000 close to 30min
      for (i = 0; i < 2; i = i + 1) { // open for
          count[i]=0;// reset count[i] so another  txt can be sent
          Serial.print(F("count[i]= ")); Serial.println(count[i]);
      }//closed the loopcounter for
  }//close if loopcounter
 
}// closes void loop

mromero
 
Posts: 44
Joined: Fri Mar 18, 2016 12:10 pm

Re: Any way to block incoming sms?

by rskup on Thu Oct 01, 2020 6:24 pm

Just a little confused...are you saying incoming texts actually interfere with the execution of your program above?

rskup
 
Posts: 33
Joined: Sat Aug 01, 2020 9:04 pm

Re: Any way to block incoming sms?

by mromero on Fri Oct 02, 2020 8:08 am

No it doesn not interfere but i am paying for texts from phones that are supposedly not in service and its aggravating

mromero
 
Posts: 44
Joined: Fri Mar 18, 2016 12:10 pm

Re: Any way to block incoming sms?

by rskup on Fri Oct 02, 2020 11:26 am

Oh ya, agree, unwanted texts are a pain, but not seeing how the FONA (or FONAtest) would be responsible for that unwanted text cost.

You asked elsewhere, "can SMS receive be turned off"? The FONA is not on its own periodically checking for texts. It requires an AT command to do that (and anything else). Here's a link to the AT commands for the SIM800:

https://simcom.ee/documents/SIM800H/SIM ... _V1.10.pdf

It sits there blinking until told what to do. For example, if you follow your "fona.sendSMS" function through to FONA.CPP, you'll see it's sending the AT command "AT+CMGS" to the SIM800 which is for sending a text (page 119 of the above manual).

I think you mentioned in another post you have Ting, it sounds like their cellphone app allows you to disable sending and/OR receiving texts:

https://help.ting.com/hc/en-us/articles ... -Messaging

Since we're talking about FONAs and not cellphones, maybe it's also possible to disable incoming texts through your online Ting account?

Otherwise you may want to change to a plan that allows unlimited texts, I use SpeedTalk Mobile for my FONA 3G, checking over their plans looks like the least costly unlimited text plan starts at $7.50/month.

rskup
 
Posts: 33
Joined: Sat Aug 01, 2020 9:04 pm

Re: Any way to block incoming sms?

by rskup on Sat Oct 03, 2020 4:45 pm

Yep, me again. Sorry, it looks like I'm dead wrong, I've been testing my FONA 3G for the last hour or two trying to understand the details about receiving texts.

Short story -- yes, it does look like shortly after a text is sent the 5320 downloads that text into its storage all by itself, and then when one sends the command AT+CMGR (sent by readSMS in FONAtest) the 5320 is reading the text from its storage, not from the network like I thought.

I'm guessing the same happens with the 800.

Again, sorry if I've sent you down a bad path, will do some further testing and etc... to try to verify what I think is happening.

Also looking at the command AT+CLCK (Facility Lock) as a possible way to stop the 5320 from checking for texts, looks like the 800 has a similar command.

Gotta say though, these AT Command manuals are hard to understand, am really hoping you will have luck going to your Ting web account and be able to stop incoming texts there like one can with their cell app.

Will update as I find out stuff.

rskup
 
Posts: 33
Joined: Sat Aug 01, 2020 9:04 pm

Re: Any way to block incoming sms?

by rskup on Sat Oct 03, 2020 6:37 pm

Update...

The AT command "AT+CPMS?" tells me that my SMS storage is on the sim card, and that there are 40 "slots" set aside to store a total of 40 messages. Am just trying to fill all those slots and see if I'm charged for any texts after it's filled (but will have to wait as the charges shown on my SpeedTalk account web page seem to lag phone activity by quite a bit of time).

One thing I do notice as that now that all 40 slots are filled, if I send any new texts the 5320 almost immediately sends the message "+SMS_FULL" to the serial monitor for each and every new text.

Still reading and learning, but if having all the incoming slots filled means no new charges, it might be possible to allocate zero slots to incoming messages, which would be super!

Ok, that's the new stuff, will test more tomorrow.

rskup
 
Posts: 33
Joined: Sat Aug 01, 2020 9:04 pm

Re: Any way to block incoming sms?

by rskup on Sun Oct 04, 2020 7:53 am

Ok, gave SpeedTalk overnight to make sure all text charges got updated, and can confirm I was only getting charged for texts IF there was a slot on the sim card available to receive and store it.

Hopefully Ting works the same way as SpeedTalk, so let your 800 fill up with texts, and you shouldn't get charged for any more texts after that.

It's been awhile since I've used FONAtest, but if you enter "S" for "Serial passthru" you should then be able to enter the command:

AT+CPMS?

and see how many slots you have for texts are how many are filled (and I think you have to enter "S" each time you want to enter an AT command, again, been awhile since I used FONAtest).

Here's how my AT+CPMS? reply looks for the 5320:

+CPMS: "SM",40,40,"SM",40,40,"SM",40,40

It's the third group of 40/40 that's associated with the space for receiving texts for both chips (discussed in both AT command manuals).

And since your "fona.sendSMS" function uses AT+CMGS (and not CMGW or CMSS), you shouldn't have any problems with sending messages even though the first 2 sets of numbers might also look "full" in your 800 (briefly discussed in both manuals).

So, looks like that's one way to solve the issue, since you didn't want to be able to receive texts anyways.

Later gonna try some other things to shut down incoming texts rather than just letting the sim storage fill up, will update if I find anything useful.

Ok, hope that helps for now, interesting problem for sure.

rskup
 
Posts: 33
Joined: Sat Aug 01, 2020 9:04 pm

Re: Any way to block incoming sms?

by cry4brk on Sun Oct 04, 2020 1:13 pm

How can they charge you for receiving SMSs? I have never heard of something like this before. You can't use AT commands to stop receiving text messages. You could use some AT+CNMI command to stop the received message being dumped on serial console or stop the notifications, but your network provider will still charge you. Anyway this is some really dumb thing to charge someone for receiving unwanted messages.

cry4brk
 
Posts: 177
Joined: Tue Oct 09, 2012 3:14 pm

Re: Any way to block incoming sms?

by rskup on Sun Oct 04, 2020 1:51 pm

I could have worded things better, it's not that either of our plans charge per text, it's that we have a limit of X texts per month on the plans our FONAs are on.

So enough unwanted incoming texts in a month can interfere with the ability to send out a freezer alarm text, which is what mromero is trying to avoid.

I have confirmed once the 40 slots on my sim card are filled with texts, I can send a dozen texts to my FONA and they will not show up in my SpeedTalk account and count against my monthly limit. So, allowing the slots to fill, and not deleting those texts, is one way to ensure you can still send out a freezer alarm text.

Are you familiar with the AT+CLCK command? It appears that can shut down incoming (or outgoing) services depending on how it's formatted. That's what I've been experimenting with, though having trouble getting it to execute without an error.

But it looks like you can use CLCK with <Class=8> and shut down SMS for the FONA 3G Sim5320 chip, yes, no?

rskup
 
Posts: 33
Joined: Sat Aug 01, 2020 9:04 pm

Re: Any way to block incoming sms?

by mromero on Mon Oct 05, 2020 8:04 am

rskup thank you so much for all the info. I will ck the commands. i contacted Ting and i can diable texting but not incomming alone. I will try the do not delete the texts trick and see if that solves the problem.

I get:
AT+CPMS="SM","SM","SM" so dont know if that means i dont have a limit on the incomming.

At this point i will move on from this. Its a government facility and using Ting allready saves a ton from the usual $40 phone line we contract for regular phones so I appreciate the help but cant continue down the rabbit hole.

mromero
 
Posts: 44
Joined: Fri Mar 18, 2016 12:10 pm

Re: Any way to block incoming sms?

by rskup on Mon Oct 05, 2020 11:27 am

Hi mromero, am really puzzled by that reply from the 800, if you do decide to try it again make sure it's:

AT+CPMS?

and not

AT+CPMS=?

The second command, with the "=", only tells you your storage options for the three SMS storage areas.

Otherwise, I think the "SM" reply is good news. From what I read the storage on a sim card is pretty small (like 32kb - 128kb), and that it stores more than just text messages, so hopefully it won't take too many more texts to fill up.

Ok, hope all goes well!

rskup
 
Posts: 33
Joined: Sat Aug 01, 2020 9:04 pm

Please be positive and constructive with your questions and comments.