maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N900 (https://talk.maemo.org/forumdisplay.php?f=44)
-   -   [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC) (https://talk.maemo.org/showthread.php?t=58570)

jschan 2011-06-21 02:12

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by youth (Post 1030572)
Are there special steps to making this work with an Android Honeycomb tablet? I've been trying the steps in the 1st post, but it hasn't been working. I'm not too familiar with Linux (got far enough to get the PAN tethering has been turned on msg but no net connection) so if there are special steps can they be listed complete in one post.

I haven't looked at it in a while, but when I was getting the Xoom working, I noticed the initial script looked like it might have gotten the dbus-send command to prompt for the internet connection truncated. I don't use it, so I forgot to follow up on that (sorry 9k).

In terms of getting a bluetooth symbol but not the tethering symbol showing: when you pair the n900, are you seeing tethering on the Xoom's n900 bluetooth profile? If so, you might be running into the same problem I *think* I did. I did this all in somewhat of a hurry, but I believe the fix was to make sure the n900 was setting the Xoom's dns values in the dnsmasq run settings. See the script I posted a while ago for the commands and just try adding the dns values to the end of 9000's dnsmasq run command.

youth 2011-06-21 05:02

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
1 Attachment(s)
Playing around with it again & got it to work!

Not doing anything special but it seem very particular in how it starts up.

1. Devices are paired but have to be connected too.
2. Then run that bluetooth-pan-tethering.sh script
3. Now it should be tethered for internet. Doesn't look like you have to be connected to the net on the n900 first for it to work either. Did it as a last step & it worked.

Now if there were a way to have the tablet just activate the net connection on the n900 when it needs it & a way to connect them w/o having to manually activate that script every time or at least a shortcut for it.

Hopefully it'll work the same on the Samsung Tab 10.1 that's gonna replace this Transformer tomorrow.

9000 2011-06-21 05:11

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Glad to see it works for another tablet. Samsung Tab 10.1 should work too as it is running honeycomb.

Cowboy 2011-06-23 11:39

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
hi,

@9000
i tried your howto to share my n900 connection with my eeepad transformer (android honeycomb), but it doesn't work.

could you help me to debug ?

i followed the howto, and the script didn't reported any errors into the terminal.

i installed kernel power for user v47, iptables and pc connectivity manager from extras-devel pr1-3.

i don't know what to do with the options in pc-connectivity-manager...


@youth
i saw in the pic bluetooth tethered, i don't have this on mine !
have you done something special to get this message ?


thanks for helping me
ps:sorry for my english

youth 2011-06-23 18:45

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
The tablet was already paired with the phone & I then connected them. After that ran the script bluetooth-pan-tethering.sh & that symbol came up. Then made sure the phone had a net connection.

That said I just got a different tablet the Samsung Tab 10.1 & I'm having trouble establishing that "Bluetooth Tethered" connection reliably. I hope it's not a hardware issue though it is working right now as I type this message.

9000 2011-06-24 03:25

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by Cowboy (Post 1037092)
hi,

@9000
i tried your howto to share my n900 connection with my eeepad transformer (android honeycomb), but it doesn't work.

could you help me to debug ?

i followed the howto, and the script didn't reported any errors into the terminal.

i installed kernel power for user v47, iptables and pc connectivity manager from extras-devel pr1-3.

i don't know what to do with the options in pc-connectivity-manager...


@youth
i saw in the pic bluetooth tethered, i don't have this on mine !
have you done something special to get this message ?


thanks for helping me
ps:sorry for my english

eeepad transformer is one of the coolest tablets available recently. ;)

For diagnosis please give me the output of the following in N900 after you pairing them up and triggered the script:

Code:

root
ifconfig bnep0
route
ps ax | grep dnsmasq


Cowboy 2011-06-24 08:44

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
actually, i'm downgrading kernel-power on v46 and i will give some feedback.
thx

Cowboy 2011-06-24 14:19

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
I know it's not comparable but i try bluetooth tethering with an android phone (2.2) with the asus eeepad and everything works fine.

iptables v1.4.6
2.6.28.10power46

so here some commands:

ifconfig
Code:

bnep0    Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX 
          inet addr:192.168.3.1  Bcast:192.168.3.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:10 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1978 (1.9 KiB)  TX bytes:128 (128.0 B)

gprs0    Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 
          inet addr:xx.32.xx.1  P-t-P:xx.32.xx.1  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP  MTU:1400  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:98 errors:0 dropped:0 overruns:0 frame:0
          TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:6346 (6.1 KiB)  TX bytes:6346 (6.1 KiB)

phonet0  Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 
          UP POINTOPOINT RUNNING NOARP  MTU:4000  Metric:1
          RX packets:5769 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1487 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:1488024 (1.4 MiB)  TX bytes:72787 (71.0 KiB)

route
Code:

Kernel IP routing table
Destination    Gateway Genmask        Flags Metric Ref Use  Iface
192.168.3.0  *    255.255.255.0  U      0        0    0      bnep0
default          *    0.0.0.0  U      0        0    0      gprs0

ps aux | grep dns

Code:

1151 nobody    2160 S    /usr/sbin/dnsmasq -k -i lo -a 127.0.0.1 -z
 1625 nobody    4292 S    /usr/sbin/dnsmasq -k -I lo -z -a 192.168.3.1 -F 192.1

i don't know if it's a terminal display error: ... -F 192.1

9000 2011-06-24 16:34

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
@Cowboy everything seems fine. Are u sure there is no error during execution? Can you show us the output?

Cowboy 2011-06-24 16:43

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
root
Code:

Nokia-N900:/home/user# ./bluetooth-pan-tethering.sh
+ IP_ADDR=192.168.3.1
+ NETMASK=255.255.255.0
+ DHCP_RANGE=192.168.3.100,192.168.3.127
+ RUNFILE=/var/run/btpan_tethering.pid
+ DNSMASQ=/usr/sbin/dnsmasq
+ modprobe ipt_MASQUERADE
+ iptables -F
+ iptables -t nat -F
+ iptables -t nat -A POSTROUTING -o gprs0 -j MASQUERADE
+ echo 1
+ ifconfig bnep0 down
+ ifconfig bnep0 up
+ ifconfig bnep0 192.168.3.1 netmask 255.255.255.0 up
+ start-stop-daemon -S -p /var/run/btpan_tethering.pid -m -b -x /usr/sbin/dnsmasq -- -k -I lo -z -a 192.168.3.1 -F 192.168.3.100,192.168.3.127 -b
+ run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:Bluetooth PAN Activated


9000 2011-06-24 17:22

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Everything seems to be running fine on N900 side. Would you please show us with photos how you connect to N900 in eeePad? Thanks.

Cowboy 2011-06-24 19:38

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
1
http://img4.hostingpics.net/pics/315219scst1.png

2
http://img4.hostingpics.net/pics/290952scst35.png

3
http://img4.hostingpics.net/pics/784918scst4.png

4
http://img4.hostingpics.net/pics/498057scst5.png

5 bnep0 only appear on n900 (ifconfig) when i click here
http://img4.hostingpics.net/pics/696227scst6.png


I tried Youth solution: start the script then start gprs connection but it doesn't work.
I also tried gprs connection first then the script same result as before.
http://img4.hostingpics.net/pics/349478scst7.png

http://img4.hostingpics.net/pics/507910scst9.png

I think it's an asus eee pad transformer problem i will try your script on ubuntu.
thanks for your help.

http://hpics.li/9999c3f

9000 2011-06-24 20:11

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Let's see if you've followed the correct sequence:

1) Pair up the devices (bnep0 will be created)
2) Start the Internet connection on N900 (gprs0 will be created)
3) Start the script on N900 (the forwarding, routing and DHCP established)
4) Press "Acces Internet" (It's call "Tethering" in English version, the Android will attempt to request N900 for IP address and DNS by DHCP request)

The problem usually arises in step 4, because it'd timeout before your android getting the DHCP reply. If this happen, try running the script again. The script is reentranable such that it can be run as many time as you like.

Oh btw, can you show me the screenshot after you've done step 4? It should have some signal.

Cowboy 2011-06-26 15:13

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
i done exactly in this order but got no results:

1) Pair up the devices (bnep0 will be created) = ifconfig doesn't show bnep0 !?
2) Start the Internet connection on N900 (gprs0 will be created) = ok
3) Start the script on N900 (the forwarding, routing and DHCP established) = ok
4) Press "Acces Internet" = on the previous screenshot it' number 5

so i tried to tether from ubuntu 10.04 (lts) (blueman + NMPANSupport plugin) to asus eeepad and it works (screenshot below)

and i tried to tether from n900 (with your script) to ubuntu and it also works !!

It gets frustrating not to understand what is happening.
The only thing that may seem problematic to me, is the point of creating a bnep0 when pairing.
bnep0 only appears when I press on the "Use internet access eeepad" screenshot 5 in the previous post.

ubuntu sharing its connection on asus eee pad transformer = lagging but works
http://img4.hostingpics.net/pics/381...0626155757.png


9000:
Quote:

Oh btw, can you show me the screenshot after you've done step 4? It should have some signal.
it's the last screenshot on my previous post. And it's says no network.

9000 2011-06-26 17:07

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
@Cowboy Can you setup the IP on eeePad manually? It seems that it can't get the IP address from DHCP server in N900.

Cowboy 2011-06-26 17:28

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
i got it work i can tether from n900 to asus eee pad transformer.

@9000 i don't see any option to set manually ip address, only on wifi options.

i started the script and at the same time pressed "connect" on eeepad

9000 2011-06-26 17:30

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by Cowboy (Post 1039502)
i got it work i can tether from n900 to asus eee pad transformer.

@9000 i don't see any option to set manually ip address, only on wifi options.

