I have written a Windows app in C# that is supposed to send SMSes using AT commands. I am connecting to the phone over Bluetooth using #32feet library. I obviously use AT+CMGS command for sending an SMS. Everything works fine as long as I send a single message. When I try to send a concatenated message it does no work. The message get split in single messages, which get sent just as they were separate single messages. The messages are properly divedied, readible on the sender and receiver phones (I use UCS2). The pdu string contains the header (UDH) as specified in the GSM documentation. I tested the pdu string trhough online converters and everything looks fine. I tried both HandsFree as well as RFCOMM profiles - same result. My method to send a pdu is like the follwing. For a concatenated SMS I prepare a pdu beforehand (pdu is fine). Anyone knows what could be wrong?
private static void SendPDU(string length, string pdu)
{
string receivedString = string.Empty;
Byte[] dcB = Encoding.ASCII.GetBytes("AT+CMGS=" + length + (char)13);
peerStream.Write(dcB, 0, dcB.Length);
while (!receivedString.Contains(">"))
{
peerStream.Read(dcB, 0, dcB.Length);
receivedString = Encoding.ASCII.GetString(dcB).TrimEnd('\0');
}
dcB = Encoding.ASCII.GetBytes(pdu + (char)26);
peerStream.Write(dcB, 0, dcB.Length);
receivedString = string.Empty;
while (!receivedString.Contains("OK"))
{
peerStream.Read(dcB, 0, dcB.Length);
receivedString = Encoding.ASCII.GetString(dcB).TrimEnd('\0');
}
}
I tried it on different modems (all SAMSUNG phones) with no success. I also got in touch with the network administrator that confirmed they support concatenation.