Everything Motorola Q  
Home Motorola Q Store Moto Q Software News Moto Q Blog Motorola Q Reviews Moto Q Forums FAQs Wiki Contact Us Everything Q RSS feed


Go Back   Motorola Q Forum | Everything Q > Accessories > Bluetooth

Notices

Reply
 
Thread Tools Display Modes
Old 08-15-2007, 08:09 PM   #1 (permalink)
 
Join Date: Aug 2007
Posts: 80
Thanks: 3
Thanked 23 Times in 9 Posts
Bobby Budnick is on a distinguished road
Default Bluetooth PAN: an alternative to 802.11B/G

Intro:
This how-to is mostly one I made for myself but I'm sure it could be useful for other Q owners as well as other WM5 Standard device owners.

This is written specifically for Ubuntu GNU/Linux but it should work for Debian as well as other Debian-derived distros.

If you don't already have a linux box, head over to the Ubuntu website and download the .iso for x86. You can burn this image to a CD and boot this on your computer and be at the ubuntu desktop in 10 minutes without changing a thing.

Requirements:
A PC
USB bluetooth adapter
Q or other WM5 Standard device
Blank CD (if you intend to burn Ubuntu)

Notes:
pand should be using NAP (network access point) role. It does not seem to be working on the Q with MOL2.
Instead, GN (group ad-hoc network) role seems to work.

Instructions:
1.Install extra needed bluetooth utilities and DHCP server
sudo apt get install bluez-utils
sudo apt-get install dhcp3-server

2.Edit /etc/network/interfaces
sudo nano /etc/network/interfaces
#ADD THIS TO THE END OF THE FILE
iface bnep0 inet static
address 192.168.3.1
netmask 255.255.255.0

3.Edit /etc/dhcp3/dhcpd.conf
sudo nano /etc/dhcp3/dhcpd.conf

#EDIT THIS SECTION OF THE FILE
# option definitions common to all supported networks...
option domain-name "yourhostname.yourprovider.org";
option domain-name-servers 192.168.1.1;

#ADD THIS TO THE END OF THE FILE
subnet 192.168.3.0 netmask 255.255.255.0 { range 192.168.3.1 192.168.3.10; option domain-name-servers 192.168.1.1; option domain-name "yourhostname.yourprovider.org"; option routers 192.168.3.1; option broadcast-address 192.168.3.255; default-lease-time 600; max-lease-time 7200; }

4.Run pand
sudo pand --listen --role GN --master -n

5.Connect with phone
bluetooth manager > personal network

6.Restart network
sudo /etc/init.d/networking restart

7.Restart DHCP server
sudo /etc/init.d/dhcp3-server restart

8.Add iptables entries
sudo iptables -t nat -A POSTROUTING -s 192.168.3.0/24 -j MASQUERADE
sudo iptables -A FORWARD -i bnep0 -o eth0 -j ACCEPT
sudo iptables -A FORWARD -o bnep0 -i eth0 -j ACCEPT

Now connect with your app!
For example, Opera uses the PAN when set to "work" network

Useful scripts:
These scripts help to automate the process. Put these in your home folder. Start the PAN by simply running the first script. Be sure to make these executable.

#/bin/sh
#Use for starting the PAN
#Start this with root privileges
#Change path to your home folder
echo "Starting the PAN..."
echo 1 > /proc/sys/net/ipv4/ip_forward
pand --listen --role GN --master --devup /home/jason/panconnect
sleep 1

#!/bin/sh
#This script runs when the device is connected to the PAN
#Name this script panconnect
sleep 2
ifconfig bnep0 up
ifconfig bnep0 192.168.3.1 netmask 255.255.255.0
sleep 2
sudo iptables -t nat -A POSTROUTING -s 192.168.3.0/24 -j MASQUERADE
sudo iptables -A FORWARD -i bnep0 -o eth0 -j ACCEPT
sudo iptables -A FORWARD -o bnep0 -i eth0 -j ACCEPT
sleep 1
/etc/init.d/dhcp3-server restart
sleep 1

Misc:
HKLM/Comm/BTCEPAN1/Parms/TCPIP
PAN TCP/IP Parameters on device

If your paranoid like me, there is also an encryption option for pand. It does not seem to slow things down, but I don't know how secure it actually is. Just add '--encrypt' after '--master' to the pand line in the startpan script.

If your GNU/Linux distribution is set up strangely, you may need to pair with the device first. I urge you to upgrade to the latest available bluez to fix this. If you want to pair anyway, do it with this:
passkey-agent /usr/bin/bluez-pin MACADDRESSOFYOURDEVICE

