View Single Post
Posts: 2 | Thanked: 1 time | Joined on Jun 2007
#24
Hello everybody!!!

Before 4 days I bought a N800 and I love it immediately after I powered it up. I didn't believed that it gonna have a so fast interface and of course when I searched the Net for repositories and third party program I went crazy.

It's amazing what one man can do with a small device like that.

The first annoying problem was that there wasn't any automated way to connect to the internet through Bluetooth PAN. USB Dongles have become very cheap these days and so it is, I think, a good way to provide internet to your N800 everywhere a PC and an internet connection exists.

I recently have bought a USB Dongle(Bluetooth), before I bought the N800 and so having been in a situation where I had a PC and internet but not a Wifi connection I tried to connect to internet with N800 through Bluetooth PAN. So I tried to do it with a friends Ubuntu machine and after 3 days search in the threads and google I managed to get it work in an automated way (no Xterm commands or app launcher, only using Nokias Connection Manager).

I must admit that this is a difficult task as the post on the forum are very misleading when you have N800 and not N770 (DUMMY type not working).

At the time I am little stressed up with my thesis so I would like to ask if somebody wants to write a contol panel applet to fully automate the process and at the same time being able to configure the script with the IP address, gateway etc. (maybe DHCP enabled??). It will be I big surprize to Nokia people to provide such a feature out-of-the-box, maybe a deb package for OS 2007. As I see it a matter of time for me to get the free time to study the API and provide to the masses an easy to use, automated feature.

For the task I used dbus-scripts to be able to get the connection manager events.
Download this file dbus-scripts to your Tablet
Then as root run ''dpkg -i dbus-scripts_1.0-2_armel.deb'' from the directory you downloaded the file or you can just open the link from your N800's broswer.


With this script the only thing you want is to have you machine approprietly configured to accept and share your internet connection through bluetooth PAN. It not necessary to run "pand" commands first, as the script establish the connection for you. The only thing you have to do is Enable bluetooth and initiate the dummy ad-hoc connection. After you see the "Connected " message you will probably have Internet Connection working to N800(if your machine's configuration is OK).

I am posting the scripts here. They need futher testing.

add this line in "/etc/dbus-scripts.d/dbus-scripts-example"
Code:
/usr/bin/bluetoothPAN * * com.nokia.icd status_changed * WLAN_ADHOC
to this in a simple manner just copy paste to your terminal:
Code:
echo "usr/bin/bluetoothPAN * * com.nokia.icd status_changed * WLAN_ADHOC" >> /etc/dbus-scripts.d/dbus-scripts-example
Then restart dbus-scripts (as root):

Code:
/etc/init.d/dbus-scripts restart
open a ssh terminal and copy paste the following code.

Code:
echo '#! /bin/sh
#
# This script is invoked by dbus-scripts to enable Bluetooth PAN access
#


# use gainroot to become root and relaunch itself
if [ `id -u` != 0 ] ; then
#if not already root, call itself as root
        exec sudo gainroot <<EOF
exec $0 $*
EOF
        exit $?
fi

BTADDR='your BT MAC ADDRESS'
BTNAME=$5
# The following 2 lines are needed for the static configuration
# If you are using a DHCP configuration you can comment these 2 lines
IP=192.168.2.2
GW=192.168.2.1

# Here you MUST Define the DNS Server -- $NS variable
NS=192.168.2.1

IFACE=bnep0
PAN_ROLE=PANU # remote PAN role, one of PANU, NAP, GN

#thanks to inz on #maemo IRC channel for this
infoprint(){
dbus-send >/dev/null 2>&1 --system --print-reply --dest=com.nokia.statusbar /com/nokia/statusbar com.nokia.statusbar.system_note_infoprint "string:$*" &
}

dummy_wlan_down(){
if ifconfig wlan0 | grep -q "UP BROADCAST RUNNING" ; then
# OK wlan is up, do we have IP set up? if not (=our dummy ad-hoc) bring wlan0 down
ifconfig wlan0 | grep -q "inet addr" || ifconfig wlan0 down
fi
}

bnep_start(){
        dummy_wlan_down
        #insmod just to be sure
        insmod /mnt/initfs/lib/modules/current/bnep.ko
        #start PAN Bluetooth connection
        pand --connect $BTADDR -d $PAN_ROLE
        # wait for the interface created by pand
        s=60
        echo -n "Waiting $s secs for $IFACE"
        while [ $s -gt 0 ] ; do
                ifconfig $IFACE >/dev/null 2>&1 && break
                s=$((s-1))
                [ -t 1 ] && echo -n "."
                sleep 1
        done
        echo
        if ifconfig $IFACE >/dev/null 2>&1 ; then
        # bring it up
        echo "OK, bringing $IFACE up"

# Comment the following two lines if you want to use the DHCP configuration
        ifconfig $IFACE $IP up
        route add default gw $GW

        sleep 2
# Uncomment the following line if you want to have DHCP configuration
# WARNING -- You must set the DNS Server -- $NS variable -- search above for $NS variable
#      udhcpc -i bnep0

# The nameserver must be defined in the $NS variable,
# even with DCHP configuration, 
# because it seems like the udhcpc have to be 
# configured a little bit more, to work appropriatly.
        echo "nameserver $NS" > /tmp/resolv.conf.lo
            [ -t 1 ] || infoprint "Connected to $BTNAME"
        else
            echo "Error: $IFACE not available."
            [ -t 1 ] || infoprint "Connection failed for $BTNAME"
        fi
}

bnep_stop(){
        echo "OK, bringing $IFACE down"
# Uncomment this line if you're using DHCP configuration
# This line tries to kill the DHCP Client
#      kill -15 `ps uaxwww|grep udhcpc|grep -v grep|cut -c 1-5`
        ifconfig $IFACE down
        echo -n '' >/tmp/resolv.conf.lo
        pand -k $BTADDR
        sleep 1
        rmmod bnep
        [ -t 1 ] || infoprint "Disconnected from $BTNAME"
}

if [ "$5" = "BlueToothPAN" ]
then
case "$7" in
  CONNECTED)
        echo "Starting $BTNAME"
        bnep_start
  ;;
  IDLE)
        echo "Stopping $BTNAME"
        bnep_stop
  ;;
esac
fi

exit 0' > test
Follow the instruction of this thread to create a "not-so-dummy" adhoc connection BUT careful to give it the Name "BlueToothPAN" (case-sensitive). Make the appropriate modification to the script (address, dns, gateway) and you with have a fully working N800 connected to the internet, only choosing the "not-so-dummy" adhoc connection from the status bar applet.

If you have enabled a dhcp server, feel free to uncomment the lines for DHCP configuration mentioned in the script and comment the lines that are refering to Static Configuration if you don't want to setup a DHCP Server with PAN

If you are using Windows you will need to Share your Internet Connection and if you running a custom configuration the thing is get more strange. You will have search to google

If noone has the time or the knowledge to write the the applet I am afraid you will have to wait until either nokia(29 June - New firmware) or me provide a complete solutionn to the matter.

Viva Open Source and Linux.

PS: Maybe a dumb question. Is it possible to find the sources of connection manager or are they proprietary code of Nokia?

Last edited by PePPeRV; 2007-07-02 at 01:31.
 

The Following User Says Thank You to PePPeRV For This Useful Post: