ppp套件配置

$(EMB_BIN)/dial-on.sh GPRS启动脚本)

#!/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配置说明:
              # ttyS1:连接GPRS模块SIM300的串口
              # 57600:GPRS的拨号速率
              # nocrtscts:无流控
              # lock:锁定设备
              # connect “chat –v –f /etc/ppp/gprs-connect”:GPRS连接脚本文件
              # user “”:用户名,这里是无
              # noauth:无需认证
              # debug:输出调试信息
              # defaultroute:此拨号连接作为默认路由
              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 关闭GPRS连接脚本)

#!/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连接配置文件)

#GPRS连接超时设置
TIMEOUT      60
#若MODEM遇到BUSY、ERROR、NO CARRIER等信息时,停止拨号
ABORT   "BUSY"
ABORT   "ERROR"
ABORT   "NO CARRIER"
#外送“AT”指令
'' AT
#当得到“OK”回应时,外送AT+CGDCONT=1,"IP","CMNET"命令
"OK" "AT+CGDCONT=1,\042IP\042,\042CMNET\042"
#当得到“OK”回应时,外送ATDT*99***1#命令
"OK" "ATDT*99***1#"
#当得到“CONNECT”回应时,拨号结束,程序退出
"CONNECT"

$(EMB_ETC)/ppp/pap-secrets GPRS认证配置文件)

# Secrets for authentication using PAP
# client    server     secret                    IP addresses
''      *     ''      *
 

Linux内核PPP设置说明

1)       还需要在$(EMB_ETC)/ppp目录下创建指向$(EMB_ETC)/resolv.conf的链接,用于指定PPP连接的DNS。

2)       在ppp连接时,需要关闭eth连接。在脚本中已经设置好了,首先关闭eth连接,然后进行ppp连接,在ppp连接完成时,再开启eth连接。

3)       最好在系统中开启syslogd进程,这样在/var/log/messages文件中会记录GPRS进行拨号的DEBUG信息,便于调试。

4)       运行拨号脚本后,可以使用#ifconfig查看PPP连接信息。


相关内容