Posts

Showing posts with the label symbian

Mobile Internet over Bluetooth Part 2

Following on from configuring your mobile phone for Internet over bluetooth...

Once you have your device configured, the next thing you need is to connect over bluetooth to some machine to route your traffic for you. I have a laptop with built-in bluetooth and I'm running Redhat Enterprise Linux version 5. You need to configure and setup bluetooth, a ppp bluetooth daemon, and some simple routing to get your phone on the Internet. First off you need to pair your laptop with your phone, there's plenty of info on how to do this around the web and it's simple enough I'll assume you now have a GnuBox configured phone paired with your laptop.

First off you need to set up Internet Connection Sharing (in windows speak) or IP Masquerading (to anybody who know's what they're talking about), on Linux this is done with iptables. Insert the following rules:
  • iptables -A FORWARD -i ppp0 -j ACCEPT
  • iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
  • iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
The last rule for the postrouting chain should point to the interface on your laptop where you have an outgoing Internet connection enabled. In my case this can be either eth0 (the first Ethernet device) or wlan0 (my wireless device, could also be ath0, eth1, etc), so I insert two rules to cover both devices, even though I only show one of these above.

Enable IP forwarding:
  • echo 1 > /proc/sys/net/ipv4/ip_forward
With your bluetooth device turned on, and previously paired with your phone, now all you need to do is set up a ppp daemon listening for incoming bluetooth "serial" type connections. This can be done in a couple of easy commands, first to add the serial protocol to your bluetooth SDP server, then to set up the listening daemon:
  • sdptool add SP
  • dund -n --listen --msdun noauth 192.168.1.1:192.168.1.2 crtscts 115200 ms-dns lock
The second command will start a dun daemon on the command line that doesn't background itself so you can debug your connection if necssary. It will set up a point to point connection between your laptop and the bluetooth connecting device with IP addresses 192.168.1.1 and 192.168.1.2, you can replace these with any addresses you like. It will also ensure the connection is operating at a sensible speed and you should provide a DNS server that will be passed to the device to resolve Internet server names - you can see this from the contents of your current /etc/resolv.conf file.

Start your web browser on your phone and tell it to connect using the Bt access point you have already configured. On the command line on your laptop you should see something similar to:
    Using interface ppp0
Connect: ppp0 <--> /dev/rfcomm1
local IP address 192.168.1.1
remote IP address 192.168.1.2
This shows your phone and your laptop are now connected through a ppp serial type connection over bluetooth using the /dev/rfcomm1 device, your phone will have the IP address 192.168.1.2 and your laptop ppp0 device will have the ipaddress 192.168.1.1. Your phone should have 192.168.1.1 set as the gateway automatically by GnuBox and the DNS address will be passed when dund sets up the ppp connection as per your command line options. Once connected, you should be able to browse the web on your phone for free through your laptop!

As I said, I run Red Hat, which provides for several handy interfaces to help with the setup of Internet over bluetooth from my phone. Here are some further instructions specific, but not limited to, how I've done things on my machine so I everything happens neatly during boot and I don't need to run any commands to set up the connection...
  • You'll want your iptables rules in place when you boot, you can append rules to /etc/iptables.d/ to do this:
    • Add the following lines to a file in /etc/iptables.d/filter/FORWARD/
      • -A FORWARD -i ppp0 -j ACCEPT
      • -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
    • Add the following lines to a file in /etc/iptables.d/nat/POSTROUTING/
      • -A POSTROUTING -o eth0 -j MASQUERADE
      • -A POSTROUTING -o ath0 -j MASQUERADE
  • Use sysctl to configure IP forwarding at boot time
    • Add (or change) the following definition in /etc/sysctl.conf
      • net.ipv4.ip_forward = 1
  • Register the serial protocol at boot time for your SDP server
    • Add the following line to the start definition after SDP is started in /etc/init.d/bluetooth
      • sdptool add SP
  • Start the dund daemon at boot time with the correct configuration options
    • chkconfig dund on (to start the service at boot time)
    • Create a file called /etc/ppp/peers/dun with the following contents
      • noauth
      • 192.168.1.1:192.168.1.2
      • crtscts 115200
      • ms-dns
      • lock
    • Edit the file /etc/sysconfig/dund so you have the following configuration
      • DUNDARGS='--listen --msdun call dun'
These settings should be enough that you can connect your phone to your laptop without having to modify any settings or start any services every time you boot. Once all the services are configured and started, and your phone is paired with the laptop, you will be able to connect to the phone's Bt access point to access the Internet any time you're in range of your laptop.

