GSM Shield program advice

Hello Community, this is my first post here, I am just starting out with Arduino's and programming, its a very steep learning curve but not too difficult, that said I have hit a roadblock

I have tried to find some answers to my problem both here on the forum and from other resources but I just cannot find anything specific so I am hoping I can get some expert guidance from you experts

I am using an Arduino Uno and GSM Sheild 2 (integrated antenna) I am able to make and receive calls, I can get results from the serial monitor (although no actual data presented from the example GSMScanNetworks sketch...)

the objective of my project is thus:

  • receive an incomming call but do not answer
  • either send the calling number in an SMS to another number or save the incomming number to an array to be printed or sent periodically
  • wait 3 rings/10 seconds and forward the call to another number or numbers from a list or array of numbers in sequence or randomly
  • send an SMS to a number with the incomming call details of the call that was forwarded ie caller number and forwarded number

can you please advise if this is even possible, all I can find on call forwarding is using AT commands (which I believe is a manual process in the Serial Monitor screen??)

so is this possible? is there any expert out there that can help an old fella out with the code/sketch? can the Uno support this?

any other advice or guidance you can offer will be greatly appreciated

regards

Dan

can you please advise if this is even possible, all I can find on call forwarding is using AT commands (which I believe is a manual process in the Serial Monitor screen??)

The examples show show you can type an AT command in the Serial Monitor, press send, and have the Arduino send that AT command to the modem.

The modem has NO clue that where the AT command came from, so if the Arduino knows what AT commands to send, it can send them, with no serial input at all.

What you propose sounds possible, but I don't understand why you want to do that.

Hi PaulS, thanks for your quick reply, I work for a Telecoms operator so I am trying to build a very cheap but effective tool for quality testing of a specific error that we sometimes get and which causes customer complaints

the aim is to build this as a cost effective proof of concept to build a business case for a more permanent solution

the other aim of course is for me to learn about the Arduino and programming, I recently got into 3D printing with an Ultimaker 2+ but all of my functional prototypes to date are inanimate objects so I really want to give my projects some life

so regarding your reply, I really am new to this so I am not fully up to speed on how this all hangs together. so AT commands are entered in sketches as well as serial monitor or other devices? whats the difference between an AT command and the commands entered in the sketch? (what does the "AT" stand for?)

sorry if these are really stupid questions, I was really chuffed that I managed to make and receive calls but I am starting to realise that that is really basic stuff

Dan

so thinking about this CCFW is a network setting so the program would have to apply the CCFW when I am not expecting a call and then remove it to allow the incoming call to ring but the forwarded caller will not be presented at the GSM shield

so it looks like its not actually going to be possible

AT commands are entered in sketches as well as serial monitor or other devices?

To the modem, all the AT commands come from the Arduino.

There is no difference between the Arduino populating an array with data from the serial port and the Arduino populating the array some other way, from the modem's point of view.

char someATcommand[] = "AT+CGM";
char serialATcommand[40];

// some code to get data from serial port into serialATcommand

   modem.print(someATcommand);
   modem.print(serialATcommand);

The modem can not tell the difference between the data in the two calls. Assuming, of course, that, in the end, serialATcommand contains a valid AT command.

what does the "AT" stand for?

AT commands are instructions used to control a modem. AT is the abbreviation of ATtention

from:
http://www.developershome.com/sms/atCommandsIntro.asp
which is a good place to start climbing your learning curve.

awesome, thank you very much for the clarifications

so the modem cannot tell the difference it data ie calling number but could the Arduino run a command based on the duration of a ring?

ie if the incoming call clears in under 3 seconds send an SMS of the caller ID to another number

if the incoming call rings for greater than 3 seconds send an SMS of the caller ID and then tell the network to Conditionally Call Forward to the next number in an array (on no answer)

I am finding out that I only know a fraction of what is required to complete this project but I am learning quickly about simplifying the requirements and functionality

Dan

so the modem cannot tell the difference it data ie calling number but could the Arduino run a command based on the duration of a ring?

Something got lost in the translation, I'm afraid.

The Arduino doesn't know how long the modem was aware of an incoming call, unless there is an AT command that it can use to ask the modem that.

if the incoming call rings for greater than 3 seconds

The Arduino would have to poll the modem - "Are you ringing?" - would be one question. When it got an affirmative answer, it would have to ask that over and over until it got a negative answer. Then, it would determine the interval between the affirmative time (which it recorded) and the negative time (which it also recorded). If that interval is greater than the threshold it could do something. If not, it could do something else.

Keep in mind, when you start writing code, that communications between the Arduino and the modem are asynchronous. Try to avoid making the Arduino wait for a response. There are other things it could be doing.

thats great Paul, you obviously know your stuff, I will have to go over some of your old post for some quick learning