i connect eeepad on the same time i run the script ...

How did you get it work, can you share?

Cowboy 2011-06-26 17:38

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
9000:
Quote:

How did you get it work, can you share?
here's what i did:
1) pairing devices
2) making a gprs connection n900
3) open a terminal on n900 and logging as root
4) on eeepad going in bluetooth options
5) n900 starting the script and at the same time clicking on eeepad connect to n900

tethering works pretty well. Thanks again 9000 for your script and trying helping me with this.
http://img4.hostingpics.net/pics/822...6261915151.png

9000 2011-06-26 17:48

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by Cowboy (Post 1039507)
9000: here's what i did:
1) pairing devices
2) making a gprs connection n900
3) open a terminal on n900 and logging as root
4) on eeepad going in bluetooth options
5) n900 starting the script and at the same time clicking on eeepad connect to n900

tethering works pretty well. Thanks again 9000 for your script and trying helping me with this.
http://img4.hostingpics.net/pics/822...6261915151.png

Just as I thought, the eeePad has pretty short timeout period for DHCP request, so timing is very crucial. Thanks for your sharing. One more device confirmed to work. ;)

youth 2011-06-26 19:57

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by Cowboy (Post 1039507)
9000: here's what i did:

5) n900 starting the script and at the same time clicking on eeepad connect to n900

tethering works pretty well. Thanks again 9000 for your script and trying helping me with this.
http://img4.hostingpics.net/pics/822...6261915151.png

Thank you too! I was having problems reliably connecting my Galaxy Tab but your step #5 seems to have done the trick. Kind of odd since timing seemed more lenient on the transformer I had.

Denis 2011-06-29 03:35

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
I've also got an asus transformer, I've managed to get it to tether to the n900 using your PAN script...
only issue I had was that when tethered it still behaved like there was no internet connection...
then I found that iptables had been uninstalled when I uninstalled v47 of the power kernel in order to install v46...

now, all is well :)
thanks for the script!

9000 2011-06-29 07:52

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by Denis (Post 1041191)
I've also got an asus transformer, I've managed to get it to tether to the n900 using your PAN script...
only issue I had was that when tethered it still behaved like there was no internet connection...
then I found that iptables had been uninstalled when I uninstalled v47 of the power kernel in order to install v46...

now, all is well :)
thanks for the script!

Thanks for your feedback. I'm trying to revise the script so as to deal with those devices with short timeout. Anyway, it's good to hear that the script works for you. :rolleyes:

gtab_n900 2011-07-04 09:41

Re: [HOWTO] N900 Bluetooth-PAN Tethering (tested with a WiFi XOOM!)
 
Just like to say a big thanks to jschan and 9000 for all they've written on this topic.

I used jschan's tether scripts with dbus and finally got an unrooted Samsung Tab 10.1 running Android 3.1 tethered via Bluetooth PAN to the N900. The only change I made was to uncomment this line:

Code:

#echo 1 > /proc/sys/net/ipv4/ip_forward
changed to:
Code:

echo 1 > /proc/sys/net/ipv4/ip_forward
Which was commented in the original script. I couldn't get an IP addres without it. The clue was when I tried tethering via kUbuntu and got endless DHCPDISCOVER log messages until timeout which made me search for IP settings in the tether script.

