iphone data share over usb tether?


skeezix

Internal Development
Joined
Mar 11, 2003
Messages
8,063
Website
www.codejedi.com
A couple of past threads have skirted around the idea of BT tether (generally unsuccessful) or wifi tether (jailbreak app on phone to do it, or iphone 4 now has it built in; eventually someone will probably mod firmware to work on 3gs, since Apple limited it arbitrarily :p )


So those are options, but sort of painful for me .. I've got a 3GS. (I try to keep it unjailbroken, as I do a lot of device testing for various things on it, and trying to keep it as stock as possible; besides, I've modded every device I've owned for 20 years, and I'm rather thinking it might be nice to not have to mod this sucker too much, for once ;)


Anyone gotten USB tether (to use data over wifi/gprs) to pandora working?


jeff
 
A couple of past threads have skirted around the idea of BT tether (generally unsuccessful) or wifi tether (jailbreak app on phone to do it, or iphone 4 now has it built in; eventually someone will probably mod firmware to work on 3gs, since Apple limited it arbitrarily :p )


So those are options, but sort of painful for me .. I've got a 3GS. (I try to keep it unjailbroken, as I do a lot of device testing for various things on it, and trying to keep it as stock as possible; besides, I've modded every device I've owned for 20 years, and I'm rather thinking it might be nice to not have to mod this sucker too much, for once ;)


Anyone gotten USB tether (to use data over wifi/gprs) to pandora working?


jeff

I've got bluetooth DUN tethering working reliably for me via pppd on a Nokia N97 mini. (Nokia Series 60) No idea if the iphone can use the same method, but I could probably throw together a script to put my solution in place and PND it up given enough time... (eg at the weekend) I believe I could adapt it for USB DUN tethering, but so far I honestly haven't had a reason to bother with it.


I have no access to an iphone (or any other iOS device for that matter) so I've no way of knowing if this is of any use.
 
List off your steps .. I'll just try and see ;) no need to pnd it up unless it works or if you'd like it yourself. I must be missing something.. Course the iphone naturally hates any oher device :p


Jeffphone
 
I'll try to make this as readable as possible for anyone who wants to try it. I'd appreciate help cleaning it up and clarifying it where my directions are lacking. Please also keep in mind that I've put this together from multiple sources so there is probably quite a lot of room for optimisation, or simply better ways to do things.


The main thing is that you need to know your service providers access point name, and the code you need to "dial" to trigger a connection in the phone.


The former can probably be obtained from your phones access point settings or by asking them directly. (though you may have to pretend to have them guide you through their troubleshooting procedures to get it... When I tried asking for it from my own provider in the past, they refused to give me the information directly until they got to the part of their procedure where they confirm it. :rolleyes: )


The latter is easy on a nokia because it is almost always *99#, *90# or something similar... I have no idea what it would be in the case of an iphone though.


