Difference between revisions of "Category:How to - bluetooth"

From Gumstix User Wiki
Jump to: navigation, search
m
(Networking: pan access point)
Line 8: Line 8:
  
 
== Networking: pan access point ==
 
== Networking: pan access point ==
 +
 +
ipkg install dhcp-server
 +
 +
/etc/dhcp/dhcpd.conf:
 +
 +
subnet 10.0.1.0 netmask 255.255.255.0 {
 +
  range 10.0.1.180 10.0.1.199;
 +
  option broadcast-address 10.0.1.255;
 +
  option routers 10.0.1.1;
 +
  option subnet-mask 255.255.255.0;
 +
}
 +
 +
/etc/network/interfaces:
 +
 +
allow-hotplug bnep0
 +
auto bnep0
 +
iface bnep0 inet static
 +
        address 10.0.1.1
 +
        netmask 255.255.255.0
 +
        network 10.0.1.0
 +
 +
/etc/default/bluetooth:
 +
 +
PAND_ENABLE=true
 +
PAND_OPTIONS="--listen --role NAP"
 +
 +
/etc/network/if-up.d/btap
 +
 +
#!/bin/sh
 +
iptables -A POSTROUTING -t nat -j MASQUERADE -s 10.0.1.0/24
 +
echo 1 > /proc/sys/net/ipv4/ip_forward
 +
iptables -P FORWARD ACCEPT   
 +
/etc/init.d/dhcp-server restart
 +
 +
You may need to re-run pand or re-run the post-up script.
  
 
== Networking: pan client ==  
 
== Networking: pan client ==  

Revision as of 19:09, 7 April 2008

Essentials

Install the basic bluetooth stuff with

ipkg install bluez-utils

First off, I had to move the "sleep 1" from after "sdptool add ..." to before the sdptool command. The startup script seemed to be failing to run to completion before I did that.

Networking: pan access point

ipkg install dhcp-server

/etc/dhcp/dhcpd.conf:

subnet 10.0.1.0 netmask 255.255.255.0 {
 range 10.0.1.180 10.0.1.199;
 option broadcast-address 10.0.1.255;
 option routers 10.0.1.1;
 option subnet-mask 255.255.255.0;
}

/etc/network/interfaces:

allow-hotplug bnep0
auto bnep0
iface bnep0 inet static
       address 10.0.1.1
       netmask 255.255.255.0
       network 10.0.1.0

/etc/default/bluetooth:

PAND_ENABLE=true
PAND_OPTIONS="--listen --role NAP"

/etc/network/if-up.d/btap

#!/bin/sh
iptables -A POSTROUTING -t nat -j MASQUERADE -s 10.0.1.0/24
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -P FORWARD ACCEPT     
/etc/init.d/dhcp-server restart

You may need to re-run pand or re-run the post-up script.

Networking: pan client

Dialup networking: server

Dialup networking: client

GPS repeater

Install gpsd and configure it for your gps connection.

In /etc/init.d/bluetooth, change

$RFCOMM_EXEC -r watch 0 1 /sbin/getty -w -L rfcomm0 115200 vt100 &

to

$RFCOMM_EXEC -r watch 0 1 sh -c "gpspipe -r >/dev/rfcomm0" &

Unfortunately, advertising your gps uses the same sdp record as advertising your bluetooth console, so this knocks out your console. You can bring it back on an unadvertised channel:

$RFCOMM_EXEC -r watch 1 2 /sbin/getty -w -L rfcomm1 115200 vt100 &

but then you'll have to be able to manually choose channel 2. That's not a problem from linux, but problematic for others.

Keyboard

Put your keyboard in pairing mode and run:

hidd --search

The keyboard should connect and on subsequent runs it will reconnect automatically if you boot up with this in /etc/default/bluetooth

HIDD_ENABLE=true
HIDD_OPTIONS="--master --server"

Voice audio

Currently the way to use voice over bluetooth requires a vx board and a USB bluetooth adapter with a CSR chip in it.

High-fidelity audio

You can use A2DP with either the internal bluetooth adapter (model 08 or newer) or any brand of USB adapter if you have a vx board.

Install the packages you'll need:

ipkg install bluez-utils bluez-utils-alsa alsa-utils-aplay madplay

Edit /etc/bluetooth/audio.service to enable autostart:

[Bluetooth Service]
Identifier=audio
Name=Audio service
Description=Bluetooth Audio service
Autostart=true

Reboot now if you had to change this.

You'll likely need the passkey agent running, at least the first time you connect. A few itech headsets need "8888" but most need "0000" for the pin:

passkey-agent --default 0000 &

put your headset in pairing mode. Usually this means starting from off and holding the power button down until it flashes. Then find the headset's address:

hcitool scan

edit your /etc/asound.conf with an adapter for bluetooth with the address you just found. My headset is made by itech, so I name the adapter after it:

pcm.itech {
 type bluetooth
 device "00:0D:3C:8A:13:06"
}

now try playing something to it:

madplay song.mp3 -r 44100 --output=wave:- | aplay -D itech

you can also live-encode the line in source to a2dp:

arecord -c 2 -f s16 -r 44100 | aplay -D itech

unfortunately for live encoding, the delay is pretty bad and for some reason I can never get stereo audio from the line-in source.

Debugging connection problems

The best way to figure out what is happening is to use hcidump.

ipkg install bluez-hcidump

In a separate window, or in the background, start the dump:

hcidump -XV

And then in another window, try out your bluetooth command that isn't working. hcidump output is very verbose, but you'll probably be able to zero in on the issue by studying it a little.

This category currently contains no pages or media.