After following jschan's instructions:
1. Turn on BT on the N900
2. Pair gtab with n900
3. N900 BT status icon should turn blue
4. In Wireless & networks > Bluetooth Settings on the gtab your device should be listed as 'Paired' with the Spanner Icon and a darker Bluetooth Tethering icon to the left.
5. Tap the Spanner
6. Under 'Profiles' tap 'Tethering - use for Internet Access'
7. In the status are of the gtab a bright blue Tethering icon will appear, per the screenshot from Youth.

Note with the dbus scripts installed I didn't have to manually run the tethering script to start the process. Battery usage seems ok as well.

Also, I don't have PC Connectivity Manager or Bluez Switch installed.

big thanks again.

9000 2011-07-04 09:49

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Thanks for your report.

I'm researching on the reason why some device can't get the DHCP, may be update the script very soon.

gtab_n900 2011-07-04 13:10

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Hi, the Tab only got an IP address via the N900 when that ip_forward line was uncommented. Prior to that, pairing and 'connection' was completed but without an IP being provide.

I used jschan's tethering script here:
http://talk.maemo.org/showpost.php?p...&postcount=124

You can see here:
# Enable IP forwarding
#echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/conf/$INTERFACE/forwarding
echo 1 > /proc/sys/net/ipv4/conf/$EXTERNAL_INTERFACE/forwarding

That it was commented out.

I tried your initial script right back on page 1 of this thread but it didn't work, although that does have the ip_forward line uncommented.

Hope that helps.

9000 2011-07-04 14:16

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
It uses Google's DNS. It should use your ISP DNS instead.

But as long as it works for you it is fine. ;)

DarkPand0r 2011-07-05 08:49

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Hi Guys,

I'm having a bit of an odd time... It worked fine yesterday to my Transformer (Not Optimus Prime :P).

I've tried to connect today, but the script says "Bnep0 does not exist"
Not sure whats gone wrong :S

I've tried reinstalling Libicd2 to no avail....

9000 2011-07-05 11:22

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Have you paired them up?

rdnetto 2011-07-06 09:11

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
I haven't been able to get mine to pair properly. Tried with my Asus Transformer and an iPad. The icon (on the n900) only stays blue for a moment with the Transformer. It goes blue permanently with the iPad. Neither of them show any profiles as being available, despite being paired. (Also, the Transformer shows it as being paired regardless of whether or not the bluetooth is actually on, so I think it only pairs when you select a profile).

'lsmod | grep bne' shows nothing, and ifconfig doesn't show bnep0 at any stage. The lines referring to it in your script just produce 'no such device'.

Quote:

Originally Posted by 9000 (Post 787864)
Although setting sudoers is better, but it seems to confuse a lot of people. I've made change to the procedure section 4.3.3 to run the script directly with root privilege:

Code:

echo "/home/user/bluetooth-pan.sh" | sudo gainroot

It's easier to just add this to the beginning of the script:
Code:

if [ $(whoami) != "root" ]; then
  echo "$0" | sudo gainroot
  exit
fi


jschan 2011-07-09 05:33

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
1 Attachment(s)
Quote:

Originally Posted by gtab_n900 (Post 1044424)
Hi, the Tab only got an IP address via the N900 when that ip_forward line was uncommented. Prior to that, pairing and 'connection' was completed but without an IP being provide.

I used jschan's tethering script here:
http://talk.maemo.org/showpost.php?p...&postcount=124

You can see here:
# Enable IP forwarding
#echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/conf/$INTERFACE/forwarding
echo 1 > /proc/sys/net/ipv4/conf/$EXTERNAL_INTERFACE/forwarding

That it was commented out...

Thanks for letting me know gtab. I went and made the script update and attached it below. It's pretty much what I posted before except with the added ability to auto connect to GPRS when it's not connected to either GPRS nor WLAN. See the notes in the script for how to configure it if you choose to use it (look for the IAP ID setting).

One tip about the auto connect functionality: if the Internet connection is already up, I never seem to have any problems with my Xoom getting a good connection. However, when the N900 has to establish the connection, it takes longer to get through the script and start up DMASQ, thereby causing the same timing issue some of the other guys have experienced, I believe. Simply breaking the bt connection from the tablet and then re-establishing it always fixes the issue since the Internet connection doesn't have to re-establish itself at that point. I'm guessing all Honeycomb tablets (such as your Galaxy) would behave the same way.