References:
Some boring and half-working reads here.

http://fastcreators.com/article/2007...r-debian-etch/

http://bluez.sourceforge.net/contrib/HOWTO-PAN

Last edited by Bobby Budnick; 10-21-2007 at 08:16 PM.
Bobby Budnick is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Old 08-15-2007, 09:00 PM   #2 (permalink)
DrQ
 
DrQ's Avatar
 
Join Date: Jun 2007
Posts: 1,079
Thanks: 35
Thanked 129 Times in 114 Posts
DrQ is on a distinguished road
Default

Am I correct in my understanding that this connects the Q via Bluetooth to the PC and therefore the internet?

Is this a faster throughput than a Bluetooth activesync connection? Someone on another thread had been talking about using BT to connect to a computer across the room.

I sometimes use the USB activesync connection to test site or download on my Q, as I am in a 1X area at home and when the Q is connected it uses the computers connection rather than the radio.

The other night I decided to play with BT activesync and after I finally got it running and connected the Q used that laptop and it's WiFi connection to connect to the internet. Helped alot yesterday when I downloaded all my old saved mail into Profimail.

BTW your directions seem to be very clear and complete for what seems to be a complicated task. Not meaning to rain on your parade, but what is the advantage of this method?

Thanks for your post. People helping people.
__________________
Search and Read and you shall find.........Fred
DrQ is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-15-2007, 11:28 PM   #3 (permalink)
 
Join Date: Aug 2007
Posts: 80
Thanks: 3
Thanked 23 Times in 9 Posts
Bobby Budnick is on a distinguished road
Default

Thanks for your reply.

Yes this will establish TCP/IP over bluetooth. Technically pand allows for the host PC to be a bluetooth "wireless router" of sorts and connect up to I think 8 devices in this configuration.

I never figured out bluetooth with Windows, including Activesync.

I did previously know that it was possible to use Activesync and it's pseudo-networking abilities to access the web with WM bluetooth devices. But, I think this solution offers a few advantages. Foremost, it does not require the use of Windows so that is the biggest advantage to me. As mentioned before, it also has alot of scalability in supporting multiple devices and for instance, encryption. With that comes full NATed tcp and udp networking with the potential to for instance run an ftp server on the device. Finally, with a PAN we have access to computers running on the local network. It's nice to watch various console programs running on the servers and workstations over my bluetooth link on midpssh while i am sitting in my easy chair

Last edited by Bobby Budnick; 08-17-2007 at 08:48 PM.
Bobby Budnick is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-17-2007, 08:39 PM   #4 (permalink)
 
Join Date: Aug 2007
Posts: 80
Thanks: 3
Thanked 23 Times in 9 Posts
Bobby Budnick is on a distinguished road
Default Bluetooth USB adapter review

I have been searching for the fastest, most reliable USB adapter. In the end, my average speed has more than doubled to 450 kbps!!! I have bursts that are higher than that. It's not much slower than the EVDO now.

I did some benchmarks with www.dslreports.com/mspeed . My home connection is Time Warner Cable premium 10Mb.

Kensington K33348 - fast, 450 kbps average, activity indicator
IOGEAR GBU221WM - fast, 400 kbps average, low cost

IOGEAR GBU211 - slow, 192 kbps average, low cost
Targus ACB10U - is detected, but will not do PAN
Belkin F8T0121 - horrible, stay far away

It is also important to have an up to date GNU/Linux distribution with the latest bluez for speed and more importantly, reliability.

Last edited by Bobby Budnick; 10-21-2007 at 08:32 PM.
Bobby Budnick is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-18-2007, 08:20 AM   #5 (permalink)
 
Pony99CA's Avatar
 
Join Date: Dec 2006
Location: Hollister, CA
Posts: 1,567
Thanks: 11
Thanked 127 Times in 94 Posts
Pony99CA is on a distinguished road
Default Bluetooth Routers

Or, if you don't have a spare PC and want something simple, you can just buy a Bluetooth router. (Although that claim of "twice the distance of WiFi" is probably wrong; Class 1 Bluetooth should be 300 feet, just like WiFi.)

Steve
__________________
Silicon Valley Pocket PC
http://www.svpocketpc.com

If somebody helps you, boost their reputation. Click the Reputation button icon under their user name.
Pony99CA is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-22-2007, 11:10 PM   #6 (permalink)
 
Join Date: Aug 2007
Posts: 80
Thanks: 3
Thanked 23 Times in 9 Posts
Bobby Budnick is on a distinguished road
Default Second addendum: advanced device configuration and PAN administration

Edit: The admin has disabled [code] tags. Try to imagine them there...