many thanks for your advice

Dear Community, after the great advice from Paul above I have been doing a bit of learning and also de-scoped my requirements but I have again got a couple of problems I need to overcome

the sketch I am running is as follows below, I do not need to initiate SMS or PIN entry but if I take that out I have some errors when I compile, also I would like to only print the number if( numtel == +44777* :wink: ie if the number starts with a certain prefix but when I compile it states that serial is not declared…

I wish all calls to be rejected regardless of the number being printed or not, I entered if( numtel == +44777* :wink: after vcs.retrieveCallingNumber(numtel, 20); but think I got the } all messed up

please can you assist if you would be so kind

Dano

// Include the GSM library
#include <GSM.h>

// PIN Number
#define PINNUMBER “”

// initialize the library instance
GSM gsmAccess;
GSMVoiceCall vcs;
GSM_SMS sms;

// Array to hold the number for the incoming call
char numtel[20];

void setup() {
// initialize serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

Serial.println(“Receive Voice Call”);

// connection state
boolean notConnected = true;

// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while (notConnected) {
if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
notConnected = false;
} else {
Serial.println(“Not connected”);
delay(1000);
}
}

// This makes sure the modem correctly reports incoming events
vcs.hangCall();

Serial.println(“Waiting for a call”);
}

void loop() {
// Check the status of the voice call
switch (vcs.getvoiceCallStatus()) {
case IDLE_CALL: // Waiting

break;

case RECEIVINGCALL: // Incomming Call Test

Serial.println(“RECEIVING CALL”);

// Retrieve the calling number
vcs.retrieveCallingNumber(numtel, 20);

// Print the calling number

Serial.print(“Number:”);
Serial.println(numtel);

// Hang up the call
vcs.hangCall();

// Print the date
Serial.println(" 30/01/2018");
break;
}
delay(100);
}

the sketch I am running is as follows below, I do not need to initiate SMS or PIN entry but if I take that out I have some errors when I compile

You make some changes that you don't show us, and you get some errors that you don't show us. Kind of hard to help that way.

I would like to only print the number if( numtel == +44777* :wink:

What number do you want to print? NUMBERS do not have *'s in their ASCII representation.

numtel is an array. It will never equal +44777* ;. It will never equal "+44777* ;", either. You use strcmp() to see if two strings are equal.

but when I compile it states that serial is not declared...

Again, the code that causes the error is missing, as are the exact error messages.

So are code tags.

thanks Paul for the succinct reply again, I was looking for high level pointer not really the answer to the problem otherwise I will not learn anything about programming, I think I am trying to get from A to Z here too fast, in future I will quote the changes and errors

as for the IF statement I was looking for some kind of wildcard that matched the prefix, this is fairly standard in the BI type systems I normally use so thanks for the heads-up on the strcmp for strings, I will look into that now

can anyone recommenced a decent reference book that is both comprehensive and easily navigated as all of the references I have now are in multiple locations ie websites etc

regards

Dan

all of the references I have now are in multiple locations ie websites etc

That's the great thing about the internet. Lots of different perspectives and takes on a given situation. Hey, look, a kitty.

Of course, that's also a drawback, sometimes.

Paul, purely from my own assumptions I dont think strcmp will give me the desired result, I need to do some more reading after work but it looks more like I need to state a String being +380 and then anything greater than +380 being printed in the serial monitor as the actual full length number being sent, I expect I need a “less than” for any number other than +380 ie +381

to summarise I only want to print a caller that has a number starting with +380 anything else I dont need any information other than the shield is waiting for a call

what do you reckon?

Dan

It is helpful, when you talk about strings, to put the string text in quotes.

On the other hand, it does not make sense to talk about one string being more than, or less than, another.

One string can appear before the other, in a dictionary. But "Sue is pretty" is not less than "Zoe is beautiful", in the sense that 10 is less than 12.

to summarise I only want to print a caller that has a number starting with +380 anything else I dont need any information other than the shield is waiting for a call

So, you want to determine if a phone "number" (actually a string) contains "+380", or not. strstr() comes to mind.

yes it seems that is the function I require although I have absolutely no idea how to incorporate that into my sketch ie how to relate the string to the phone number in the array…

yep seems I am trying to do something nobody has done before, at least with an Arduino and GSM Shield, I also wanted to have the output stream to a Nextion screen, nothing too fancy just the same output as the serial monitor really but I will probably have to bin that idea. back to the drawing board

I have absolutely no idea how to incorporate that into my sketch ie how to relate the string to the phone number in the array

Some place in your code, you have a telephone "number" in a string. Some place in your code, you care if the phone "number" in the array contains/starts with/is some specific string (such as "+380").

It is at that 2nd place where you would call strstr().