Cheers,

Code:

#!/bin/sh
#
# /opt/tether/tether.sh
#
# Written by jschan @ http://talk.maemo.org
#
# Code snippets and inspiration from:
#  - http://wiki.maemo.org/DbusScripts
#  - http://talk.maemo.org/showthread.php?t=58570
#  - http://code.google.com/p/n900ipv6/source/browse/share/pan
#
# Enables tethering over USB network and Bluetooth PAN.
#
# usage: ./tether.sh start|stop [internal_interface]
#
# Examples:
#  - "./tether.sh start" - Enables tethering on a single PAN client when an Internet connection is active
#  - "./tether.sh stop" - Disables tethering on a single PAN client (assumes the client is on bnep0)
#  - "./tether.sh start bnep1" - Enables tethering on a 2nd PAN client when an Internet connection is active
#  - "./tether.sh stop bnep1" - Disables tethering on the 2nd PAN client, without interfering with the 1st
#
# Notes:
#  - Tested to work with multiple Bluetooth PAN clients including a WiFi-only XOOM
#  - Tested to work in conjuction with a dbus-scripts to automate tethering setups
#  - Doesn't currently have support for multiple concurrent Internet interfaces
#    such as an IPv4 grps connection and a seperate IPv6 grps connection.
#  - IPv6 isn't supported yet... (Waiting for T-Mobile IPv6 activation)
#

# You will want to customize the IAP ID value below
#  - DEFAULT_IAP_ID: This a code uniquely identifying the default GPRS connection to use if you aren't currently connected.
#    It can be obtained with the following command: gconftool -R /system/osso/connectivity/IAP
#    Find lines which matches /system/osso/connectivity/IAP/<IAP_ID> for the GRPS connection you use for Internet connectivity.
#    See http://wiki.maemo.org/Phone_control#Connect_to_specific_saved_connection for more information.
DEFAULT_IAP_ID="efc9b252-9bf3-4aa7-a023-348c2d46f101"
DEFAULT_INTERFACE="bnep0"
PAN_NETWORK_PREFIX="10.20"
USB_NETWORK_PREFIX="10.30"
INTERFACE_OCTET="88"
DHCP_MIN_IP_OCTET="100"
DHCP_MAX_IP_OCTET="127"
DHCP_MAX_LEASE_TIME="1h"
PRIMARY_DNS="8.8.8.8"
SECONDARY_DNS="8.8.4.4"

if [ $# -lt 1 ] || [ $# -gt 2 ]; then
        echo "usage: $0 start|stop [internal_interface]"
        exit 1
fi

if [ -z "$2" ]; then
        INTERFACE="$DEFAULT_INTERFACE"
else
        INTERFACE="$2"
fi

print_message () {
        echo "$(date) $*"
              run-standalone.sh dbus-send \
                --type=method_call \
                --dest=org.freedesktop.Notifications \
                /org/freedesktop/Notifications \
                org.freedesktop.Notifications.SystemNoteInfoprint \
                string:"$*"
}

connect_default_access_point () {
        print_message "Establishing Default Connection"
        dbus-send \
                --system \
                --type=method_call \
                --print-reply \
                --dest=com.nokia.icd \
                /com/nokia/icd \
                com.nokia.icd.connect \
                string:$DEFAULT_IAP_ID uint32:0
        #sleep 2
}
#set -x

INTERFACE_TYPE="$(echo $INTERFACE | sed 's/\([a-z]*\)[0-9]*/\1/')"
INTERFACE_NUMBER="$(echo $INTERFACE | sed 's/[a-z]*\([0-9]*\)/\1/')"

case $INTERFACE_TYPE in
        bnep )
                NETWORK_PREFIX="$PAN_NETWORK_PREFIX.$INTERFACE_NUMBER"
        ;;
        usb )
                NETWORK_PREFIX="$USB_NETWORK_PREFIX.$INTERFACE_NUMBER"
        ;;
        * )
                # Notify no active Internet connection
                print_message "Unsupported interface type: $INTERFACE_TYPE"
                exit 1
        ;;
esac

INTERFACE_IP="$NETWORK_PREFIX.$INTERFACE_OCTET"
NETMASK="255.255.255.0"
EXTERNAL_INTERFACE="$(ifconfig | awk '/(gprs|wlan)/ {print $1}' | head -1)"

