Cdma cat sends a Chinese text message using the AT command (C #)

Source: Internet
Author: User

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 #)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.