码迷,mamicode.com
首页 > 移动开发 > 详细

[quote] Use Point-to-Point Protocol (PPP) in Android

时间:2014-10-28 19:24:19      阅读:851      评论:0      收藏:0      [点我收藏+]

标签:des   android   blog   http   io   os   ar   java   for   

From http://afewe.wordpress.com/android-arm-development/use-point-to-point-protocol-ppp-in-android/

 

Use Point-to-Point Protocol (PPP) in Android

Requirements:

Android Gingherbread (2.3.4) sources

ppp 2.4.4 (ftp://ftp.samba.org/pub) for the chatscript in Android

ppp 2.4.5 for Ubuntu 11.04 & 8.04 tests

ppp 2.4.3 in Android

any android compatible dev board (used igepv2 from ISEE, beagleboard xm rev c)

2G (GPRS) or greater modem (used Sierra Wireless Q2686 Refreshed and Cinterion BG2 E)

BEWARE: This document is targeted for Android, all information and code is Android related and may not work if you use a “normal” linux distribution (ubuntu, …) .

What is PPP?

All important files usually are in the /system/etc/ppp/ directory, but you have a default link at /etc/ppp/. Mainly,

  • /etc/ppp/options
  • /etc/ppp/chap-secrets
  • /etc/ppp/pap-secrets
  • /etc/ppp/ip-up-ppp0
  • /etc/ppp/ip-down-ppp0
  • /etc/ppp/chatscripts/dialer
  • /etc/ppp/init.gprs-pppd
You also have the 2 binaries I’ll use later: /system/bin/chat, a program used to handle communication with a dial modem, and /system/bin/pppd the PPP daemon.

For tests purposes later on, I’ll use all the pppd options parameters, and the chatscript option and related commands in one instruction. This is more handy than having to modify 2 files and save them. Be careful if you copy paste those lines: the options in the files i mentionned above will also be passed as arguments to the program and may be conflicting with the settings I tested.

Tests on Gingerbread

There are a couple of tests before you can test the above scripts in Android.

First we need, the chat program:

Go to ftp://ftp.samba.org/pub and download the 2.4.4 archive file. Copy the chat dir to ../froyo/external/ppp/ . We are gonna have to make a couple of changes to some files in order to actually build the files.

You have to add this Android.mk file to ../external/ppp/chat/

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES:= 	chat.c

LOCAL_SHARED_LIBRARIES := 	libcutils libc
LOCAL_C_INCLUDES := 	$(LOCAL_PATH)/include
LOCAL_CFLAGS := -DANDROID_CHANGES -DTERMIOS -DSIGTYPE=void -UNO_SLEEP -DFNDELAY=O_NDELAY
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
LOCAL_MODULE_TAGS := eng
LOCAL_MODULE:= chat
include $(BUILD_EXECUTABLE)

Then, use this script

#!/bin/sh
echo "Using defaults"
ANDSOURCES=~/bin
GINGER=$ANDSOURCES/gingerbread
FILES=~/Desktop/Files
PPP=$FILES/ppp
PRODUCT=beagleboard

#copy chat source files
#and compile
cp -r $PPP/chat $GINGER/external/ppp/
cd $GINGER
source build/envsetup.sh
mm chat TARGET_PRODUCT=$PRODUCT -j8

At this point, if the build succeeds (it should), you can add the following lines to the script and save it somewhere: build then push to the device using adb. 

adb push $GINGER/out/target/product/$PRODUCT/system/xbin/chat /system/bin/
adb shell chown root.shell /system/bin/chat

Then, we need BusyBox. Actually we don’t need that yet, but hey, what the hell. Go to How to build Busybox for Android.

First we have to create some files.

  • init.gprs-pppd
#!/system/bin/sh
# An unforunate wrapper script
# so that the exit code of pppd may be retrieved

# this is a workaround for issue #651747
#trap "/system/bin/sleep 1;exit 0" TERM

PPPD_PID=

/system/bin/setprop "net.gprs.ppp-exit" ""

/system/bin/log -t pppd "######## Starting pppd"

PPPD_ARGS=`/system/bin/getprop net.gprs.ppp-args`

/system/bin/log -t pppd "######## pppd additional arguments $PPPD_ARGS"

#/system/bin/pppd /dev/ttyUSB0 115200 dump linkname ppp0 defaultroute usepeerdns nomagic nodetach crtscts debug novj maxfail 1 0.0.0.0: logfile /system/etc/ppp/ppp.log connect "/system/bin/chat -v -s -f /etc/ppp/xgoldDialer"

#/system/bin/pppd connect "/system/bin/chat -V -f /etc/ppp/chatScripts/connectScript" disconnect "/system/bin/chat -V -f /etc/ppp/chatScripts/disconnectScript"
/system/bin/pppd /dev/ttyUSB0 115200 modem linkname ppp0 user "" persist defaultroute noipdefault usepeerdns -detach crtscts noauth debug noccp novj maxfail 1 0.0.0.0: logfile /system/etc/ppp/ppp.log connect "/system/bin/chat -v -s -f /etc/ppp/chatScripts/connectScript"

#/system/bin/pppd /dev/ttyUSB0 115200 logfile /system/etc/ppp/ppp.log linkname ppp0 defaultroute crtscts nomagic dump noccp usepeerdns debug noauth novj user "" connect "/system/bin/chat -V -f /etc/ppp/chatScripts/connectScript"

PPPD_EXIT=$?
PPPD_PID=$!

/system/bin/log -t pppd "######### pppd exited with $PPPD_EXIT"

/system/bin/setprop "net.gprs.ppp-exit" "$PPPD_EXIT"
  • ip-up-ppp0
#!/system/bin/sh
#
# This script is run by the pppd after the link is established.
# It uses run-parts to run scripts in /etc/ppp/ip-up.d, so to add routes,
# set IP address, run the mailq etc. you should create script(s) there.
#
# Be aware that other packages may include /etc/ppp/ip-up.d scripts (named
# after that package), so choose local script names with that in mind.
#
# This script is called with the following arguments:
#    Arg  Name                          Example
#    $1   Interface name                ppp0
#    $2   The tty                       ttyS1
#    $3   The link speed                38400
#    $4   Local IP number               12.34.56.78
#    $5   Peer  IP number               12.34.56.99
#    $6   Optional ``ipparam‘‘ value    foo

# The  environment is cleared before executing this script
# so the path must be reset
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/system/bin
export PATH
PREFIX=ppp0
/system/bin/log -t pppd "ppp/ip-up script started"

# These variables are for the use of the scripts run by run-parts
PPP_IFACE="$1"
PPP_TTY="$2"
PPP_SPEED="$3"
PPP_LOCAL="$4"
PPP_REMOTE="$5"
PPP_IPPARAM="$6"
export PPP_IFACE PPP_TTY PPP_SPEED PPP_LOCAL PPP_REMOTE PPP_IPPARAM

# as an additional convenience, $PPP_TTYNAME is set to the tty name,
# stripped of /dev/ (if present) for easier matching.
PPP_TTYNAME=`/system/bin/basename "$2"`
export PPP_TTYNAME 

# If /var/log/ppp-ipupdown.log exists use it for logging.
if [ -e /var/log/ppp-ipupdown.log ]; then
  exec > /var/log/ppp-ipupdown.log 2>&1
  echo $0 $*
  echo
fi

# This script can be used to override the .d files supplied by other packages.
if [ -x /etc/ppp/ip-up.local ]; then
  exec /etc/ppp/ip-up.local "$*"
fi

/system/bin/run-parts /etc/ppp/ip-up.d   --arg="$1" --arg="$2" --arg="$3" --arg="$4" --arg="$5" --arg="$6"

/system/bin/setprop "net.interfaces.defaultroute" "gprs"
/system/bin/setprop "net.$PREFIX.dns1" "$DNS1"
/system/bin/setprop "net.$PREFIX.dns2" "$DNS2"
/system/bin/setprop "net.$PREFIX.local-ip" "$PPP_LOCAL"
/system/bin/setprop "net.$PREFIX.remote-ip" "$PPP_REMOTE"
/system/bin/setprop "net.$PREFIX.gw" "$PPP_REMOTE"

/system/bin/log -t pppd "Using prefix $PREFIX"
/system/bin/log -t pppd "IP-UP TRACE for gprs"
/system/bin/log -t pppd "DNS1 $DNS1"
/system/bin/log -t pppd "DNS2 $DNS2"
/system/bin/log -t pppd "local-ip $PPP_LOCAL"
/system/bin/log -t pppd "remote-ip $PPP_REMOTE"
/system/bin/log -t pppd "gw $PPP_REMOTE"
/system/bin/log -t pppd "IP-UP END TRACE for gprs"

# if pon was called with the "quick" argument, stop pppd
if [ -e /var/run/ppp-quick ]; then
  rm /var/run/ppp-quick
  wait
  kill $PPPD_PID
fi

/system/bin/log -t pppd "ppp/ip-up script ended"
  • ip-down-ppp0
#!/system/bin/sh
#
# This script is run by the pppd _after_ the link is brought down.
# It uses run-parts to run scripts in /etc/ppp/ip-down.d, so to delete
# routes, unset IP addresses etc. you should create script(s) there.
#
# Be aware that other packages may include /etc/ppp/ip-down.d scripts (named
# after that package), so choose local script names with that in mind.
#
# This script is called with the following arguments:
#    Arg  Name                          Example
#    $1   Interface name                ppp0
#    $2   The tty                       ttyS1
#    $3   The link speed                38400
#    $4   Local IP number               12.34.56.78
#    $5   Peer  IP number               12.34.56.99
#    $6   Optional ``ipparam‘‘ value    foo

# The  environment is cleared before executing this script
# so the path must be reset
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/system/bin
export PATH

# These variables are for the use of the scripts run by run-parts
PPP_IFACE="$1"
PPP_TTY="$2"
PPP_SPEED="$3"
PPP_LOCAL="$4"
PPP_REMOTE="$5"
PPP_IPPARAM="$6"
export PPP_IFACE PPP_TTY PPP_SPEED PPP_LOCAL PPP_REMOTE PPP_IPPARAM

# as an additional convenience, $PPP_TTYNAME is set to the tty name,
# stripped of /dev/ (if present) for easier matching.
PPP_TTYNAME=`/system/bin/basename "$2"`
export PPP_TTYNAME 

# If /var/log/ppp-ipupdown.log exists use it for logging.
if [ -e /var/log/ppp-ipupdown.log ]; then
  exec >> /var/log/ppp-ipupdown.log 2>&1
  echo $0 $*
  echo
fi

# This script can be used to override the .d files supplied by other packages.
if [ -x /etc/ppp/ip-down.local ]; then
  exec /etc/ppp/ip-down.local "$*"
fi

/system/bin/run-parts /etc/ppp/ip-down.d   --arg="$1" --arg="$2" --arg="$3" --arg="$4" --arg="$5" --arg="$6"

Good links

http://ppp.samba.org/ppp/pppd.html

38 thoughts on “Use Point-to-Point Protocol (PPP) in Android”

    1. bubuko.com,布布扣vikaskmDecember 23, 2011 at 7:35 am

      Where should one create the files?

      ip-down-ppp0
      ip-up-ppp0
      init.gprs-pppd

      Reply ↓
      1. bubuko.com,布布扣adrienferrePost authorDecember 23, 2011 at 8:14 pm

        Hi,

        ip down and ip up should be in /etc/ppp/ if i remember correctly.
        init.gprs-pppd can be wherever you want it to be. Just change the path in the relevant scripts.

        Reply ↓
    2. bubuko.com,布布扣vikaskmJanuary 19, 2012 at 7:51 am

      Hi Adrien,

      I have a USB modem , i am to connect to internet using the chnages and following your blog.

      But its not automated, i need to make a dialer script, and then run manually the usb_modeswitch commands.

      Can u tell me how can i automate this process, so as soon as i connect the modem, the modeswicth should and run and pppd with the dialer script.

      How doese the apn settings for different modems gets recognised?

      Reply ↓
    3. bubuko.com,布布扣TejasFebruary 14, 2012 at 9:51 pm

      I am using uBlox GSM LEON G200 module and i used above steps but i did not get the internet working. Do i need to change the PTY_PATH in reference_ril.c and comment the “requestSetupDataCall” function?

      Please let me know

      Reply ↓
      1. bubuko.com,布布扣adrienferrePost authorFebruary 14, 2012 at 10:52 pm

        Try to only use pppd to get a working internet connection and then go from there.

        What is the output message (/system/etc/ppp/ppp.log) for pppd?

        Reply ↓
    4. bubuko.com,布布扣TejasFebruary 15, 2012 at 5:52 am

      I am using PPPD from init.rc. I will give you ppp.log very soon but what will be the linkname to provide? Is it ppp0 or ppp? Shall i give anything. In my /dev directory, i can see ppp as an entry so what to do?

      I can follow the above steps but have a bit confusion on reference_ril.c role during system is running. Anyway, let me give you the log first.

      Thanks a lot for your reply.

      BTW, i can do call out using the module so ril is working fine.

      Reply ↓
    5. bubuko.com,布布扣TejasFebruary 15, 2012 at 6:21 pm

      below log i got from ppp.log

      timeout set to 15 seconds
      abort on (DELAYED)
      abort on (BUSY)
      abort on (ERROR)
      abort on (NO DIALTONE)
      abort on (NO CARRIER)
      timeout set to 40 seconds
      send (AT^M)
      expect (OK)
      SIGINT
      timeout set to 15 seconds
      abort on (DELAYED)
      abort on (BUSY)
      abort on (ERROR)
      abort on (NO DIALTONE)
      abort on (NO CARRIER)
      timeout set to 40 seconds
      send (AT^M)
      expect (OK)

      Reply ↓
    6. bubuko.com,布布扣adrienferrePost authorFebruary 15, 2012 at 6:34 pm

      Well you don’t even try to connect to the internet so it goes without saying that you won’t have an internet connection when the script ends.

      You need to tell the modem to connect at some point, by setting the APN (depends on your phone plan provider) and then you usually have to use something like ATD99****1 I think. I didn’t provide this part because this is the part where it really depends in which country you are, what phone provider you subscribed to, which modem you use…

      Plus I think the ^M you see after AT is somewhat of a encoding error.

      Reply ↓
    7. bubuko.com,布布扣TejasFebruary 16, 2012 at 5:08 am

      Dear Adrienferre,
      Thanks for your reply and looking in to the log. I will provide the APN in connectScript and for that i will ask again to provider to give me proper information.

      Once again thanks for your help so far. I will provide a new ppp.log soon.

      Reply ↓
    8. bubuko.com,布布扣TejasFebruary 16, 2012 at 6:57 am

      Here i would like to explain in detail about what i have done to integrate the gsm/gprs modem in to gingerbread.
      I have LEON G200 (2G only) module from uBlox and support gsm, gprs both with in built MUX protocol and working on single serial port only for AT and DATA.

      I followed your previous script for setting RIL and i was able to get the GSM working and can dial out any number. However, after RADIO_POWER (AT+CFUN=1), i am getting some issue in unsolicited response and RADIO treated as death for telephony but from the adb shell, i am writing below command to again start the OnRequest engine:

      #echo -e “AT\r” > /dev/ttyO3

      After doing this, i am getting gsm working and now can do call as well.

      Once i done with GSM part ( with all modification that you said in init.rc and android layer) i started to read PPP post.

      According to this, i have added chat script and looking for conncetScript to make it work. In your init.gprs-pppd script, i have change the physical port from /dev/ttyUSB0 to /dev/ttyO3.i have no idea on linkname.

      up to this point, i have not done anything in reference_ril.c meas for PTY_PATH. It is as below:
      #define PPP_TTY_PATH “/dev/omap_csmi_tty1″

      Now when i loaded everything in to board, i restarted the board and went in to APN menu and gave the required value. and restart the board but net is not working.

      So below are question which i can not figure out by studying so many forum.

      1. If i want to run GPRS then do i need to disable rild from init.rc?

      2. Can i use both, obvious not simultaneously but by switching from GSM-> GPRS and GPRS-> GSM?

      3. in my board, i have /dev/ppp entry what to do with that?

      4. i have read couple of thread and saying that use /dev/ppp for ril and physical port for pppd. i don’t know what is the exact path and how to set that

      5. There are so many forum available but none are clear so here i would like to solve the issue if someone have serial modem and would like to work GSM/GPRS then what are the best steps to get both working. Your “ril” post is awesome for GSM.

      Would you please help me to get things sorted out?

      Thanks in advance.
      Tejas

      Reply ↓
      1. bubuko.com,布布扣adrienferreFebruary 16, 2012 at 8:15 am

        1. No you don’t, especially if you have MUX support.

        2. cf 1.

        3. I think the ppp node is the ppp driver layer. you should see a new entry “ppp0″ when you connect using pppd. This is the linkname part (it defualts to ppp0 if i remember correctly)

        4. see 4.

        5. This part I didn’t do as I bought an Android compatible modem (Cinterion PH8 is shipped with the android ril). To have both working you are on the good track as you already support MUX and this is definetly the way to go. In the end you will have a command port and a data port.

        Once again my advice is that you should drop the ril part for now, get a working internet connection and then move back to the ril and integrate what you did. This would defintely save you time as you won’t have to check whether a bug comes from the ril or the ppp part.

        Reply ↓
        1. bubuko.com,布布扣loveisroseJune 18, 2012 at 8:03 am

          Dear adrienferre,

          Now I am working on RIL (ph8) driver,i’m little bit confusion with starting pppd service, bcoz i am opening data (ttyUSB0)and command port(ttyACM0) but plssss suggest me how to start pppd service and which device name i need to give (i.e ttyACM0 or other).

          Thanks in Advance !!

        2. bubuko.com,布布扣adrienferrePost authorJune 29, 2012 at 8:00 am

          Hi,

          It is strange that you have both ttyUSB0 and ttyACM0. Can you give me more information on how you setup the modem?

          If you are using the ph8 modem, try to contact cinterion so that they give you the RIL they developped.

    9. bubuko.com,布布扣TejasFebruary 16, 2012 at 9:02 am

      Dear adrienferre ,

      Thanks for your prompt reply. Today, i will check with only pppd part. i will drop ril portion for now so i don’t get confused.

      1. I will disable rild from init.rc but not sure if default AT commands will fire or not!!

      2. I wrote that my hardware supports MUX protocol but i have not implemented in to software. I was expecting that from vendor but still did not get a chance so continue on my design.

      I will let you know about my progress.

      Once again thanks a lot!!

      Reply ↓
    10. bubuko.com,布布扣TejasFebruary 16, 2012 at 5:01 pm

      Dear adrienferre ,
      I have removed rild from init.rc and only implemented init.gprs.pppd in to /etc/ppp.

      But still i get an issue in connectScript. Can you please give me your script for cross verify. I will change the APN as per my country.

      Regards,
      Tejas

      Reply ↓
    11. bubuko.com,布布扣TejasFebruary 17, 2012 at 6:01 am

      below is my connectScript:

      #!/system/bin/sh
      TIMEOUT 30 \
      ECHO ON \
      ABORT DELAYED \
      ABORT BUSY \
      ABORT ERROR \
      ABORT NO DIALTONE \
      ABORT NO CARRIER \
      TIMEOUT 15 \
      “‘AT’\
      OK ‘ATZ’\
      OK ‘ATE0’\
      OK ‘AT+IPR=115200’\
      OK ‘ATQ0 V1 E1 S0=0 &C1 &C2 +FCLASS=0’\
      OK ‘AT+CGDCONT=1,”IP”,”TATA.DOCOMO.INTERNET”‘\
      OK ‘AT+CSQ’\
      OK ‘ATD*99***1#’\
      CONNECT ”

      after applying this i am not getting any error in ppp.log but at the logcat i am getting below issue every time:

      I/pppd ( 4699): ######## Starting pppd
      I/pppd ( 4701): ######## pppd additional arguments
      E/pppd ( 4702): Connect script failed
      I/pppd ( 4760): ######### pppd exited with 8

      I hope this will help you. BTW, i am using the same script which you have give in init.gprs-pppd

      Regards,
      Tejas

      Reply ↓
    12. bubuko.com,布布扣adrienferreFebruary 17, 2012 at 9:20 am

      The (dis)connect script doesn’t have #!/system/bin/sh.

      Reply ↓
    13. bubuko.com,布布扣TejasFebruary 20, 2012 at 8:39 am

      Hi Adrienferre,

      I am able to work GPRS from the terminal. Now my next step is to make it accessible from Android UI. Do you have any idea on integration part?

      I think i need to integrate MUX GSM method and need to start it with service in android so i can get more pts devices to do communications.

      If you have something to share then please let me know.

      Regards,
      Tejas

      Reply ↓
      1. bubuko.com,布布扣venkatrajuApril 3, 2012 at 7:59 am

        Hi Tejas says,

        i have been working on gprs/gsm cinterion(tc63i) modem,here also i got one physical serial port. based on some support i have integrated GSM to android frame work and it’s been working fine. through command line i have been establish the gprs connection and this is also working fine. please can you suggest me how to access from Android UI.
        my module vendor also provided me MUX driver.

        please i have been facing this issues from log time onwards.

        Reply ↓
        1. bubuko.com,布布扣adrienferrePost authorApril 3, 2012 at 9:18 am

          Hi,

          I’ve been following your discussion on the rowboat forum. My first question is: have you followed my tutorial? The second question is: what is it you are not able to do if you succeed in integrating your modem? And please don’t copy paste your post :)

    14. bubuko.com,布布扣adrienferreFebruary 20, 2012 at 9:14 am

      The integration part is the topic of a tutorial on this blog.

      Yes you can use the MUX part to have a DATA and a COMMAND port which will allow to do what you intend but I have never even worked on the mux part so I can’t help.

      Could you provide what you finally did here so that others can use your work?

      Reply ↓
      1. bubuko.com,布布扣PrakashJune 28, 2012 at 2:45 pm

        I am also facing the same issues like what Tejas faced. I followed all your conversations and confident to solve the issue. But Tejas simply escaped once he got fixed his issue with the help of your guidance. Such people only looking at their own benefit and never consider about the knowledge transfer from a technical geek like adrienferre.

        BTW, Thanks for given a good tutorial. Appreciate all your efforts.

        Reply ↓
    15. bubuko.com,布布扣venkatrajuApril 3, 2012 at 9:31 am

      Hi adrienferre ,

      i have gone through your tutorial,then only i have done GSM section successfully.
      and also i have made some changed in property_service.c regarding pppd_gprs like you suggest .

      /*
      * White list of UID that are allowed to start/stop services.
      * Currently there are no user apps that require.
      */
      struct {
      const char *service;
      unsigned int uid;
      unsigned int gid;
      } control_perms[] = {
      { “dumpstate”, AID_SHELL, AID_LOG },
      { “pppd_gprs”, AID_RADIO, AID_LOG },
      {NULL, 0, 0 }
      };

      and also i added in init.rc below one

      service pppd_gprs /etc/ppp/init.gprs-pppd
      user root
      group radio cache inet misc
      disable

      i have strictly followed your tutorial,somehow GSM part was working but GPRS part through UI not working.

      please can you tell what is wrong here?

      Reply ↓
      1. bubuko.com,布布扣adrienferrePost authorApril 3, 2012 at 9:38 am

        I can’t if you don’t post some more information. What does “GPRS part through UI not working” mean?

        Reply ↓
    16. bubuko.com,布布扣venkatrajuApril 3, 2012 at 9:44 am

      Hi adrienferre,

      i am not able to run the init.gprs-pppd from init.rc.

      so.
      one more thing is for the time being i don’t wnat GSM and i want only GPRS
      for that what i did is?

      i have written small android application it’s like two buttons one for connect and second one for disconnect,so in jni part if i press connect button i am trying to open my modem file and i am trying to run pppd call gprs from jni layer using like system call like (system(“pppd call gprs”); and also i tried like execl(“/system/bi/pppd”,”pppd”,”call”,”gprs”);
      but these thing not working for me.

      Reply ↓
    17. bubuko.com,布布扣venkatrajuApril 3, 2012 at 10:08 am

      Hi adrienferre,

      what is wrong i am doing..
      please suggest me i have been facing this issues!!!! :(

      Reply ↓
    18. bubuko.com,布布扣adrienferrePost authorApril 3, 2012 at 11:35 am

      Can you post some logs… ?

      Plus you don’t need to double post (20 minutes, come on…), I am currently at work that’s why my answers aren’t immediate.

      Reply ↓
    19. bubuko.com,布布扣venkatrajuApril 3, 2012 at 11:59 am

      Hi adrienferre,

      i am very very sorry !!!!!

      #logcat -b raido

      I/RILC ( 481): ril_event_init …
      I/RIL ( 481): Opening tty device /dev/ttyS0
      I/RIL ( 481): Setting speed
      D/AT ( 481): AT> ATE0Q0V1
      D/AT ( 481): AT ATE0Q0V1
      D/AT ( 481): AT ATS0=0
      D/AT ( 481): AT AT+CMEE=2
      D/AT ( 481): AT AT+CREG=2
      D/AT ( 481): AT AT+CGREG=1
      D/AT ( 481): AT AT^SGAUTH=0
      D/AT ( 481): AT AT+CCWA=1
      D/AT ( 481): AT AT+CMUT=1
      D/AT ( 481): AT AT+CSSN=0,1
      D/AT ( 481): AT AT+COLP=0
      D/AT ( 481): AT AT+CSCS=”UCS2″
      D/AT ( 481): AT AT+CUSD=1
      D/AT ( 481): AT At+cgatt=1
      D/AT ( 481): AT AT+CMGF=0
      D/AT ( 481): AT SCREEN_STATE: true
      D/RILJ ( 171): [0001]> RADIO_POWER
      D/RILJ ( 171): [UNSL] BASEBAND_VERSION
      I/RILC ( 481): RIL Daemon version: android reference-ril 1.0
      D/RIL ( 481): onRequest: SCREEN_STATE
      D/RILJ ( 171): [0000] GET_IMEI
      D/RILJ ( 171): NOTE: mReqWaiting is NOT 0 but1 at TIMEOUT, reset! There still msg waitng for response
      D/RILJ ( 171): WAKE_LOCK_TIMEOUT mRequestList=1
      D/RILJ ( 171): 0: [1] RADIO_POWER
      E/RILJ ( 171): ERROR: mReqPending is NOT 0 but2 at TIMEOUT, reset!
      D/RILJ ( 171): [0004]> GET_IMEISV
      D/RIL ( 481): onRequest: BASEBAND_VERSION
      D/RIL ( 481): onRequest: GET_IMEI
      D/RILJ ( 171): [0002]< BASEBAND_VERSION error: com.android.internal.telephony.CommandException: RADIO_NOT_AVAILABLE
      D/RILJ ( 171): [0003]< GET_IMEI error: com.android.internal.telephony.CommandException: RADIO_NOT_AVAILABLE
      E/RILJ ( 171): ERROR: mReqPending is NOT 0 but1 at TIMEOUT, reset!
      D/RIL ( 481): onRequest: GET_IMEISV
      D/RILJ ( 171): [0004]< GET_IMEISV error: com.android.internal.telephony.CommandException: RADIO_NOT_AVAILABLE
      D/AT ( 481): AT< +CME ERROR: invalid index
      D/AT ( 481): AT< +CME ERROR: invalid index
      D/AT ( 481): AT< +CME ERROR: invalid index
      D/AT ( 481): AT< +CME ERROR: invalid index
      D/AT ( 481): AT< +CME ERROR: invalid index
      D/AT ( 481): AT< +CME ERROR: invalid index

      #logcat

      E/pppd ( 477): Connect script failed
      I/pppd ( 490): ######### pppd exited with 8
      I/pppd ( 494): ######## Starting pppd
      I/pppd ( 496): ######## pppd additional arguments
      E/pppd ( 497): Connect script failed
      I/pppd ( 500): ######### pppd exited with 8
      I/pppd ( 504): ######## Starting pppd
      I/pppd ( 506): ######## pppd additional arguments
      E/pppd ( 507): Connect script failed
      I/pppd ( 510): ######### pppd exited with 8
      I/pppd ( 514): ######## Starting pppd
      I/pppd ( 516): ######## pppd additional arguments
      E/pppd ( 517): Connect script failed
      I/pppd ( 520): ######### pppd exited with 8
      I/pppd ( 524): ######## Starting pppd
      I/pppd ( 526): ######## pppd additional arguments
      E/pppd ( 527): Connect script failed

      /********init.rc**********
      service ril-daemon /system/bin/rild -l /system/lib/libreference-ril.so — -d /dev/ttyS0
      socket rild stream 660 root radio
      socket rild-debug stream 660 radio system
      user root
      group radio cache inet misc audio

      service pppd_gprs /etc/ppp/init.gprs-pppd
      user root
      group radio cache inet misc
      # disabled

      /***********init.gprs-pppd*********/

      #!/system/bin/sh
      # An unforunate wrapper script
      # so that the exit code of pppd may be retrieved

      # this is a workaround for issue #651747
      #trap "/system/bin/sleep 1;exit 0" TERM

      PPPD_PID=

      /system/bin/setprop "net.gprs.ppp-exit" ""

      /system/bin/log -t pppd "######## Starting pppd"

      PPPD_ARGS=`/system/bin/getprop net.gprs.ppp-args`

      /system/bin/log -t pppd "######## pppd additional arguments $PPPD_ARGS"

      /system/bin/pppd /dev/ttyS0 115200 modem linkname ppp0 persist defaultroute noipdefault usepeerdns -detach crtscts noauth debug noccp novj maxfail 1 0.0.0.0: logfile /system/etc/ppp/ppp.log connect "/system/bin/chat -v -s -f /etc/ppp/peers/gprs-chat"

      PPPD_EXIT=$?
      PPPD_PID=$!

      /system/bin/log -t pppd "######### pppd exited with $PPPD_EXIT"

      /system/bin/setprop "net.gprs.ppp-exit" "$PPPD_EXIT"

      /***********gprs-chat***********/

      ABORT ‘BUSY‘
      ABORT ‘NO CARRIER‘
      ABORT ‘VOICE‘
      ABORT ‘NO DIALTONE‘
      ABORT ‘NO DIAL TONE‘
      ABORT ‘NO ANSWER‘
      ABORT ‘DELAYED‘
      REPORT CONNECT
      TIMEOUT 6
      ‘‘
      ‘ATD*99***1#‘
      TIMEOUT 30
      CONNECT ‘‘

      Reply ↓
      1. bubuko.com,布布扣adrienferrePost authorApril 4, 2012 at 6:24 am

        Did you at least read those logs? I believe that reading what the system tells you is a requirement when you want to develop on Android.

        What does the error 8 mean when talking about pppd?

        Reply ↓
    20. bubuko.com,布布扣loveisroseJune 29, 2012 at 8:50 am

      Dear adrienferre,

      Thank you so much for quick reply !!

      Actually modem (ph8) connects to ttyUSB0[data port] & ttyUSB1[command port]. But problem is that i want to make 3g connection. For that instead of dialling from RIL, I’m using the pppd chat scripts. in chat script i’m using ttyACM0 for data connection.The problem is that APN i need to hardcode and build the image and flash on my android device.It works only for that particular n/w carrier but if I use Other SIM and try to connect to 3g then connection is not establishing. Though i use “Settings->wireless&n/w->Mobile n/w->Access Point Names” to set the APN.

      I’m getting “Errror: connection failed !! Modem connection terminated”. if i mention particular carrier’s APN with,

      AT+CGDCONT=1,”IP,,””,0,0″

      Then works fine.

      I would like to make the Generic script to connect to all network’s 3g connection.

      in “init.rc ” i’m starting pppd service as below mentioned
      ———————————————————————-
      service ppp /system/bin/pppd call hsdpa
      user root
      group system radio

      /****hsdpa-connect-chat ***/

      ‘OK’ ‘AT+CGDCONT=1,”IP”,

      here if i omit APN actually it should take subscribed APN and connect to the 3g.but it is not happening.

      Please suggest me to solve this issue.

      Reply ↓
      1. bubuko.com,布布扣adrienferrePost authorJune 29, 2012 at 12:43 pm

        i don’t get it: you say you have ttyUSBx nodes but you then use a ttyACMx node.

        Reply ↓
        1. bubuko.com,布布扣loveisroseJuly 2, 2012 at 1:37 am

          Yeah,i’ve ttyUSBx nodes, i’ve used ttyACMx.

    21. bubuko.com,布布扣benAugust 21, 2012 at 12:08 pm

      Hi adrienferre,

      In the tutorial the ip-up-ppp0 file contains tty name as ‘ttyS1′. In my case the modem uses serial tty interface ttySAC1, i have doubt which interface name to use.
      please help me clear this.
      thanks

      Reply ↓
      1. bubuko.com,布布扣adrienferrePost authorAugust 21, 2012 at 3:05 pm

        Hi,

        You should use the one that appears when you plug in your modem, so ttyASC1 should be fine.

        Reply ↓
    22. bubuko.com,布布扣ManjeetJanuary 17, 2013 at 11:50 am

      Hi adrienferre,

      Thanks for this information it is very useful. I have followed your blog info and able to connect nexus 7 to internet using dialup connection.

      I am using the rosewill modem and dial up connection on Nexus for internet connection.

      I was able to ping by IP successfully. After I added a DNS server with “setprop net.dns1 8.8.8.8” I was able to ping with DNS names.

      Even though the connection is successfully established and I can ping within the shell, the web browser and all other apps show “no connection” and do not attempt to connect to the internet.

      Am I doing anything wrong or have I missed any steps?

      Looking forward to hear from you.

      Thanks,
      Manjeet Kadam

      Reply ↓
      1. bubuko.com,布布扣adrienferrePost authorMay 10, 2013 at 7:10 am

        Hi Manjeet,

        I faced this particular problem and IIRC I solved it by configuring the ppp.dns1 and ppp.dns2 (or net.dns1 and net.dns2, but I guess if you already tested those out, they can’t be the ones). You should take a look at those properties.

        Reply ↓
    23. bubuko.com,布布扣Fabio FumiMay 9, 2013 at 1:16 pm

      Hi, I’m not sure my previous post went through, so asking again…
      I’m porting a GB tablet firmware to JB (https://groups.google.com/forum/#!forum/renesas-emev-osp) and I’m now stuck at the 3G modem integration. I missed what has been customized in GB (though I can access code), so I have to redo the work myself.
      Hence I found your tutorial very useful to this aim, though I still have some doubts I’d like you to clarify.

      1) what needs to be done, in order to make the connection being triggered by the “appearance” of the ttyUSB* devices, when powering up the modem for example?
      2) the chat script invoked by pppd is apparently operator-specific. What should be done to make connection generic and APN-independent?
      3) If rild makes the “trick”, what are the parts that are typically customized and what type of info needs to be collected about the specific modem being used (btw, mine is a ZTE MF-212).

      Thank you in advance
      Fabio

      Reply ↓
      1. bubuko.com,布布扣adrienferrePost authorMay 10, 2013 at 7:07 am

        Hello Fabio

        1) if you want to trigger it when you connect/power the modem, you should look at udev and add a script which would call the ril init. I don’t really know if you need this.

        2) There are several options which should be grouped (modem serial speed, tty name, …), and others which shouldn’t be (authentication, dns adresses, …). PPP offers this kind of hierarchical property definition (see ppp/options) You should take a look at the ppp documentation.

        3) The customised parts should all be in the lower level RIL ( written in c, accessible in hardware/ril/rild IIRC), and those are typically AT command modification or response translation for the upper layers of the RIL. You could have some bug fixes to put in the java layer as well.

        Good luck!

        Reply ↓

[quote] Use Point-to-Point Protocol (PPP) in Android

标签:des   android   blog   http   io   os   ar   java   for   

原文地址:http://www.cnblogs.com/lake-of-embedded-system/p/4057413.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!