DHCP_MIN_IP="$NETWORK_PREFIX.$DHCP_MIN_IP_OCTET"
DHCP_MAX_IP="$NETWORK_PREFIX.$DHCP_MAX_IP_OCTET"
DHCP_GATEWAY="$INTERFACE_IP"

DNSMASQ_PID_NAME="dnsmasq.$INTERFACE"
DNSMASQ_PID_FILE="/var/run/$DNSMASQ_PID_NAME.pid"

if [ "$1" == "start" ]; then
        INTERFACE_EXISTANCE_CHECK="$(ifconfig -a | grep $INTERFACE | awk '{print $1}')"
        if [ -z "$INTERFACE_EXISTANCE_CHECK" ]; then
                # Notify no active Internet connection
                print_message "$INTERFACE does not exist"
                exit 1
        fi

        if [ -z "$EXTERNAL_INTERFACE" ]; then
                connect_default_access_point
                EXTERNAL_INTERFACE="$(ifconfig | awk '/(gprs|wlan)/ {print $1}' | head -1)"

                if [ -z "$EXTERNAL_INTERFACE" ]; then
                        # Notify no active Internet connection
                        print_message "Unable to establish tether for $INTERFACE"
                        exit 1
                fi
        fi

        # Setup interface
        ifconfig $INTERFACE down 2> /dev/null
        ifconfig $INTERFACE up
        ifconfig $INTERFACE $INTERFACE_IP netmask $NETMASK

        # Load modules
        modprobe ipt_MASQUERADE

        # flush old iptables rules
        iptables --flush
        iptables --table nat --flush

        # Setup NAT
        iptables --out-interface $EXTERNAL_INTERFACE \
                --table nat \
                --append POSTROUTING \
                --jump MASQUERADE

        # Enable IP forwarding
        echo 1 > /proc/sys/net/ipv4/ip_forward
        echo 1 > /proc/sys/net/ipv4/conf/$INTERFACE/forwarding
        echo 1 > /proc/sys/net/ipv4/conf/$EXTERNAL_INTERFACE/forwarding

        # Setup DNS and DHCP
        start-stop-daemon \
                --exec /usr/sbin/dnsmasq \
                --pidfile $DNSMASQ_PID_FILE \
                --verbose \
                --start -- \
                        --interface=$INTERFACE \
                        --listen-address=$INTERFACE_IP \
                        --except-interface=lo \
                        --bind-interfaces \
                        --pid-file=$DNSMASQ_PID_FILE \
                        --dhcp-range=$DHCP_MIN_IP,$DHCP_MAX_IP,$DHCP_MAX_LEASE_TIME \
                        --dhcp-option=1,$NETMASK \
                        --dhcp-option=3,$DHCP_GATEWAY \
                        --dhcp-option=6,$PRIMARY_DNS,$SECONDARY_DNS

        # Notify user bluetooth tethering is active
        print_message "Tethering from $INTERFACE to $EXTERNAL_INTERFACE activated"

elif [ "$1" == "stop" ]; then

        start-stop-daemon \
                --exec /usr/sbin/dnsmasq \
                --pidfile $DNSMASQ_PID_FILE \
                --verbose \
                --stop

        # Bring down the interface
        ifconfig $INTERFACE down 2> /dev/null

        # Disable IP forwarding for tethered interface
        if [ -f "/proc/sys/net/ipv4/conf/$INTERFACE/forwarding" ]; then
                echo 0 > /proc/sys/net/ipv4/conf/$INTERFACE/forwarding 2> /dev/null
        fi

        # Notify user bluetooth tethering is inactive
        print_message "Tethering from $INTERFACE to $EXTERNAL_INTERFACE deactivated"

        # Disable external interface IP forwarding if appropriate
        DNSMASQ_CHECK="$(ps -eaf | grep 'dnsmasq' | grep -v -e '127\.0\.0\.1' -e 'grep')"
        if [ -z "$DNSMASQ_CHECK" ]; then
                echo "$(date) No more clients tethered--disabling all forwarding"
                echo 0 > /proc/sys/net/ipv4/conf/$EXTERNAL_INTERFACE/forwarding
                echo 0 > /proc/sys/net/ipv4/ip_forward
        fi