Mobile Internet over Bluetooth Part 1

I'm one of these "mobile phones are for calls and texts" types, but last year I bought a new phone, shoved in my PAYG SIM, and set about working out how I could connect it to the Internet. I have a Nokia N73 so it doesn't do wifi but I still wanted to be able to synchronise to my Google Calendar. For me this doesn't involve using the Nokia tool set as they're all Windows based. I found out it's possible to do IP over bluetooth on the N73 so I got it going that way. This is great for cheap data connection, I can maintain a PAYG SIM and get as much data as I like for free, but obviously only when I'm in bluetooth range of my laptop. That's absolutely fine for something like calendar synchronisation, which is all I need.

What's sparked off this post is I've just got a new laptop and so I looked out my notes on how to do IP over bluetooth once again and have now got it going on my new machine too. For the benefit of anyone else who might want this type of setup, here's what I did for the phone (how to set up the data connection on the laptop will be coming in Part 2)...

My N73 runs Symbian S60 version 3. This type of phone has all the required software and hardware built in to do what I want. All you need to do is alter the communications database to set yourself up a bluetooth access point and you're done. The problem here is, the mobile network operators don't want this option exposed on your phone so you have to pay them for a data connection. With a little research you can discover third party open source apps to make the necessary modifications to your database to enable these options, I found and am using one called GnuBox.

GnuBox works nicely enough, but getting it going on S60v3 can be tricky. The developer makes the app available for S60v2, hence it doesn't need to be signed in order to access the features locked down on your S60v3 phone. GnuBox requires write access to your comms DB which requires the app to be signed on S60v3, you can't download a signed version, so we're into the realms of self-signing in order to get this working on S60v3. So for S60v3 you need to get hold of a tweaked version of GnuBox, sign it for your phone, install and configure.

Grab the S60v3 version (search for gnubox_s60v3.sis) which must then be signed for your phone (since writing the instructions below, it's become possible to sign symbian apps online at symbiansigned.com):
  • sign up for an ID at http://symbiansigned.com
  • download their certificate request application
    • sadly this is a windows only app, but find yourself a windows box and install+start the app
    • Select an output file for your *.csr file (say gnubox.csr)
    • If you don't have an ACS pub ID, select No. Then select your key output filename *.key (say gnubox.key) and pick a password
    • Fill out the personal info and your IMEI number, find your IMEI by typing *#06# on your phone
    • Add all the capabilities to your certificate request, from the left box to the right
    • Log into symbiansigned.com, click the "My Symbian Signed" tab and upload your gnubox.csr file.
    • You will automatically be taken to the dev cert page. You can download your certificate file (*.cer) to your machine.
  • now you need the signsis files package to sign your app for your phone with your developer certificate
    • run the signsis program, signsis.exe -o -s -v gnubox.sis gnuboxs.sis gnubox.cer gnubox.key [ENTER]
    • This will use your certificate file and key to sign the gnubox.sis file and output gnuboxs.sis for your phone.
    • You can copy gnuboxs.sis to your phone and install it. You will get a warning about it being signed with a developer certificate!

You now have the software in place to configure Internet over bluetooth on your phone, so lets do just that:
  • On the phone go to, Tools -> Settings -> Connection -> Access points, to set up a new access point
    • Options -> New acces point -> use default settings
    • Name the access point, Bt, GnuBox uses this name internally so make sure it is called Bt case sensitive (it stands for bluetooth, duh!).
    • Change the data bearer to "Data call"
    • Set any old dial up number, say 321, this is not at important as it will be nulled by GnuBox later anyway
    • Set a username/password combination with prompt password set to No. Say abc/xyz for username/password, also not important.
    • You should be able to leave the rest of the settings, including, options -> advanced settings, alone!
  • Now start GnuBox, it's installed and located in your applications folder.
    • The phone number you just entered is printed on the screen, but the ModemBearer should still show nothing
    • Go to Options -> Install -> Create records
    • Exit GnuBox with Options -> Exit
    • Start GnuBox again, the ModemBearer should now be set (the exit of GnuBox was just a sanity check to show you this)
    • Select Install -> Set RAS login script
    • Then select 2box bluetooth -> Serial Port, which will tell GnuBox to set a point to point connection between 2 machines when you "dial" your Bt connection later

Thats it, you now have Internet over Bluetooth capability on your phone. The next step is to connect to another machine to act as your router to the Internet, but that's for my next post.