Bluetooth

From OESF

(Difference between revisions)
Jump to: navigation, search
m
m (Corrected bluetooth PAN applet link)

Line 90:

Line 90:

If you have a howto for using PAN with a Linux PC, then please let me know and I can either link it from here or put a copy of it up here (with credits of course).
If you have a howto for using PAN with a Linux PC, then please let me know and I can either link it from here or put a copy of it up here (with credits of course).
-
'''Note:''' You can also use the [http://www.oesf.org/howto/downloads/bluez Bluetooth PAN Applet] for creating PAN connections, which integrates nicely with the Network applet. With this you can create a connection in the same way as with a LAN connection in the Network application.
+
'''Note:''' You can also use the [http://www.elsix.org/index.php?w=project&p=bluetooth_plugins Bluetooth PAN Applet] for creating PAN connections, which integrates nicely with the Network applet. With this you can create a connection in the same way as with a LAN connection in the Network application.
==Suspending & Resuming with the BlueZ drivers==
==Suspending & Resuming with the BlueZ drivers==

Revision as of 02:12, 23 January 2005

This howto describes how to setup the BlueZ Bluetooth drivers on a Sharp 3.x ROM (or a ROM based on this), which has the 2.4.18 Linux Kernel.

Contents

Installing the drivers

Download and install the package below:

bluez-zaurus_2.3-2.4.18d_arm.ipk
(Or if you are using a pre-emptive patched kernel install: bluez-zaurus_2.3-2.4.18d-preempt_arm.ipk)

For the Socket Bluetooth CF Rev G Card (Look here for more details) and possibly other CSR UART based cards that use the BCSP protocol, install this package too:

bluez-csr-serial_0.1_arm.ipk
(NOTE: This replaces /etc/pcmcia/serial so you will lose any changes you have made to it and it is restored to the Sharp default if you uninstall this package)

If your Bluetooth CF card does not respond after resuming your Zaurus from a suspend, see the section "Suspending & Resuming with the BlueZ drivers" below for more packages to install to fix this problem.

The homepage for most of these packages is: http://downloads.zaurususergroup.com/community/66.180.235.230/projects/bluez

The rest of this howto assumes previous knowledge of working with bash/sh and editing text files from the terminal. The initial setup of the BlueZ services and discovering devices requires command line access. If you do not know any of this or do not even know what I am talking about, then I would suggest using the Affix Bluetooth drivers instead as they have a nice graphical utility for discovering devices and connecting to them. I simply like BlueZ because of the stability and how well it can be integrated with the Zaurus Network Applet.

BlueZ Introduction

Once the BlueZ driver package is installed, all the bluetooth services should be up and running and ready to use. There is no need to reboot. If your supported Bluetooth CF card was in the slot when the package was installed, the CF icon should have appeared on your Zaurus. Otherwise you can insert your Bluetooth CF card and the CF icon should then appear.

All the configuration files are under /etc/bluetooth. Any changes to hcid.conf, rfcomm.conf and possibly /etc/bluetooth/pin requires a restart of the drivers by running the following command as root:

/etc/rc.d/init.d/bluetooth restart

hcid.conf contains all of the general settings and should be fairly self explanatory. To get a basic connection running, nothing should need changing in this file.

/etc/bluetooth/pin contains the pin number that you enter in any other Bluetooth device that pairs with the Zaurus.

/etc/bluetooth/givepin contains the pin number that your Zaurus will automatically give to another Bluetooth device if pairing from the Zaurus. givepin is a script which must print out a string of the format "PIN:1234" where 1234 is the pin number, so you only change that part of the script to change to pin number.

rfcomm.conf defines which rfcomm device connects to what other Bluetooth device and on which channel as a COM serial link. When the package is installed, 32 rfcomm devices are created in /dev. These devices act as virtual serial devices and when opened, rfcomm.conf is used to determin which Bluetooth device to connect to and on which channel. This means that these devices can be used as normal serial devices without the need for any extra commands, so they can be used as the device that pppd opens. When these rfcomm devices are closed, the Bluetooth link is also automatically closed.

You can run the command hciconfig to verify that the drivers and CF card are working properly. If everything is OK, the settings on your CF card should be printed. If something is wrong, then nothing will be printed.

Setting up an internet connection to a Bluetooth enabled mobile phone

(All the command line steps must be done in order as the root user)

  • Open the Network application on your Zaurus
  • Add a 'Dialup - IrDA' connection and set it up as if you were creating an IR connection.

Note: If you use the Bluetooth Dialup Applet then you do not need the next 2 steps. Instead create a dialup connection with the Bluetooth entry in the Network application and set the rfcomm device to

/dev/rfcomm0
  • Look in all the files /home/zaurus/Applications/Network/modules/IRDA*.conf to find the connection you just created and note the value of the ID setting.
  • Open the file under /etc/ppp/peers that matches the ID setting with a text editor, such as vi and add the following line to the top of the file:
/dev/rfcomm0
  • Set your mobile phone to be discoverable.
  • Run the following command in the terminal:
sdptool browse

This will search for all discoverable Bluetooth devices

  • From the list of devices found, look for your mobile phone and note its MAC address and the channel number for the DUN/Serial profile.
  • Open the file /etc/bluetooth/rfcomm.conf with a text editor.
  • In the rfcomm0 block, change the device value to the MAC address of your phone, change the channel value to the channel of the DUN/Serial profile on your phone, and finally set the comment to something that describes the connection to your phone. Save it and close.
  • With a text editor, change the pin number in /etc/bluetooth/givepin to whatever will be entered on your mobile phone for pairing.
  • Restart Bluetooth on your Zaurus with the command in the terminal:
/etc/rc.d/init.d/bluetooth restart
  • Having setup a network connection, the Network applet icon should have appeared on your Zaurus.

Try tapping it and connecting the network connection. Your Zaurus should automatically try to pair with your mobile phone and once complete should try to initiate the network connection. NOTE: I had trouble with the automatic pairing on the first connection with my Nokia 6310i mobile phone. To pair my Zaurus with my phone I had to run the following command (replacing the MAC address with my real phone's address): dund -c 11:22:33:44:55 After that I could then initiate the network connection as normal.

Setting up a connection to a PC, using PPP

Almost the exact same procedure is used to connect to a PC as it to a mobile phone. The only real difference comes when editing the file under /etc/ppp/peers. Instead of just adding a rfcomm device to the top of the file, it should be replaced by one of the sample files installed by the package under /etc/ppp/peers.

The sample peers files may need tweaking for your setup. Also, note that they use different rfcomm devices. Which rfcomm device is used is not important, except that a rfcomm device may be used for only one Bluetooth device. rfcomm.conf can be setup to specify more than one rfcomm device. To do that it simply needs a block similar to the one for rfcomm0, but starting with rfcomm1 or rfcomm2 etc instead.

The sample peers file BT-WINXP should work with Windows 2000 and even possibly with Windows 98, but I have only tested it with Windows XP Home.

You will have to enable an incoming PPP connection on the PC for this to work.

In Windows you need to create an incoming network connection, which is done differently on each version of Windows. The basic procedure is as follows:

  • Add a new modem, do not scan for new hardware, but click the 'Have Disk' button and select 'Connection between two computers'
  • When selecting the COM port for the new modem, your Windows Bluetooth software should have created a virtual COM port for incoming DUN/Serial connections and this is what should be used for the new modem.
  • Create a new network connection that is an incomming connection and uses the 'Connection between two computers' and also ensure that a guest user can connect with it.

In Linux, if you are running the BlueZ drivers on the PC too, then the following commands should enable an incomming connection:

dund -s
sdptool add SP

These commands can be put in an init script if you want the connection to be always available. `

Setting up a connection to a PC, using the PAN profile

The PAN (Personal Area Network) profile is also working and can give you a full ethernet connection over Bluetooth. I do not use this since it cannot be integrated into the Network Applet, which is required by the Sharp email application, although it shouldn't be. It does have the advantage of Windows Internet Connection Sharing working with it however.

Jens Koenen has put together a howto for using PAN with a Windows PC: http://www.jens-koenen.de/zaurus_pan.html

If you have a howto for using PAN with a Linux PC, then please let me know and I can either link it from here or put a copy of it up here (with credits of course).

Note: You can also use the Bluetooth PAN Applet for creating PAN connections, which integrates nicely with the Network applet. With this you can create a connection in the same way as with a LAN connection in the Network application.

Suspending & Resuming with the BlueZ drivers

If your Bluetooth CF card appears to stop responding after a suspend and resume, then you need to eject the CF card and reinsert it. Or if your Zaurus freezes when you suspend, then you need to turn the CF card before suspending.

To have this done automatically, without having to physically reinsert the CF card or run any commands, install the following packages (Some custom ROMs may have the first two packages already installed, like the tkcROM):

susp-resume_0.9-3.1.ipk
sudo-0.1.ipk
susp-resume-bluez_0.9.1_arm.ipk

It will then automatically reset your Bluetooth CF card on every resume.

Securing Bluetooth

Here are some tips for securing your Zaurus with Bluetooth. (Bluetooth is restarted by running the command '/etc/rc.d/init.d/bluetooth restart' as root.)

  • You can turn on encryption by removing the # in front of 'encrypt enable;' in the file /etc/bluetooth/hcid.conf and restarting Bluetooth.
  • If you do not want your Zaurus to be discoverable, in the file /etc/bluetooth/hcid.conf, change 'iscan enable;' to 'iscan disable;' and restart Bluetooth.
  • If you do not want anyone to be able to connect to your Zaurus at all via Bluetooth (but still be able to connect from it) then in /etc/bluetooth/hcid.conf change 'pscan enable;' to 'pscan disable;' and restart Bluetooth.
Personal tools