View source for Manually using Bluetooth

From Openmoko

Jump to: navigation, search

You do not have permission to edit this page, for the following reasons:

  • The action you have requested is limited to users in the group: Administrators.
  • You must confirm your email address before editing pages. Please set and validate your email address through your user preferences.

You can view and copy the source of this page:

Return to Manually using Bluetooth.

Personal tools
In progress: This article or section documents one or more features whose implementation are in progress.

Bluetooth is one of the core functions of the Neo1973, however it is basically unimplemented on the software side at the moment. Hardware problems in the P1 phone mean that the CPU has to be active in order to wake on external bluetooth events, which will reduce the battery life to some 2 days at best in standby.

This page details how to use bluetooth from the command line. We have quite a lot of plans about what exactly Bluetooth should be used for.

Power it up

Bluetooth may not be powered up.

Power up the adapter:

root@fic-gta01:~$ echo "1" > /sys/bus/platform/devices/gta01-pm-bt.0/power_on

If that doesn't do it, power up and reset the adapter one after the other:

root@fic-gta01:~$ echo "1" > /sys/bus/platform/devices/gta01-pm-bt.0/power_on ; 
echo "1" > /sys/bus/platform/devices/gta01-pm-bt.0/reset ;
echo "0" > /sys/bus/platform/devices/gta01-pm-bt.0/reset

hciconfig should print information about the adapter if it powered up properly:


(If you have an older rootfs, you may need to modprobe gta01-pm-bt or even hci_usb but these are built in/loaded automatically currently.) The devices should show as UP. If not you can use

hciconfig <device> up

Bluetooth Functions

