GPRS Internet access solution in embedded Linux

Source: Internet
Author: User
Run # makemenuconfigNetworkDeviceSupport & agrave; & lt; * & gt; PPP (point-to-pointprotocol) support & nbsp

Support PPP for Linux kernel

Go to the Linux kernel directory and run # make menuconfig

Network Device Support à

<*> PPP (point-to-point protocol) support

[*] PPP multilink support

<*> PPP support for async serial ports

<*> PPP support for sync tty ports

<*> SLIP (serial line) support

[*] CSLIP compressed headers

 

Ppp kit installation

 

Ø download ppp: × the latest version is 2.4.4

Unzip ppp-2.4.4.tar.gz to the Directory

* The default ppp source code directory is $ (PPP)

# Tar zxvf ppp-2.4.4.tar.gz

And then cross-compile ppp:

# Cd $ (PPP)

#./Configure

# Make CC =/usr/local/arm/3.4.1/bin/arm-linux-gcc × cross compiler is specified here

Install the ppp kit in the embedded system:

× The default executable file directory in the embedded system is $ (EMB_BIN)

# Cp $ (PPP)/chat $ (EMB_BIN)

# Cp $ (PPP)/pppd $ (EMB_BIN)

# Cp $ (PPP)/pppdump $ (EMB_BIN)

# Cp $ (PPP)/pppstats $ (EMB_BIN)

× Here, the etc Directory of the embedded system is $ (EMB_ETC) by default)

# Mkdir $ (EMB_ETC)/ppp

# Cp $ (PPP)/etc. ppp/* $ (EMB_ETC)/ppp

 

Ppp suite configuration

 

$ (EMB_BIN)/dial-on.sh (GPRS boot script)

 

#! /Bin/sh

 

# Define dial_on function

Dial_on ()

{

# Test if pppd is running

Pppd_stat = 'ifconfig | grep ppp | wc-l | cut-B 7-7'

If [$ pppd_stat-gt 0]

Then

Echo "ppp connection's already started ."

Else

# Close ethernet interface

Ifconfig eth0 down

# Ppp start

Pppd modem/dev/ttyS1 57600 nocrtscts lock connect "chat-v-f/etc/ppp/gprs-connect" user "" noauth debug defaultroute

# Pppd configuration instructions:

# TtyS1: Serial port connecting to the GPRS module SIM300

#57600: GPRS dialing rate

# Nocrtscts: no traffic control

# Lock: lock the device

# Connect "chat-v-f/etc/ppp/gprs-connect": GPRS connection script file

# User "": user name, which is none

# Noauth: no authentication required

# Debug: output debugging information

# Defaultroute: This dial-up connection serves as the default route

Echo "ppp is starting ..."

Fi

}

 

# Dial on gprs

Dial_on

 

# Wait for ppp's init

Sleep 5

 

Pppd_stat = 'ifconfig | grep ppp | wc-l | cut-B 7-7'

If [$ pppd_stat-eq 0]

Then

Echo "trying 2nd time to call ppp"

Dial_on

Sleep 5

Fi

 

Pppd_stat = 'ifconfig | grep ppp | wc-l | cut-B 7-7'

If [$ pppd_stat-eq 0]

Then

Echo "pppd error! "

Echo "please check pppd's config files"

Fi

 

# Open ethernet interface

Ifconfig eth0 up

 

# End

 

$ (EMB_BIN)/dial-off.sh (close GPRS connection script)

 

#! /Bin/sh

 

# Get pppd's pid

Pid = 'pidof pppd'

 

# If pppd process is running

If [-n $ pid]

Then

# Kill pppd

Kill $ pid

# Open the ethernet interface

Ifconfig eth0 up

Echo "ppp connection is closed ."

Else

Echo "ppp connection isn' t existed ."

Fi

 

# End

 

$ (EMB_ETC)/ppp/gprs-connect (GPRS connection configuration file)

 

# GPRS connection timeout settings

TIMEOUT 60

# If the MODEM encounters information such as BUSY, ERROR, or no carrier, stop dialing.

ABORT "BUSY"

ABORT "ERROR"

ABORT "no carrier"

# Sending "AT" command

''At

# When "OK" is returned, send AT + CGDCONT = 1, "IP", "CMNET" command

"OK" "AT + CGDCONT = 1, \ 042IP \ 042, \ 042CMNET \ 042"

# When "OK" is returned, send the ATDT * 99 *** 1 # command

"OK" "ATDT * 99 *** 1 #"

# When "CONNECT" is returned, the dialing ends and the program exits.

"CONNECT"

 

$ (EMB_ETC)/ppp/pap-secrets (GPRS authentication configuration file)

 

# Secrets for authentication using PAP

# Client server secret IP addresses

''*''*

Description

(1) You also need to create a link to $ (EMB_ETC)/resolv. conf in the $ (EMB_ETC)/ppp directory to specify the DNS of the PPP connection.

(2) the eth connection must be closed during a ppp connection. The eth connection has been set in the script. First, the eth connection is closed, and then the ppp connection is established. when the ppp connection is complete, the eth connection is enabled.

(3) it is best to enable the syslogd process in the system. In this way, the DEBUG information of GPRS dialing is recorded in the/var/log/messages file to facilitate debugging.

(4) after running the dialing script, you can use # ifconfig to view the PPP connection information.


This article from The CSDN blog, reproduced please indicate the source: http://blog.csdn.net/baozhongchao/archive/2010/02/03/5284551.aspx

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.