I have successfully sent a multipart pdu sms,
The problem is when i try to send this SMS to a number on a different network it gives me the following error :
+CMGS ERROR:500
Please can any one tell me what should i do.
atCommandStr = "AT+CMGF=0\r";
comPort.WriteLine(atCommandStr + (char)13);
Console.WriteLine(comPort.ReadExisting());
Thread.Sleep(2000);
for (int i = 0; i < number_of_parts; i++)
{
int oct = (messagesParts[i].ToCharArray().Count() / 2) -1;
atCommandStr = "AT+CMGS=" + oct + "\r";
comPort.WriteLine(atCommandStr + (char)13);
Console.WriteLine(comPort.ReadExisting());
Thread.Sleep(2000);
string path;
path = messagesParts[i] + Char.ConvertFromUtf32(26);
comPort.WriteLine(path + (char)13);
for (int a = 0; a < 100; a++)
{
Thread.Sleep(2000);
string t = comPort.ReadExisting();
Console.WriteLine(t);
if (t != "" && t.Contains("CMGS") || t.Contains("ERROR"))
{
break;
}
}
//Console.WriteLine(comPort.ReadExisting());
}
Did the modem really return
+CMGS ERROR:500
and not+CMS ERROR: 500
? Because in that case, your modem is not compliant with the 27.005 standard which specifiesif sending fails: +CMS ERROR: <err>
.Error code 500 means
unknown error
, so that does not help very much. But I would guess that your length calculation is wrong. From the standard:Is it correct to subtract 1 after dividing by 2? Try to decode exactly what will be sent on TP layer. Try to increase/decrease the length a bit and see if it makes any difference.
Also, since atCommandStr already contains
\r
you should not include the+ (char)13
in