else

        echo "unknown argument: $1"
        echo "usage: $0 start|stop [internal_interface]"
        exit 1

fi


verrnum 2011-07-10 22:14

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Hi,

I am very interested by N900 bluetooth-PAN not for internet connection shared.

I just want a remote connection connection via SSH on N900 using BT.

I installed the needed package and i successfully pairing the N900 (Windows Seven - ad hoc network).

Now i am just looking for the N900 ip address to connect on with putty.

Is someone can help me ?

Best Regards

verrnum 2011-07-10 22:18

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
And another quqestion :

"Setup IP network for server (N900)" ??

How ?

Best Regards

jschan 2011-07-10 22:22

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by verrnum (Post 1048513)
Hi,

I am very interested by N900 bluetooth-PAN not for internet connection shared.

I just want a remote connection connection via SSH on N900 using BT.

I installed the needed package and i successfully pairing the N900 (Windows Seven - ad hoc network).

Now i am just looking for the N900 ip address to connect on with putty.

Is someone can help me ?

Best Regards

Yeah, that should work fine too. Just open up an xterm and run ifconfig as root.

verrnum 2011-07-10 22:31

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by jschan (Post 1048522)
Yeah, that should work fine too. Just open up an xterm and run ifconfig as root.

Hi,

Thanks for response.

I don't see the BT ip address :

bnep0 Link encap:Ethernet HWaddr
inet6 addr: fe80::ee9b:5bff:fe58:d8ac/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:207 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:57851 (56.4 KiB) TX bytes:172 (172.0 B)


Any ideas ?

I have an ip address for my PC :

Ethernet adapter Bluetooth Network Connection:

Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::c92e:cbc6:80a9:20ec%15
Autoconfiguration IPv4 Address. . : 169.254.32.236
Subnet Mask . . . . . . . . . . . : 255.255.0.0
Default Gateway . . . . . . . . . :

Thanks for help

verrnum 2011-07-10 22:45

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by jschan (Post 1048522)
Yeah, that should work fine too. Just open up an xterm and run ifconfig as root.

I forgot the ip value when i up the bnet0 interface !!

It works thanks a lot !

khuong 2011-08-01 19:28

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Hi, thank you all for your contribution to this helpful thread. I finally got my new gtab 10.1 connected to my n900 and able to use its internet connection. It's a little tricky at first but once I understood the whole process it seems simple enough.

The only tricky part is when to press the "use for Internet connection" under Bluetooth setting [ Profiles ] in my GTab,

It need to be pressed before the script is activated, and then there's only like 1 or maybe 2 sec window to activate the script on n900 before it times out. If successful, the big bluetooth icon on the lower right coner of my GTab task bar should popup in bright blue color, otherwise, the whole process has to be done again.

I will create a small program in QT to simplify the whole process.

Here's what i have in mind for the program.

1. Click Program Icon to initiate the connection:
  • Program will turn on the bluetooth if it's not on and then connect to dbus to listen to device connection signal from GTab.
2. User click "user Internet connection" on GTab:
  • Program will run "tether.sh start", and continue to monitor the dbus signal for disconnection then run "tether.sh stop" and maybe turn bluetooth off as well then quit itself until user click on the icon again.

What do you guys think, simple enough?

Hell, Maybe I just write the whole thing without using tether.sh script.:) or maybe not because some command has be run as root. :mad:

jschan 2011-08-02 02:35

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
There's already dbus support and with the blue switch widget, I think we already have support for what you are proposing. I'm sure I'm misunderstanding in some way though...

alphalux 2011-08-02 05:04

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
This is fantastic, and eliminated the need for me to use the wifi hotspot method. It did seem that I had to pair the device AFTER I ran the script the first time for the device to recognize the PAN profile. Thanks a thousand, 9000.

9000 2011-08-02 10:37

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by alphalux (Post 1062633)
This is fantastic, and eliminated the need for me to use the wifi hotspot method. It did seem that I had to pair the device AFTER I ran the script the first time for the device to recognize the PAN profile. Thanks a thousand, 9000.

NP. That is interesting. What device are you pairing with N900?

ToniA 2011-08-03 06:16

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
If you are wondering why your Xoom only tethers once... There's a bug in the latest system upgrade (Android 3.2), now it requires a reboot before you can tether again.


All times are GMT. The time now is 09:43.

vBulletin® Version 3.8.8