Introduction to advantages of GPRS and knowledge about GPRS internet access)

Source: Internet
Author: User

Source: http://blog.chinaunix.net/uid-20745340-id-1878732.html

 

Single-Chip Microcomputer microcontroller is widely used in embedded systems of various industries and civil applications due to its small size, low power consumption, and convenient use. With the rise and popularization of the Internet, it makes sense for the microcontroller to transmit data over the Internet. Currently, there are two solutions for using a microcontroller to access the Internet: one is to use a microcontroller to drive the NIC and connect to the Internet through Ethernet; the other is to enable the microcontroller to directly drive the modem to dial up the Internet to the ISP over a telephone line. The disadvantage of both solutions is that wired networks are used and cannot be used in remote areas or mobile systems.

To solve this problem, a GPRS-based Single-Chip Microcomputer solution is proposed, that is, the PPP protocol is implemented in the single-chip microcomputer, And the GPRS module is connected to the Internet through the GPRS wireless network. This solution has the following advantages:

① Wide coverage, applicable to remote areas;

② Wireless Internet access, applicable to mobile targets;

③ Using a cheap microcontroller is simple and cost-effective;

④ Easy to install and easy to maintain.

 

GPRS Technology and Its Features

General Packet Radio Service (GPRS) is short for universal grouping wireless services. It is a data transmission mode developed based on GSM. Compared with the original GSM, GPRS has obvious advantages in carrying and supporting data services: Through the reuse of multiple GSM time slots, it supports a higher data transmission rate, the theoretical peak value reaches kb/s. Different network users share the same group of GPRS channels. However, only when a user needs to send or receive data will the channel resources be occupied. In this way, multi-user business reuse is used to make more effective use of wireless network channel resources, which is especially suitable for sudden and frequent small-traffic data transmission and well adapted to the sudden characteristics of data services; the GPRS billing method is more flexible and supports billing by data traffic. Unlike the Wireless Application Protocol (WAP) technology, GPRS can provide users with transparent IP channels at any time, direct access to all sites and resources on the Internet; Channel multiplexing technology is used to ensure that every GPRS user can stay online forever; in addition, GPRS also supports voice calls while transmitting data. Compared with other wireless data communication services such as short messages, GPRS has obvious price advantages. Currently, China Mobile's GPRS internet access service is only 3 cents per kilobytes, and users can further reduce the cost of GPRS communication by monthly rent, monthly subscription, and Other forms based on their own needs. Therefore, using GPRS to transmit remote data is very economical and practical, especially for remote areas and mobile devices that are not easy to establish wired networks.

 

Hardware connection and GPRS module settings

The GPRS module is generally used for data transmission over the GPRS network. Currently, the GPRS module generally refers to the GSM module with the GPRS function, which can be used for data communication through the GPRS network. Among them, the more popular are the wismo series of French wave Corporation and the S series of Siemens Corporation. The wismo Module Interface of Wavecom is simple, easy to use, and powerful.

Among them, the GPRS module communicates with the single-chip microcomputer through a serial port, and the communication speed can reach 115 Mbit/s at the fastest. The communication protocol between the module and the controller is the AT command set. Most of the commands comply with the "at command set for GSM mobile equipment (me) (GSM 07.07 version 6.4.0 release 1997) ", but there are also some AT commands defined by Wavecom. In addition to serial sending (TX) and serial receiving (RX), the microcontroller and the GPRS module also have some hardware handshake signals, such as DTR, CTS, and DCD. To simplify the control of the microcontroller, do not use all the hardware handshake signals during hardware design. Instead, use data carrier detect (DCD) and Data Terminal ready, DTR) signal. The DCD signal can detect whether the GPRS module is in the data transmission status or at Command Transmission status. The DTR signal is used to notify the GPRS module that the transmission has ended.

 

After the hardware connection is complete, you must set the GPRS module before accessing the Internet through GPRS. The main settings include:

① Set the communication baud rate. You can use the at + IPR = 38400 command to set the baud rate to 38 400b/s or another suitable baud rate. The default communication speed is 9600b/s.

② Set the Access Gateway and use the at + CGD cont = "1", "ip", and "cmnet" commands to set the GPRS Access Gateway as the mobile Dream network.

③ Set the category of a mobile terminal and use at + cgclass = "B" to set the category of a mobile terminal to Class B, that is, to monitor multiple services at the same time, but only one service can be run, that is, you can only use GPRS to access the Internet at the same time, or use GSM voice communication.

④ Test whether the GPRS Service is activated and use the at + cgact = command to activate the GPRS function. If OK is returned, the GPRS connection is successful. If error is returned, the GPRS connection fails. In this case, check whether the SIM card's GPRS Service has been activated and whether the GPRS module antenna is correctly installed.

