Hello all,
I do want to send SMS in case some conditions are met.
I have many conditions, so there is a lot of text.
This is an working example:
void ERR000001() {
sms.SendSMS("123456789", "sampe text sampe text sampe text sampe text sampe text");
}
However, if I do all messages like this, I run out of memory.
This is something that looked promising to me, however it does nor work.
I simply receive an integer number when I do this by SMS.
void ERR000002() {
char m = F("sampe text sampe text sampe text sampe text sampe text");
sms.SendSMS("123456789", m);
}
This is the libraray that I am using:
I have checked the library and found these two functions regarding SMS sending:
char SMSGSM::SendSMS(char *number_str, char *message_str)
{
if(strlen(message_str)>159)
Serial.println(F("Don't send message longer than 160 characters"));
char ret_val = -1;
byte i;
char end[2];
end[0]=0x1a;
end[1]='\0';
/*
if (CLS_FREE != gsm.GetCommLineStatus()) return (ret_val);
gsm.SetCommLineStatus(CLS_ATCMD);
ret_val = 0; // still not send
*/
// try to send SMS 3 times in case there is some problem
for (i = 0; i < 1; i++) {
// send AT+CMGS="number_str"
gsm.SimpleWrite(F("AT+CMGS=\""));
gsm.SimpleWrite(number_str);
gsm.SimpleWriteln("\"");
#ifdef DEBUG_ON
Serial.println("DEBUG:SMS TEST");
#endif
// 1000 msec. for initial comm tmout
// 50 msec. for inter character timeout
if (RX_FINISHED_STR_RECV == gsm.WaitResp(1000, 500, ">")) {
#ifdef DEBUG_ON
Serial.println("DEBUG:>");
#endif
// send SMS text
gsm.SimpleWrite(message_str);
gsm.SimpleWriteln(end);
//_cell.flush(); // erase rx circular buffer
if (RX_FINISHED_STR_RECV == gsm.WaitResp(7000, 5000, "+CMGS")) {
// SMS was send correctly
ret_val = 1;
break;
} else continue;
} else {
// try again
continue;
}
}
gsm.SetCommLineStatus(CLS_FREE);
return (ret_val);
}
char SMSGSM::SendSMS(byte sim_phonebook_position, char *message_str)
{
char ret_val = -1;
char sim_phone_number[20];
ret_val = 0; // SMS is not send yet
if (sim_phonebook_position == 0) return (-3);
if (1 == gsm.GetPhoneNumber(sim_phonebook_position, sim_phone_number)) {
// there is a valid number at the spec. SIM position
// => send SMS
// -------------------------------------------------
ret_val = SendSMS(sim_phone_number, message_str);
}
return (ret_val);
}
Any ideas how I could store the long strings in Flash memory by using F and keep this thing working?
Kr,
Andreas