Receive short messages through string

Source: Internet
Author: User
Tags volatile

A year ago I wrote "Send and receive short message via serial port (on), (next)" Two articles, discussed in Te (PC, SCM system, etc.) using extended at command control me (mobile phone, GSM module, etc.) to send and receive short messages of the basic method. The method of accepting/reading short message using active query. Te sends the "AT+CMGL" instruction, and me outputs the received and stored SMS messages. This is more in line with the spirit of the at instruction set: Ask and answer. But in the practical application, it is found that this method has some disadvantages:

Me receives the message and stores it, and then transmits it to TE during the query, and there is always a delay in the middle. This delay depends on the query interval.

After issuing the directive, no matter how many messages I have, there is always a long delay in the TE to receive the final "OK". The complete process typically lasts 5-10 seconds.

This paper introduces a method of receiving short message via serial port "real Time". When I receive a message, I initiate a notification to TE, or forward the message directly to TE. It is similar to the interrupt mechanism compared to the query mechanism.

First, briefly describe the concept of the short message Class (class): According to the location of the specified store, the short message is divided into class 0–3 four classes. You can also not specify a class (no Class), which is processed by my default settings and stored in memory or in a SIM card. In the Tp-dcs byte of TPDU, when BIT7-BIT4 is 00x1, 01x1, 1111, the bit1-bit0 indicates the class to which the message belongs:

00–class 0: Show only, do not store

01–class 1: Stored in me memory

02–class 2: stored in SIM card

03–class 3: Direct transmission to TE

GSM modem generally supports a "at+cnmi" instruction, can be used to set when a certain type of short message arrives, how to dispose of it: only stored in the specified memory (volatile/non-volatile), the first storage to notify TE, or directly forwarded to TE, and so on.

The "at+cnmi" instruction syntax is

AT+CNMI=[<mode>[,<mt>[,<bm>[,<ds>[,<bfr>]]]]]

mode-Notification Mode:

0– does not notify TE.

A/T notifies TE when the data cable is idle, otherwise the TE is not notified.

2– notify Te. When the data cable is occupied, buffer first, wait for the data line to be idle, and then notify.

3– notify Te. When the data cable is occupied, notifications are mixed in the data to be transmitted together.

MT-Message storage or direct forwarding to TE:

0– storage to the default memory location (including Class 3)

Save to the default memory location and notify Te (including Class 3)

2– for Class 2, store to the SIM card, and send a notification to TE, and forward the message directly to the TE for the other class

3– for Class 3, forwards messages directly to TE; for other classes, the same mt=1

BM, DS, bfr meaning, please refer to the relevant standard documentation. Generally do not need to care about them.

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.