Once you have those the following should work:

  1. Pair the phone via the Bluetooth applet
  2. Obtain the address of the phone and find the channel your phone uses for DUN. This can be done with the following commands:



    Code:
    $ hcitool scan
    
    Scanning ...
    
    	XX:XX:XX:XX:XX:XX	Name of Phone
    
    
    $ sdptool search DUN
    
    Inquiring ...
    
    Searching for DUN on XX:XX:XX:XX:XX:XX ...
    
    Service Name: Dial-Up Networking
    
    Service RecHandle: 0x10021
    
    Service Class ID List:
    
      "Dialup Networking" (0x1103)
    
    Protocol Descriptor List:
    
      "L2CAP" (0x0100)
    
      "RFCOMM" (0x0003)
    
        Channel: CH

    Please note that you will need to have your phone visible to bluetooth scans for these commands to work.

  3. Choose a name for the connection and create a file with that name in /etc/ppp/peers


    Code:
    $ sudo mousepad /etc/ppp/peers/ConnectionName

    It should contain:


    Code:
    nodetach
    
    /dev/rfcomm0
    
    115200
    
    connect "/usr/sbin/chat -f /etc/ppp/chatscripts/ConnectionName"
    
    nomultilink
    
    defaultroute
    
    noipdefault
    
    ipcp-restart 7
    
    ipcp-accept-local
    
    ipcp-accept-remote
    
    ipcp-max-configure 20
    
    ipcp-max-failure 2
    
    lcp-echo-interval 0
    
    lcp-echo-failure 999
    
    modem
    
    nodeflate
    
    nocrtscts
    
    noipdefault
    
    novj
    
    usepeerdns
    
    user ``
    
    password ``
    
    holdoff 10

    Replace ConnectionName with the name of your connection.


    If your connection requires a username and password they should be placed between the ` marks in the lines beginning with user and password.

  4. Create a directory in /etc/ppp/ called chatscripts


    Code:
    $ sudo mkdir /etc/ppp/chatscripts
  5. Create a file in that folder with named for your chosen connection name.


    Code:
    $ sudo mousepad /etc/ppp/chatscripts/ConnectionName

    It should contain:


    Code:
    ABORT BUSY ABORT 'NO CARRIER' ABORT VOICE ABORT 'NO DIALTONE' ABORT 'NO DIAL TONE' ABORT 'NO ANSWER' ABORT DELAYED ABORT ERROR
    
    SAY "Initializing\n"
    
    '' ATZ
    
    SAY "ATE\n"
    
    OK 'AT+CGDCONT=1,"IP","3netaccess"'
    
    OK 'AT'
    
    OK 'ATDT*99#'
    
    SAY "Dialing\n"
    
    
    CONNECT \d\c

    Replace 3netaccess with the access point name of your provider. (3netaccess is specific to 3 Australia)

    Replace *99# with the code to trigger the connection as mentioned above. (if need be)

    I'm not sure if that last line is required, but since it works with it there I haven't messed with it. :)
  6. The next step is to initiate the connection. I do that with the following script that I've placed in my home folder on the NAND. Whenever I want to connect via bluetooth I run this script from a terminal with sudo. Note that my scripting style is mostly a hodgepodge of other peoples code, eg some of the following was lifted directly from the op_bluetooth.sh script from the Pandora's firmware. :)

    Code:
    $ mousepad btconnect.sh



    Code:
    #!/bin/bash
    
    INTERFACE="`hciconfig | grep "^hci" | cut -d ':' -f 1`"
    
    if ! hciconfig "$INTERFACE" | grep UP &>/dev/null; then
    
      /usr/bin/zenity --question\
    
        --title="Bluetooth not enabled!"\
    
        --text="Would you like to start it now?"\
    
        --ok-label="Yes" --cancel-label="Exit"
    
      if [ $? -eq 0 ]; then
    
        /usr/pandora/scripts/op_bluetooth.sh
    
      else
    
        exit
    
      fi
    
    fi    
    
    if ! [ -c /dev/ppp ]; then
    
      mknod /dev/ppp c 108 0 
    
    fi
    
    
    rfcomm bind 0 XX:XX:XX:XX:XX:XX CH
    
    pppd call ConnectionName
    
    rfcomm release 0
    
    notify-send -u normal "Disconnected" -t 10000


    Replace XX:XX:XX:XX:XX:XX and CH with the address and channel noted in step 2

    Replace ConnectionName with the name of your connection

  7. to connect, open a terminal and enter:


    Code:
    $ sudo ./btconnect.sh

    If I need to disconnect the service I switch back to the terminal window and hit Ctrl-C



thoughts?


I would love to be able to clean this up, put together a zenity script to grab the variables and create the relevant files. If you can suggest a good way to do this without requiring the files in NAND I'd be very interested.
 
Neelix, thanks for this great guide. It works perfectly!


Would be cool, if BT DUN connections would be supported by NetworkManager. :)


Has anyone looked into this yet? Otherwise I may do so. We have NetworkManager 0.8 on SZ Beta5. In the meantime, there is NetworkManager 0.94 available. Maybe that alreaedy has some improvements in this direction...?


Daniel
 
I've been meaning to look into that but haven't had much of a chance yet. As I understand it, Modem Manager/Network Manager specifically ignore rfcomm devices during discovery because they expect them be announced by the Gnome Bluetooth Applet.


Blueman's NMDUNSupport plugin uses a workaround for this, (which is what I use under Ubuntu) but I haven't yet found out what that workaround is or how I can apply it under Zaxxon. I suspect it has to do with tweaking the udev rules.


- Neelix
 
I can't get this to work. It seems that my iPhone has no DUN. sdptool search DUN comes up with "Inquiring..." and nothing else. sdptool browse can't find DUN either.


This is iPhone 3GS with iOS 5.1.1.


Is there anything I can do about it?


Regards, A2000
 
Back
Top