The PAN has been working well for me since I started with it. A few weeks back I noticed that some programs that need internet access will only access it through the "Internet" connection in the connection manager. Some programs are hardcoded this way, and there is no way to change them, registry or otherwise. Most notably, IM+ and Agile messenger behave this way. This normally would not be a problem on the pocket PC because the connection manager will allow you to assign network adapters to connections. In WM5 standard, it seems that you can not assign the BTCEPAN1 device to the "Internet" connection in the connection manager. Fortunately, you can change an adapter's DestID in the registry to the DestID for the "Internet". In this case, we can change BTCEPAN1 from "Work" to "Internet". The bad news is this must be done every time the PAN connection is connected/disconnected, and every time it auto-reconnects. Fortunately, I have written a script to automate this.

The script utilizes Mortscript to scan the connection manager registry key for BTCEPAN1 in a neverending loop and write the DestID for "Internet" whenever the DestID is changed to "Work" by disconnecting/reconnecting or from the auto-reconnect feature. Mortscript is a scripting framework supporting Windows Mobile. It is free and is invaluable to me now that I've used it. It can be installed in cab form from the website at http://www.sto-helit.de/index.php?mo...n=view&menu=29 . The scripts it can execute are just text files with the extension .mscr . The scripts are very light-weight. They use almost no memory and very little CPU. This is good, because the script is designed to run all the time. The script also does not bother the EVDO connection at all.

//START SCRIPT
//pan_hack_loop.mscr

while ( 1 )

x = RegRead( "HKLM", "Comm\ConnMgr\Providers\{F792e23c-dc19-4668-9be4-f8688b4c18d6}\BTCEPAN1", "DestId" )

if ( x eq "{A1182988-0D73-439E-87AD-2A5B369F808B}" )

RegWriteString( "HKLM", "Comm\ConnMgr\Providers\{F792e23c-dc19-4668-9be4-f8688b4c18d6}\BTCEPAN1", "DestId", "{436EF144-B4FB-4863-A041-8F905A62C572}" )

SleepMessage (15, "Hacking...", "Test",1)

EndIf

Sleep 2000

EndWhile

//END SCRIPT

Copy/paste this into a text file on the Q with extension .mscr . To run the script, just choose it with the file manager. Now you can use ANY application that needs internet/network access over the PAN. Once it is running, be sure not to close down Mortscript.exe in the task manager. To start the script at boot-time, add a shortcut to the script in \windows\startup\ .

I also have some scripts, which are personalized a little, which will switch between bluetooth and EVDO for a connection. They work by disabling/disconnecting one connection and enabling the other. Let me know if someone is interested and I will post them.

To easily administer the PAN from the GNU/Linux access point, I have written a GUI administration tool with Zenity. I call it PAN_ADMIN. Zenity is a GTK+ dialog frontend to the BASH scripting language.

#!/bin/bash
#PAN_ADMIN

#Start this script with root priviledges

while true
do

Choice=$(zenity --list --height=325 --text "PAN Admin" --radiolist --column "Pick" --column "Options" TRUE "Start_PAND" FALSE "Stop_PAND" FALSE "Reset_hci0" FALSE "hci0_status" FALSE "bnep0_status" FALSE "Connected_clients" FALSE "Exit")

if [ “$Choice” == “Start_PAND” ]
then
zenity --warning --text "The next screen will show any pand instances."
ps aux | grep pand > processfile
cat processfile | zenity --text-info --width 530
zenity --question --text "Start PAND, are you sure?"
if [ "$?" = 0 ]
then
#Here is where you put the line to start pand
#Your config may be different depending on your device!
./startpan
fi

elif [ “$Choice” == “Stop_PAND” ]
then killall pand

elif [ “$Choice” == “Reset_hci0” ]
then hciconfig reset hci0

elif [ “$Choice” == “hci0_status” ]
then hciconfig | zenity --text-info --width 530

elif [ “$Choice” == “bnep0_status” ]
then ifconfig bnep0 | zenity --text-info --width 530

elif [ “$Choice” == “Connected_clients” ]
then pand -l | zenity --text-info --width 530

elif [ “$Choice” == “Exit” ]
then exit

fi

done

#END OF SCRIPT

Copy/paste this into a text file on the GNU/Linux access point with any extension. Then 'chmod +x nameofscript'. Then run with 'kdesu nameofscript' with KDE or 'gksudo nameofscript' with GNOME.

Last edited by Bobby Budnick; 10-21-2007 at 08:11 PM.
Bobby Budnick is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT -5. The time now is 07:31 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Integrated by BBpixel Team 2008 :: jvbPlugin R1015.37x.1