Hi
No that was not what I was hinting. There are many ways to talk to the SARAU201 GSM module. Low level where you handle everything yourself, or high level using a library.
Reading from your last question, it seems you use the MKRGSM library, which includes a GSM_SMS class
The reference to the Serial tutorial was applicable if you were to read at low level the information from your modem
As when you receive an SMS, the library offers an API that is similar to the Streams (using available() and read()) so you can build a cString and then parse it.
Imagine running this:
// Array to hold the text of the SMS
const byte maxSMSLength = 100;
char smsMessageBody[maxSMSLength + 1];
void setup() {
Serial.begin(115200);
// simulate receiving the SMS
strcpy(smsMessageBody, "garbage +4418779, 20 garbage");
// parse using strtok: http://www.cplusplus.com/reference/cstring/strtok/
strtok (smsMessageBody, "+"); // replace the + by a NULL CHAR
const char * phoneNumberToCallPtr = strtok (NULL, ","); // replace the ',' by a NULL char, pointer after the ','
const char * numberofCallsPtr = strtok (NULL, ""); // we just want the next pointer
// transform the string into a number http://www.cplusplus.com/reference/cstdlib/atoi/
const int totalNumberOfCalls = atoi(numberofCallsPtr);
Serial.print(F("Calling [+"));
Serial.print(phoneNumberToCallPtr); // carefull we removed the +
Serial.print(F("] for "));
Serial.print(totalNumberOfCalls);
Serial.print(F(" times"));
}
void loop() {}
(typed here so not tested).
You should see in the console
[color=purple]Calling [+4418779] for 20 times[/color]
that shows you how I was able to extract from a cString the phone number and then the number of times. So if you were able to receive your SMS into a cString, you could just extract the information that way.
So now if you take the ReceiveSMS example from the documentation and inject the above code into it after building a small buffer with the SMS message, you should be able to have your info in memory as you want and able to proceed
again - I don't have an arduino with me now but that's how a simple structure could work:
#include <MKRGSM.h>
const char PINNUMBER[] = "0000";
// initialize the library instances
GSM gsmAccess;
GSM_SMS sms;
// Array to hold the number a SMS is retreived from
char senderNumber[20];
// Array to hold the text of the SMS
const byte maxSMSLength = 50;
char smsMessageBody[maxSMSLength + 1];
void setup() {
// initialize serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) ;
// Start GSM connectionx
bool connected = false;
while (!connected) {
if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
connected = true;
} else {
Serial.write('.');
delay(1000);
}
}
Serial.println("GSM initialized");
Serial.println("Waiting for messages");
}
void loop() {
int c;
// If there are any SMSs available()
if (sms.available()) {
Serial.println("Message received from:");
// Get remote number
sms.remoteNumber(senderNumber, 20);
Serial.println(senderNumber);
// Read message bytes and print them
int i = 0;
while (((c = sms.read()) != -1) && (i < maxSMSLength)) {
smsMessageBody[i++] = c;
}
smsMessageBody[i] = '\0'; // terminate the cString correctly
Serial.print(F("Received:"));
Serial.println(smsMessageBody);
// Delete message from modem memory
sms.flush();
// this is now where you need to parse the SMS body.
// assume the format is "+YYxxxxxxxxxxx, 20"
// here this is a crude parser, with no test for error
// parse using strtok: http://www.cplusplus.com/reference/cstring/strtok/
strtok (smsMessageBody, "+"); // replace the + by a NULL CHAR
const char * phoneNumberToCallPtr = strtok (NULL, ","); // replace the ',' by a NULL char, pointer after the ','
const char * totalNumberOfCallsPtr = strtok (NULL, ""); // we just want the next pointer
// transform the string into a number http://www.cplusplus.com/reference/cstdlib/atoi/
const int totalNumberOfCalls = atoi(totalNumberOfCallsPtr);
Serial.print(F("Calling [+"));
Serial.print(phoneNumberToCallPtr); // carefull we removed the +
Serial.print(F("] for "));
Serial.print(totalNumberOfCalls);
Serial.print(F(" times"));
for (int callNb = 0; callNb < totalNumberOfCalls; callNb++) {
Serial.print(F("Call #"));
Serial.print(callNb + 1);
// HERE PUT THE CODE TO PLACE A CALL
// remember to add the + in the dialing
// (see example in https://www.arduino.cc/en/Reference/GSMVCSVoiceCall)
}
}
delay(1000);
}
(to be tested, typed here)
The code to place calls should be taken from the example
hope this helps