CDMA cat! @ #¥ #% (*, Only text messages can be sent if the PDU is not supported. In addition, the Chinese text message is UNICODE and cannot be input in the Super Terminal. Only programs can be written.
This problem is often discussed on the Internet, and sometimes garbled. Post the successful code of C.
Reprinted please indicate the source
Copy codeCode: void SendCHNSms (string content, string phone)
{
// Chinese CDMA Transmission, UNICODE encoded bytes
Byte [] B = Encoding. BigEndianUnicode. GetBytes (content );
// You cannot add 86 to the phone number of the AT command of CDMA. Otherwise, although the message is successfully sent, the SMS center responds to error code 5.
If (phone. IndexOf ("86") = 0)
{
Phone = phone. Substring (2 );
}
// Assume it is a COM3 port.
SerialPort sp = new SerialPort ("com3 ");
// Unlike a GSM cat, the baud rate is 115200. This problem has been plagued for a long time.
Sp. BaudRate = 115200;
Sp. Open ();
// Set Chinese text message
Sp. Write ("AT + WSCL = 6, 4 \ r ");
Thread. Sleep (500 );
// Set text message format
Sp. Write ("AT + CMGF = 1 \ r ");
Thread. Sleep (500 );
// Set the length of the sent number and sent content in bytes.
Sp. Write ("AT + CMGS = \" "+ phone +" \ "," + B. Length + "\ r ");
Thread. Sleep (500 );
// Write
Sp. Write (B, 0, B. Length );
Thread. Sleep (500 );
// Write CTRL + Z to end the text message content. Note that two bytes are required in UNICODE mode. This is also the reason why the operation cannot be performed on a Super Terminal.
Byte [] b2 = new byte [] {0x00, 0x1a };
Sp. Write (b2, 0, b2.Length );
Sp. Close ();
}
May 15 [original] Chinese text message (C #) sent by CDMA cat with AT command (C #)