D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

[LUG] Linux Bluetooth Mobile Tethering - was Pigeon beats ISP for data transfer...

 

On Fri, 11 Sep 2009 11:13:34 +0100
Rob Beard wrote:

> Grant Sewell wrote:
> > On Fri, 11 Sep 2009 10:45:41 +0100
> > Rob Beard wrote:
> >   
> >> tom wrote:
> >>     
> >>> I would imagine in Africa in general they havent yet succumbed to
> >>> the data-decompression techniques so beloved of marketing in this
> >>> country that means a 2k info exchange requires 64meg BB and a very
> >>> powerful media-pc to watch a flash of something when all you
> >>> really wanted was to find out how much a widget cost.
> >>>
> >>>       
> >> Well at the moment I'm fixing an e-mail issue for a customer using
> >> SSH, I dare say it would work happily over my mobile GPRS
> >> connection (although I find that I prefer to use a bigger keyboard
> >> than what my mobile offers).  I would have said real keyboard, but
> >> um... I don't have one of those original IBM keyboards.
> >>     
> >
> > Can you not "tether" your phone to your computer with either a USB
> > cable or Bluetooth?  I've even used the God-awful Java-based LogMeIn
> > client tool on my mobile (currently a Nokia N95-1) - grantedly I was
> > glad I was in Truro at the time as we have a pretty good 3G signal
> > in Truro and I really wouldn't want to do that over a GPRS/EDGE
> > connection.  */me shudders at the thought*
> >
> > Grant.
> >   
> I've looked into it but not had any joy just yet (via Bluetooth).  My 
> phone is a Nokia e63 on Three.  Saying that though, I also have the 
> Vodafone Pre-pay 3G modem too which I generally use.  I have also got 
> Putty on my phone although sods law most of what I support is Windows
> based.
> 
> Haven't tried the Java LogMeIn client on my phone.  Actually I may
> give it a try as it would be pretty handy.
> 
> Rob

It took me a fair bit of fiddling, but I got it sorted in the end.  I
posted my efforts to symbian-freak.com's forums but it seems to be
stickied in a subforum that requires membership to view it.

Here's what I originally posted:

It's taken me a little while to get this sorted, but since it is now I
figured I'd share it with you all. Sure, the new Ubuntu (8.10 -
Intrepid Ibex) does the whole "Mobile Internet" thing well, but that
only works cleanly with USB connections... and Ubuntu. Below I will
detail how you should be able to get this to work with any Linux
distribution that runs a newish kernel.