China Mobile has established many ISP-equivalent Gateway Support nodes (ggsn) between GPRS and the Internet to connect the GPRS network to the Internet. The GPRS module can call "* 99 *** 1 #" to log on to the ggsn and dynamically allocate an Internet IP address. In the meantime, the communication between the GPRS module and the gateway must comply with the Point-to-Point Protocol (PPP). the user name and password are empty during authentication. After using the PPP protocol to log on, you can connect to the Internet through the ggsn.

 

Overall Software Structure

It is best to write all the code in the program in C language and adopt a layered structure, from the bottom to the top: serial driver layer, GPRS module driver layer, PPP protocol layer, IP protocol layer, UDP protocol layer and application layer. The implementation of upper-layer functions needs to be applied to the underlying functions. The task of the underlying functions is to provide services for the upper-layer functions, and finally complete the application-layer task-transfer data.

 

Driver Programming 

The first is the serial port driver layer. It enables functions such as opening the serial port, closing the serial port, reading the serial port data, and writing the serial port data. Then, compile the GPRS module driver functions based on these serial functions. The single-chip microcomputer controls the GPRS module through a serial port for dialing, setting, and other operations. The control method is to use the AT command. After the GPRS module calls the logon number "* 99 *** 1 #" of ggsn, the GPRS module is transferred to the on-line mode ). At this time, all the data sent by the single-chip microcomputer to the serial port is transparently transmitted to the ggsn, and the answer of the same ggsn is also sent back to the serial port of the single-chip microcomputer. After data transmission is complete, the microcontroller needs to notify the GPRS module to end the session and switch from the online mode back to the normal command mode, which can be completed by setting the high DTR line. At the same time, if the line is abnormally disconnected, the CD line will return to the normal low level. Therefore, in online mode, it is necessary to continuously check whether the CD line is in a high level. Based on these operations, you can write GPRS driver functions: Initialize GPRS module functions, dial-up functions, disconnect functions, and check whether functions are in the online status. These underlying driver functions will facilitate the compilation of the Upper-layer protocol. More importantly, they provide us with a driver abstraction layer. When the underlying hardware is changed, you only need to modify the underlying driver functions, while the Code of the Upper-layer functions remains unchanged.

 

Implementation of PPP protocol

Because the ggsn of mobile Dream network follows the PPP protocol when communicating with the GPRS module, a part of the PPP protocol must also be implemented in the single chip microcomputer before talking to it. After dialing, the GPRS module first negotiates the communication link with the GPRS gateway, that is, negotiates various Link parameter configurations at the point-to-point. The negotiation process complies with LCP (Link Control Protocol), PAP (password authentication protocol), ipcp (Internet Protocol control protocol), and other protocols. The LCP protocol is used to establish, construct, and test link connections. The PAP protocol is used to process password verification. The ipcp protocol is used to set the network protocol environment and assign IP addresses. The negotiation mechanism is implemented using the finite state machine model. Once the negotiation is complete, the link has been created and the IP address has been allocated, and the IP packets can be transmitted according to the negotiation standard. Based on different applications, IP packets can carry UDP packets or TCP or ICMP packets. The system uses UDP packets to transmit data. After the data transmission is complete, the microcontroller will send a LCP disconnect packet to ggsn to terminate the network connection.

The frame structure of the PPP protocol (Figure omitted ). The serial interrupt receiving program of single chip microcomputer first checks whether there is a complete PPP package based on the package start and end characters, and verifies the content of the PPP package to determine the integrity and correctness of the data packet. Then, enter the PPP packet parsing module in the main loop.

 

Logon to ggsn

One difficulty of the system is that the microcontroller logs on to the GPRS Gateway (ggsn) and negotiates with the gateway through LCP, pap, and ipcp protocols. The frame structures of LCP, pap, and ipcp are similar. The most common frames are request (req), accept (ACK), and reject (NAK. The single-chip microcomputer and ggsn negotiate with each other. Either party can send a req frame request for preparation. The other party feels that the configuration is unacceptable and will respond to the Nak frame. If yes, it will respond to the ACK frame. To save resources, we only deal with these three data frames. Other link problems are solved by the single-chip microcomputer under the control of the program.

The negotiation process is roughly described as follows: after successful dial-up connections, ggsn first returns a pap req data frame. We send an empty LCP req frame to force the protocol negotiation phase. Then, ggsn sends the LCP setting frame, and we reject all the settings and request the verification mode. Select chap or PAP for verification on ggsn. We only accept pap. Then, the user name and password are verified by PAP. In GPRS, the user name and password are empty. If the password is successful, ggsn will return the ipcp message with a dynamic IP address. At this point, the process of negotiation with ggsn is completed. The status of the negotiation process is changed to 4.

After the negotiation is completed, the IP datagram communication stage is entered. At this time, all PPP messages sent by the MCU to ggsn containing IP packets will be sent to the corresponding IP addresses in the Internet; all messages sent from the remote end to the IP address of the single chip microcomputer are also sent to the single chip microcomputer through GPRS network, so as to complete the data transmission between the single chip microcomputer and the remote host through the Internet.

Introduction to advantages of GPRS and knowledge about GPRS internet access)

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.