1

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.

Adam
  • 11
  • 2
  • Ок, I found out that using #32feet library is perhaps not best idea for that kind of task. AT commands, at least those for SMS operations, behave strangely, no matter what Bluetooth profile you get connected to. I tried USB connection and everything seems to work just fine. Still, would be great to get rid of the cable connecton between the PC and the smarphone modem. Anyone anything? – Adam Jun 26 '23 at 07:44

0 Answers0