So, first things first... you have a shiny S60 phone (N95-1, in my
case), you have a 3G connection (or 2.5G if you're unlucky), you have
an "unlimited" data plan (which is usually limited:roll:) and you have
a Linux machine (laptop, maybe?) that you want to connect to the
Internet through your phone. All's good, except that there's an
absolute tonne of information out there regarding using those "3G
Dongle" things, and the info regarding setting it up on your phone is
scarce and inaccurate.

Well, you've come to the right place.

If you're using a USB connection, then you will need to make sure that
your Linux supports "ttyACM" devices. So, plug in your phone, select
"PC Suite" on the phone's menu and on the Linux box, open a
command-line and type:
-------------------
dmesg
-------------------
You should see lots of text, and the
bottom few lines will, hopefully, show that a new USB device has been
found and a ttyACM0 device has been registered. Some phones may
register 2 devices (ttyACM0 and ttyACM1).

If your Linux doesn't have ttyACM support... either change your distro
or compile your own ttyACM driver/module. The latter option is beyond
the scope of this how-to, and the former option is a bit off-topic.

Once you have your device registered, all you need to do is get the
dialing programme to work. It has been suggested that you should use
either wvdial or gnome-ppp (if running a GNOME desktop - kppp if you're
running a KDE desktop). Although wvdial is a command-line application,
it's quite easy to work with and doesn't get in your way. I'll be
discussing the wvdial option.

You'll need a config file, normally /etc/wvdial.conf. To edit it you'll
need to either be "root" or use "sudo". Here's mine wvdial.conf file
(I'll comment on it below):
-------------------
[Dialer Defaults]
Init1=ATZ
Init2=ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3=AT+CGDCONT=1,"IP","three.co.uk","",0,0
Baud=460800
Modem Type=Analog Modem
ISDN=0
Phone = *99#
Username = user
Password = passwd
New PPPD = yes

[Dialer BT]
modem=/dev/rfcomm0

[Dialer USB]
modem=/dev/ttyACM0
-------------------
If you're not going to be using any other method of dial-up, then you
can leave it like this. As you can see, there are 3 sections to
my .conf file: Dialer Defaults, Dialer BT and Dialer USB. The Defaults
section contains all the necessary configuration except for the
physical device to dial with.

In the Init3 config line, you'll notice I have "three.co.uk" in the
middle. This is part of the APN details and your mobile provider should
be able to give you that information. If not, check your phone's
setting. For me, I went to Setting -> Connection -> Access Points, then
selected my primary access point and looked at the "Access Point Name"
line.

The other two Init lines should work for S60 phones.

The other really important lines in the Dialer Defaults section are:
Baud=460800
Phone = *99#
Username = user
Password = passwd
New PPPD = yes

Most 3G providers don't bother asking for username/passwords as they
check your IMEI when you try to connect - much easier for them!
However, most dialling software (and you are making a dial-up
connection here) won't work without supplying something. wvdial is no
exception. So, you can reasonably put anything you like in the
username/password lines, but they must exist.

The "New PPPD" line is not vital, but it makes life easier - the ppp
(Point to Point Protocol) daemon will be started when you dial, and
killed when you disconnect. Unless you're turning your machine into an
always-on 3G router, I'd keep this line. Unless you're feeling
brave/daft, I wouldn't change the baud line either.

So, phone number time. If your default/first access point on your phone
is your provider's normal 3G one, then you can keep this as it is.
Sometimes you'll see *99***1# on other websites. This works exactly the
same as *99#.

If, however, the access point you want to use (on your phone) is not
the 1st in your list, then you'll need to specify it... as *99***2# for
the second in the list, etc.

Now to the other two sections.

Remember you found a /dev/ttyACM0 device when you plugged in your phone
to the USB port? Well, that's why it's in this config file. If your
phone presented 2 ttyACM devices (0 and 1), and 0 doesn't work for you,
try /dev/ttyACM1 in your config file instead.

Ok, to test it out all you need to do from the command-line is:
-------------------
wvdial USB
-------------------
You need to specify USB at the end to tell wvdial to use the "Dialer
USB" profile - the defaults section doesn't specify a device to use! To
quit your session, press CTRL+C.

If this works for you, then fantastic! Now let's talk Bluetooth!

Since I'm likely to use my Bluetooth connection fairly frequently, I
don't want the hassle of having to initiate the Bluetooth dial-up every
time I want to use it, so I automated part of it using Linux's own
bluetooth tools.

In /etc/bluetooth directory you'll find a bunch of files. You'll want
to be editing the rfcomm.conf file, but not yet! First thing we need to
do is find the bluetooth MAC address of your phone. There is a *# code
for this, but I can't remember it, so I'll do it the Linux way.

Running the following command gets your Linux box to scan for other
Bluetooth devices in the area and displays the MAC and name:
-------------------
hcitool scan
-------------------
Once you know your phone's MAC address, we can move on.

You'll also need to know what "channel" your phone is listening on for
dial-up networking. The following command (after you've replaced
00:11:22:33:44:55 with your own phone's MAC address) will scan your
phone for its available services, pick out the "Dial Up Networking" bit
and show you the channel line:
-------------------
sdptool browse 00:11:22:33:44:55 | grep -A 10 Dial-Up | grep Channel
-------------------
So, we know the MAC address and the
channel number. Let's edit that rfcomm.conf file!

Presuming you don't already have any rfcomm devices present (ie you're
not exporting your phone's GPS signal via bluetooth and reading it in
under Linux... if so, why are you reading this how-to?!), you can get
away with using rfcomm0, as shown. You'll most likely need to be root,
or use "sudo" to edit this file:
-------------------
rfcomm0 {
        bind yes;
        device 00:11:22:33:44:55;
        channel    2;
        comment "Nokia N95";
}
-------------------
Most lines should be self-explanatory, but the "bind yes" line
essentially means that Linux should actually reserve rfcomm0 for using
on this channel, but not do anything with the device until something
tries to use the /dev/rfcomm0 device.

With this in place, you will probably need to restart your bluetooth
stack. Most distros would use the following to do this, which will
almost certainly need to be run as root (or using "sudo"):
-------------------
/etc/init.d/bluetooth restart
-------------------
So, your Linux box will now try to connect to your phone for dial-up
purposes. If your phone complains and asks for permission, then give
it. You may need to pair your devices before this will work, so try
sending a file from the Linux box to your phone, or vice-versa, until
it asks for a PIN or something. Essentially, as long as your phone
recognises your Linux box and trusts it, it doesn't matter how you get
there!

So, we're almost done. Remember in the wvdial.conf file we
have /dev/rfcomm0 as our "modem" for the Bluetooth profile... now you
see why.

You can test it by running:
-------------------
wvdial BT
-------------------
Don't forget to use CTRL+C to close your session.

So, if you want to connect with your phone, you can either run "wvdial
USB" or "wvdial BT" and keep your fingers crossed. I went a stage
further and wrote a short BASH script (9 lines long) and gave it an
icon on my menu bar. Here's the script contents:
-------------------
connecttype=`zenity\
 --title="N95 Connection"\
 --list \
 --text "Which are you using?"\
 --column "Connection" USB BT`
case $connecttype in
"USB"|"BT")
  xterm -e wvdial $connecttype
  ;;
  "*")
  zenity --title="N95 Connection"\
  --error --text "You didn't specify a connection"
  ;;
esac
-------------------

It uses zenity (because I'm using a GNOME desktop) and pops up a little
dialog box asking simply "USB or BT", and then runs the appropriate
wvdial in an autoclosing terminal window. 

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html