Bluetooth & D-Bus, January 08
Posted: Mon 31 Dec 2007, 11:04
Note: The bluetooth libraries and utilities in this thread are compatible only with Puppy 3.x and 4.x.
For Puppy 2.x you must use the older ver 2.10 bluetooth libraries contributed by forum member debernardis here -
http://www.debernardis.it/dotpups/experimental_BT_1.pup
D-Bus is not required with these older libraries.
Recent versions of the bluetooth libraries need to bind to the D-Bus subsystem, and this has been problematic.
Forum member giac_fab mentioned that bluetooth works well under XFCE4.4.1, and with this clue I think I have worked out the problem.
D-Bus can be run using two different utilities; dbus-launch and dbus-daemon. I can now say that dbus-launch is no use for bluetooth, because it does not create the necessary PID file and socket file. You must use dbus-daemon to start D-Bus.
So here is how to get the bluetooth/dbus system running:
NOTE: Use the DBus/Bluetooth dotpets from this forum thread. These have been carefully configured with the correct configuration locations.
Other DBus/Bluetooth packages may not work.
First we need to get D-Bus running.
Load all necessary bluetooth kernel modules -
EDIT July 2010
In more recent kernels since Puppy 4.3, the hci-usb module has been replaced by the btusb module. Thus replace the last command with -
Now we need to run the Bluetooth Host Controller Interface daemon (hcid). But this process will fork to run in the background, which means that any errors will not be noticed. So it's a good idea to first do this
You should see something like this -
Now you know it looks OK, you can terminate the daemon with Ctrl>c, and hcid can be run without the -n switch.
Now start hcid, as well as the Bluetooth Service Discovery Protocol daemon (sdpd). Run these 2 commands -
Bluetooth (and D-Bus) should now be up and running.
Forum member tantor reports that this command is necessary
but I found that OBEX file transfer works fine without it.
Now let's fix the configuration file. Open /etc/bluetooth/hcid.conf in geany.
Change "security auto" to "security user"
You will see that the default passkey is "BlueZ". Since this passkey will need to be entered into your mobile device, it's easier if the passkey is numeric, and I prefer to avoid "1234" since many mobile devices use this as a default value. I'm more confident that a connection is successful if it is made with a non-default value. So let's use "2345" for the following examples. Change "passkey "BlueZ";" to "passkey "2345";"
Now there's just one more thing to prepare: the passkey verification daemon. Run this command -
Once a bluetooth connection is successfully established for the first time, your mobile device registers the properties of the Puppy bluetooth connection with your Puppy computer, and passkey-agent is not needed for all subsequent connections.
Put your bluetooth device (mobile phone, PDA, etc) into "discoverable" bluetooth mode, then run this command to find its bluetooth MAC address -
The result for my Motorola K1 is "00:17:E3:4B:68:A3"
Now query the capabilities of your device with -
Take note of the channel number which corresponds to the bluetooth service you want to use.
The 3 bluetooth services most likely to be useful are:
1) "Dial-up Networking Gateway"
(my Motorola's channel is 1)
This is for GPRS/EDGE connections to a mobile phone. See the HOWTO's by forum members daemon and debernardis here -
http://www.murga-linux.com/puppy/viewto ... 8286#88286
http://puppylinux.org/wikka/ExperimentalBT
Quick summary: Puppy is missing the necessary /dev/rfcomm0 device node, so create it -
Now pair the computer to phone, specifying the correct channel for Dial-up Networking Gateway (channel 1 for me) -
Now you need a GPRS chatscript to connect via /dev/rfcomm0
2) "SyncML Data Synchronisation" (or similar)
(my Motorola's channel is 12)
This is for calendar/organiser/addressbook exchange. See "HowTo sychronise J-Pilot with a Palm device via bluetooth" -
http://www.murga-linux.com/puppy/viewto ... 442#173442
It's also possible, in theory, to synchronise to PocketPC/WindowsMobile devices, but I think that some extra libraries are required. John Doe knows more about PocketPC -
http://www.murga-linux.com/puppy/viewtopic.php?t=17440
3) "OBEX file transfer"
(my Motorola's channel is 9)
This is to copy files from/to your Puppy computer, initiated from Puppy. Quick HOWTO: run this command -
It's also possible to specify the correct channel with the "-B" parameter (channel 9 in my case) but obexftp is smart enough to use the correct channel anyway.
Your phone will prompt you to enter the passkey we created earlier (2345), then the phone will ask you to accept "OBEX file transfer, Requested by: BlueZ (0)".
Puppy will then display a list of directories available on your phone in XML format. Let's say one of those directories is "audio". So to list files in this directory, do this -
Let's say you see a file called "mymusic.mp3". To get (or "fetch") this file, use the "-g" parameter, like this -
Or to send ("put") a file to the phone, use the "-p" parameter.
If the file transfer is initiated from the phone, the process is different ... maybe I will test this some other time.
It may be possible to mount the phone as a filesystem using the obexfs dotpet package from later in this thread, but this will only work with certain phones. Install Obexfs-0.8.pet, then do this -
If it works, you will now be able to browse files in the phone using ROX, or any other file manager.
For Puppy 2.x you must use the older ver 2.10 bluetooth libraries contributed by forum member debernardis here -
http://www.debernardis.it/dotpups/experimental_BT_1.pup
D-Bus is not required with these older libraries.
Recent versions of the bluetooth libraries need to bind to the D-Bus subsystem, and this has been problematic.
Forum member giac_fab mentioned that bluetooth works well under XFCE4.4.1, and with this clue I think I have worked out the problem.
D-Bus can be run using two different utilities; dbus-launch and dbus-daemon. I can now say that dbus-launch is no use for bluetooth, because it does not create the necessary PID file and socket file. You must use dbus-daemon to start D-Bus.
So here is how to get the bluetooth/dbus system running:
NOTE: Use the DBus/Bluetooth dotpets from this forum thread. These have been carefully configured with the correct configuration locations.
Other DBus/Bluetooth packages may not work.
First we need to get D-Bus running.
Code: Select all
rm -f /var/run/dbus/*
dbus-uuidgen --ensure
dbus-daemon --system
Code: Select all
modprobe bluetooth
modprobe l2cap
modprobe rfcomm
modprobe hci-usb
In more recent kernels since Puppy 4.3, the hci-usb module has been replaced by the btusb module. Thus replace the last command with -
Code: Select all
modprobe btusb
Code: Select all
hcid -n
Code: Select all
# hcid -n
hcid[3005]: Bluetooth HCI daemon
hcid[3005]: Created local server at unix:abstract=/var/run/dbus-it4nWAKmag,guid=f7d18acc9c2cb6e3385394004772417e
Now start hcid, as well as the Bluetooth Service Discovery Protocol daemon (sdpd). Run these 2 commands -
Code: Select all
hcid
sdpd
Forum member tantor reports that this command is necessary
Code: Select all
hciconfig hci0 class 0x3e0100
Now let's fix the configuration file. Open /etc/bluetooth/hcid.conf in geany.
Change "security auto" to "security user"
You will see that the default passkey is "BlueZ". Since this passkey will need to be entered into your mobile device, it's easier if the passkey is numeric, and I prefer to avoid "1234" since many mobile devices use this as a default value. I'm more confident that a connection is successful if it is made with a non-default value. So let's use "2345" for the following examples. Change "passkey "BlueZ";" to "passkey "2345";"
Now there's just one more thing to prepare: the passkey verification daemon. Run this command -
Code: Select all
passkey-agent --default 2345 &
Put your bluetooth device (mobile phone, PDA, etc) into "discoverable" bluetooth mode, then run this command to find its bluetooth MAC address -
Code: Select all
hcitool scan
Now query the capabilities of your device with -
Code: Select all
sdptool browse 00:17:E3:4B:68:A3
The 3 bluetooth services most likely to be useful are:
1) "Dial-up Networking Gateway"
(my Motorola's channel is 1)
This is for GPRS/EDGE connections to a mobile phone. See the HOWTO's by forum members daemon and debernardis here -
http://www.murga-linux.com/puppy/viewto ... 8286#88286
http://puppylinux.org/wikka/ExperimentalBT
Quick summary: Puppy is missing the necessary /dev/rfcomm0 device node, so create it -
Code: Select all
mknod -m 666 /dev/rfcomm0 c 216 0
Code: Select all
rfcomm bind /dev/rfcomm0 00:17:E3:4B:68:A3 1
2) "SyncML Data Synchronisation" (or similar)
(my Motorola's channel is 12)
This is for calendar/organiser/addressbook exchange. See "HowTo sychronise J-Pilot with a Palm device via bluetooth" -
http://www.murga-linux.com/puppy/viewto ... 442#173442
It's also possible, in theory, to synchronise to PocketPC/WindowsMobile devices, but I think that some extra libraries are required. John Doe knows more about PocketPC -
http://www.murga-linux.com/puppy/viewtopic.php?t=17440
3) "OBEX file transfer"
(my Motorola's channel is 9)
This is to copy files from/to your Puppy computer, initiated from Puppy. Quick HOWTO: run this command -
Code: Select all
obexftp -b 00:17:E3:4B:68:A3 -l
Your phone will prompt you to enter the passkey we created earlier (2345), then the phone will ask you to accept "OBEX file transfer, Requested by: BlueZ (0)".
Puppy will then display a list of directories available on your phone in XML format. Let's say one of those directories is "audio". So to list files in this directory, do this -
Code: Select all
obexftp -b 00:17:E3:4B:68:A3 -l /audio
Code: Select all
obexftp -b 00:17:E3:4B:68:A3 -g /audio/mymusic.mp3
If the file transfer is initiated from the phone, the process is different ... maybe I will test this some other time.
It may be possible to mount the phone as a filesystem using the obexfs dotpet package from later in this thread, but this will only work with certain phones. Install Obexfs-0.8.pet, then do this -
Code: Select all
mkdir /mnt/bluetooth
obexfs -b 00:17:E3:4B:68:A3 -B 9 /mnt/bluetooth