Configuring Bluetooth on OpenMoko 2007.2 (August 27 snapshot with kernel

in file /etc/bluetooth/hcid.conf you should change the passkey from BlueZ to something numeric. For testing you may use "0000". Also, you can set the name to "Neo (%d)".

Scanning for bluetooth devices

hcitool scan

This will list the addresses of any discoverable bluetooth devices in the vicinity

passkey agent example

There should be a passkey agent built into openmoko, but for now you can start up the example passkey agent and set the pin code there. This will allow for new pairings to be made when you attempt a connection.

passkey-agent --default 0000 &

Note: the passkey-agent is not required in OpenMoko 2007.2 with kernel as of at least since August 27 (maybe earlier).

HID (Human Input Device)

Being able to use HID devices

We want to be able to use a bluetooth keyboard to type into the various applications of our Neo1973. To use a Bluetooth Keyboard type: (11:22:33:44:55:66 is the Address of your BT-Keyboard)

hidd --connect 11:22:33:44:55:66

and press "Connect" on your BT-KB

Tested on:

Acting as HID device

We want to be able to use the Neo1973 as a HID device, being able to use it as controller for presentations.


Here's how to connect to an external Bluetooth GPS and read NMEA data (Tested with a Holux GPSSlim236).

First, switch on the GPS and identify the BT address:

 hcitool scan

Then, edit /etc/bluetooth/rfcomm, which by default has all settings commented out, to something like this:

 rfcomm0 {
       # Automatically bind the device at startup
       bind no;
       # Bluetooth address of the device
       device 00:11:22:33:44:55;
       # RFCOMM channel for the connection (check your GPS docs for details)
       channel 1;
       # Description of the connection
       comment "Bluetooth GPS";

Restart the BT services:

 root@neo:~$ /etc/init.d/bluetooth stop
 root@neo:~$ /etc/init.d/bluetooth start

You should now be able to bind the GPS to /dev/rfcomm0, like this:

 root@neo:~$ rfcomm bind 0

Confirm the connect:

 root@neo:~$ rfcomm
 rfcomm0: 00:11:22:33:44:55 channel 1 clean 

... and watch the NMEA strings coming from your GPS:

 root@neo:~$ cat /dev/rfcomm0 

If you have nothing better to do, you can now pinpoint my office :-).



Bluetooth networking with a Linux system

Bluetooth should behave just like our usbnet and provide full TCP/IP access to the phone. BNEP has to be used.

On the laptop

  • Start bluetooth
elara /home/alphaone # /etc/init.d/bluetooth start
  • Start pand as server
elara /home/alphaone # pand -s
  • As soon as pand is started on the phone configure your IP address
elara /home/alphaone # ip a add dev bnep0
elara /home/alphaone # ip l set bnep0 up
  • Configure IP forwarding and masquerading to your liking (see USB_Networking)

On the Neo

  • Power on bluetooth (see above)
  • Scan for the laptop
root@fic-gta01:~$ hcitool scan
Scanning ...
        00:0E:6D:C0:0l:6A       Sho
        00:20:E0:5A:FE:C8       BlueZ (0)
  • Connect to the laptop pand
root@fic-gta01:~$ pand -c 00:20:E0:5A:FE:C8
  • Configure your IP address
ip a add dev bnep0
ip r add default via
  • Enjoy

Bluetooth networking with a Windows XP system

This was tested with a Windows XP SP2 on a IBM Thinkpad T41 with the Widcomm BT stack

  • start bluetooth on Windows XP
  • enable "Network Access" in the Bluetooth configuration
  • scan for the Neo and pair with the Neo (right click, select pair)

On the Neo

  • enable PAN support on the Neo by changing Autostart from false to true in /etc/bluetooth/network.service
  • Power on bluetooth (see above)
  • Scan for the laptop
root@fic-gta01:~$ hcitool scan
Scanning ...
        <laptop_bt_address>     Thinkpad

  • Connect to the laptop pand
pand -c <laptop_bt_address> -r PANU -d NAP -e bnep0 -A -E -S

(add '-n' to see the pand status messages until you get it right)

For some reason, I was not able to initiate PAN connections from the Neo, I got 'Permission denied (13)' even when I had explicitly allowed the Neo to connect (right click on Neo icon, set properties, on Authorization tab). But initiating 'PAN User' from Windows worked when executing on Neo:

pand -l -r PANU -d NAP -e bnep0 -A -E -S

(add '-n' to see the pand status messages until you get it right)

  • Configure your IP address. It should work like when connecting to Linux:
ip a add dev bnep0
ip r add default via

If this does not work, the IP stacks may have auto-assigned network addresses to themselves. You can look this up with 'ifconfig' on the Neo and with 'ipconfig' on Windows.

  • You should now be able to ssh/putty from Windows to your Neo. Enjoy!

By setting up the Windows Bluetooth connection properly, it should also be possible to share the Internet Connection of the Windows box with the Neo.

PPP Networking

If you are unable to use the 'BNEP' method described above, you may be able to use a dialup-networking emulation mode. On the Neo:

  • Edit the /etc/default/bluetooth file and set the following options:
DUND_OPTIONS="--listen --persist call dun"
  • Create an /etc/ppp/peers/dun file with options like the following:

  • Restart bluetooth (/etc/init.d/bluetooth stop ; /etc/init.d/bluetooth start)

To connect from a MacOS 10.3 client:

  • Open "Applications/Utilities/Bluetooth Serial Utility"
  • Click on "New"
  • Choose a name, then click "Choose Device"
  • Locate your Neo, then select the "LAN Access Point" service. If your device is not found, or if this service does not show up, then you will need to troubleshoot and fix that before continuing. Bluetooth is designed for short-range communication, so make sure that the devices are physically close to each other.
  • Select "Port type: RS-232" and "Show in Network Preferences". Click OK.
  • Open the Network Preferences page then "Show: Network Port Configurations". Enable the new device that you defined in the previous step and drag it to the bottom of the device list (so that it will not interfere with your other network connections)
  • Choose "Show: <your-device-name>", then click "Modem"
  • Select "Null Modem 115200" from the list of available devices. Uncheck "Wait for dial tone" and "Enable error correction and compression in modem". Optionally check "Show modem status in menu bar".
  • Click "Connect". If everything worked, you will end up with a 'ppp0' device on your Mac with a local address of and you will be able to access your Neo at


It's now possible (if a little hackish) to stream mp3 to a bluetooth headset.

Add a couple of ipkg repositories:

echo "src/gz python" >> /etc/ipkg/angstrom-python.conf 
echo "src/gz base" >> /etc/ipkg/angstrom-base.conf
ipkg update ; ipkg install python-dbus bluez-utils bluez-utils-alsa

Create /etc/asound.conf:

pcm.!default {
 type bluetooth
ctl.!default {
 type bluetooth
pcm.bluetooth {
 type bluetooth
ctl.bluetooth {
 type bluetooth

Run the passkey agent (see above in this page)

Fill in your bluetooth headset address below and execute the python script (with your headset on)

import dbus
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object('org.bluez', '/org/bluez'), 'org.bluez.Manager')
conn = manager.ActivateService('audio')
audio = dbus.Interface(bus.get_object(conn, '/org/bluez/audio'), '')
path = audio.CreateDevice('00:0D:3C:44:33:22')
sink = dbus.Interface(bus.get_object(conn, path), '')

FINALLY: play a song

madplay /media/card/song.mp3 --sample-rate=44100 --output=wave:- | aplay

Headset Audio

Bluez has an audio daemon for headset audio that should work to set up the control connection to the headset. It will need hooks in the openmoko gui.

Neo1973_Audio_Subsystem has more detail about what magic needs to happen with the Wolfson codec so system audio can be switched to use the bluetooth audio channel and later back to the speaker/earpiece/wired headset. There seems to be a proposal for audio scenario management there but no detail about whether that is how things are done currently. How should audio management work when eg plugging in/unplugging the wired headset?

If the codec audio management is worked out, then all we need are hooks to make the kind of dbus api calls that are in the python examples at (need to ipkg install python-dbus and python-xml). The play method *does* need to be called; it's automatic only when using an alsa plugin which is not how it works on neo.

Bluetooth networking with a Linux system - More secure way

Check this, probably needs some corrections

Bluetooth should behave just like our usbnet and provide full TCP/IP access to the phone. BNEP has to be used.

On the laptop

  • check these options in /etc/bluetooth/hcid.conf
security auto;
passkey "your pin";
lm master;
  • Start bluetooth
# /etc/init.d/bluetooth start
  • Start pand as server
 pand --listen --role NAP --encrypt
auto bnep0
iface bnep0 inet static
       post-up iptables -A POSTROUTING -t nat -j MASQUERADE -s
       post-up echo 1 > /proc/sys/net/ipv4/ip_forward
       post-up iptables -P FORWARD ACCEPT

On the Neo

  • Power on bluetooth (see above)
  • Scan for the laptop
root@fic-gta01:~$ hcitool scan
Scanning ...
        00:20:E0:5A:FE:C8       laptop
  • Set pin
root@fic-gta01:~$ passkey-agent 'your pin' 00:20:E0:5A:FE:C8 &
  • Connect to the laptop pand
root@fic-gta01:~$ pand -c 00:20:E0:5A:FE:C8
  • Configure your IP address
root@fic-gta01:~$ ifconfig bnep0
root@fic-gta01:~$ route add default gateway
  • Enjoy

Further reading