Hello everyone,
I try to send SMS with my GSM Shield V2 and my UNO, I can receive SMS it's not a problem, but I can't
receive multi line SMS, when i try to put '\n' i receive a non ascii character and the backslash is'nt
executed.
My code:
#include <GSM.h>
#define PINNUMBER ""
GSM gsmAccess;
GSM_SMS sms;
char PhoneNumber[30] = "";
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("SMS Messages Sender");
boolean notConnected = true;
while (notConnected)
{
if (gsmAccess.begin() == GSM_READY)
{
Serial.println("GSM initialized");
notConnected = false;
}
else
{
Serial.println("Not connected");
delay(1000);
}
}
if (notConnected == false)
{
}
}
void loop() {
sendSMS();
}
void memset(char *tab, int size)
{
int i = 0;
while (i <= size)
{
tab = '\0';
-
i++;*
-
}*
}
void sendSMS() { -
memset(PhoneNumber, '\0', 30);*
-
Serial.println("Put phonenumber: ");*
-
readSerial(PhoneNumber);*
-
Serial.println(PhoneNumber);*
-
Serial.print("Now, enter SMS content: ");*
-
char txtMsg[1024];*
-
memset(txtMsg, 1024);*
-
readSerial(txtMsg);*
-
Serial.println("SENDING");*
-
Serial.println();*
-
Serial.println("Message:");*
-
Serial.println(txtMsg);*
-
// send the message*
-
sms.beginSMS(PhoneNumber);*
-
sms.print(txtMsg);*
-
sms.endSMS();*
-
Serial.println("\nCOMPLETE!\n");*
}
/* -
Read input serial*
*/
int readSerial(char result[])
{ -
int i = 0;*
-
while (1)*
-
{*
-
while (Serial.available() > 0)*
-
{*
-
char inChar = Serial.read();*
-
if (inChar == '\n')*
-
{*
_ result = '\0';_
* Serial.flush();*
* return 0;*
* }*
* if (inChar != '\r')*
* {*
_ result = inChar;
* i++;
}
}
}
}*
Do you have an idea ?
Thansk_