C # Summary of sending and receiving text messages using serial SerialPort

Source: Internet
Author: User

C # Summary of sending and receiving text messages using serial SerialPort


Development Environment: vs2008 + sqlserver2008 + single-port SMS cat + 8-port SMS cat

Knowledge: serial port parameter configuration + common SMS operations + encryption and decryption of SMS Codes

The following describes the relevant knowledge and experience in detail and summarizes:


1. Serial Port parameter configuration:

Portname serial port name, COM1, com2, com3, com4, com5, com6, COM7, com8, com9, com10, etc (the default includes COM1-COM4, desktop default COM1-COM2, single-port SMS cat port is the serial port number corresponding to the laptop or desktop, and multiple-port SMS cat corresponds to the port number after the laptop or desktop ).

Baudrate baud rate (for single-port SMS cats, the default value is 1152000, and for 8 SMS or MMS cats, the value is)

Parity parity (you can select the default setting instead of custom configuration)

Databits data bit (basically set it by default, no custom configuration is required)

Stopbits stop bit (select the default setting instead of custom configuration)


Two common operations for SMS cats:

SMS cat encoding mode:

The commands are at + cmgf = 0 and at + cmgf = 1 respectively.

SMS cat module model or machine code. The corresponding command is at + cgmi

Reading text messages from SMS cats is divided into the following types:

Read all read text messages. The command is at + cmgf = 1.

Read all unread SMS messages. The command is at + cmgf = 0.

Read all sent messages. The command is at + cmgl = 3.

Read all unsent messages. The command is at + cmgl = 2.

Read all text messages. The command is at + cmgl = 4.

Reads the text message with the specified number. The command is at + cmgr = number.

The methods for enabling or disabling serial ports to write data are mainly open (), close (), write (string/byte []) that come with the SerialPort object.


3. encryption and decryption of SMS Codes

There are three encoding methods for sending and receiving text messages: 7bit, 8bit, and ucs2. therefore, there are six corresponding encryption and decryption functions.

The operation objects for encrypting text message content mainly include the target encrypted mobile phone number, encrypted text message content, and encrypted SMS center number.

The operation objects used to decrypt the text message content include decrypting the mobile phone number of the sender of the text message, decrypting the time when the text message was received, and decrypting the content received by the text message.

The encoding format for sending text messages is similar to 0011000b6831 ********** 0008c408828265e55feb4e50 (08828265e55feb4e50 indicates that the length of the text message is 08 bytes + the content is Happy Holidays)

The encoding format of the received SMS is similar to that


The above is a summary of my original experience. You can easily find the relevant function methods on the network. For more information, see open-source code http://code.google.com/p/gsmmodem /. However, this is still not perfect. I think it will take at least a month for the average person to study the system that can be used in practical projects. Common operations related to databases, such as recording the receipt of all text messages and sending of text message logs to the database.

Related Article

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.