Manually using Bluetooth

From Openmoko

Revision as of 20:52, 5 September 2008 by Nytowl (Talk | contribs)

Jump to: navigation, search
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.

Contents

Power it up

Power up the adapter by clicking on the bluetooth icon in the top bar and selecting power on.

The old way to do it is a shell command (for kernels before 2.6.24):

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

For kernel 2.6.24 (or later) use

root@om-gta02:~# echo 1 > /sys/bus/platform/devices/neo1973-pm-bt.0/power_on

and on the GTA02 *only* (i.e. not on the GTA01) also use

root@om-gta02:~# echo 0 > /sys/bus/platform/devices/neo1973-pm-bt.0/reset


At the shell, "hciconfig" should print information about the adapter if it powered up properly:

hciconfig

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 2.6.21.6-moko11)

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 2.6.21.6 as of at least since August 27 (maybe earlier).

HID (Human Input Device)

Being able to use HID devices

Using a bluetooth keyboard with the built-in terminal is a little funky... I can only type into the console using the bt keyboard if the onscreen keyboard is visible. Also, pressing "p" twice on the bt keyboard actually gives you a "q".

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. Alternately, if you know that only one BT-Keyboard is within range, you can just:

hidd --search

to find and connect to any BT-Keyboard.

Tested on:

  • Logitech Dinovo Edge
  • Logitech Dinovo Media Desktop (keyboard)
  • Nokia SU-8W. Switched on the BT keyboard, scanned for BT address and ran the connect statement above. Works fine.
  • Chordite. This keyboard uses the Broadcom BCM2042 BT keyboard controller along with a custom driver.
  • Apple's Aluminum Keyboard. You may have to add 'auth enable; encrypt enable;' to device {} in hcid.conf. Run the passkey agent the first time. --search works to pair and every time after. (Might be obvious for those who have used BT in other spots, but you have to type in y our passkey on the keyboard as the connect is happening, otherwise pairing doesn't take place. I don't think there is a prompt on the Neo for this)
  • Apple's white "Wireless Keyboard (original)" - details may be the same as above. (tested some time ago)
  • FrogPad - as above
  • The freedom keyboard and its many rebranded models (they look like this: [1]) need 'modprobe uinput' to circumvent the 'Can't open input device: No such file or directory (2)' error of 'hidd --search'. It works as of february 7th 2008.
  • Logitech Playstation 3 Keyboard Works well, Mouse pad works.
  • iGo Stowaway UltraSlim (which was apparently discontinued early 2008, but can still be bought in some places) (user:ChristW I have 2008.8 on it, and using hidd --search to connect to the iGo works perfectly. I also used it to edit a new contact, dial a number and edit a settings text box in TangoGPS. So far, no problems...)
  • I-Tech Virtual Laser Keyboard works. Cursor keys not recognized as such, but produce keycodes than can be mapped.

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. See Software_Bluetooth_HID_Keyboard

RFCOMM

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

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

 hcitool scan

Then, edit /etc/bluetooth/rfcomm.conf, 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 
 $GPGGA,111748.000,5907.6964,N,01121.1787,E,1,06,1.2,57.7,M,40.1,M,,0000*6F
 $GPRMC,111748.000,A,5907.6964,N,01121.1787,E,0.00,94.94,160807,,,A*50
 $GPVTG,94.94,T,,M,0.00,N,0.0,K,A*3D

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

OBEX

Networking

Using PC's connection from Neo

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
/etc/init.d/bluetooth start
  • Start pand as server
pand -s
  • As soon as pand is started on the phone configure your IP address
ip a add 10.0.0.1/24 dev bnep0
ip l set bnep0 up
  • Configure IP forwarding and masquerading to your liking (see USB_Networking). You can even set up Udev rules to do this for you once the bnep0 interface appears.


On the Neo

  • There is a little script that does the steps below (and retries the pand -c command; I had issues with it not working the first time every time) at Bt-net-script You shouldn't need the other steps below if you use the script.
  • 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 10.0.0.2/24 dev bnep0
ip r add default via 10.0.0.1
  • Sometimes you may need to bring up the bnep0 on the phone as well:
ip l set bnep0 up
  • Enjoy
Bluetooth networking with a MacOS X system

Please refer to MacOS_X#Bluetooth_2

For using the Neo as a dialup Bluetooth server and the Mac as the client, please see below at Manually_using_Bluetooth#PPP_Networking

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 10.0.0.2/24 dev bnep0
ip r add default via 10.0.0.1

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 PPP and a DUN (dialup-networking) emulation mode. On the Neo:

  • Edit the /etc/default/bluetooth file and set the following options:
RFCOMM_ENABLE=true
DUND_ENABLE=true
DUND_OPTIONS="--listen --persist call dun"
  • Create an /etc/ppp/peers/dun file with options like the following:
115200
192.168.2.202:192.168.2.200
passive
local
noipdefault
noauth
nodefaultroute

  • 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 192.168.2.200 and you will be able to access your Neo at 192.168.2.202.
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
address 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
       post-up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.1.0/24
       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 192.168.1.2
root@fic-gta01:~$ route add default gateway 192.168.1.1
  • Enjoy

Using Neo's connection from PC

This section not written yet. Has someone set it up?

Calling Neo's GPRS modem via Bluetooth

In this mode, Neo would behave like any other phone which can be used from a PC to get a network connection.

Sharing existing Neo's connection

In this mode, Neo would already have a network connection (GPRS, WLAN, ...), and it should get shared to the PC.

A2DP quickie

  • If you experience problems with choppyness, try changing your hcid.conf to include "lm accept,master;" and "lp hold,sniff,park;" You may also have to bond (commonly known as 'pairing') your phone and your headset. See http://wiki.bluez.org/wiki/HOWTO/Bonding for details. Mercury 17:36, 5 September 2008 (UTC)

It's now possible (if a little hackish) to stream mp3 to a bluetooth headset. It's a known problem that the playback rate changes (pitch varies). Timing issues are also likely the reason for gaps in playback.

If the bluez packages are recent enough, you can use a shortcut. I'll document it here and leave the longer version below (the long version also demonstrates the API used by the GUI to manage headsets)

Create /etc/asound.conf with your bluetooth headset's address filled in:

pcm.!default {
 type bluetooth
 device "xx:xx:xx:xx:xx:xx"
}

then play a song

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

or for smoother results...

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

A2DP

If that doesn't work... all the more hackish... install required packages:

echo "src/gz python http://www.angstrom-distribution.org/unstable/feed/armv4t/python/" >> /etc/ipkg/angstrom-python.conf 
echo "src/gz base http://www.angstrom-distribution.org/unstable/feed/armv4t/base/" >> /etc/ipkg/angstrom-base.conf
ipkg update ; ipkg install python-core python-xml 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 turned on)

#!/usr/bin/python
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'), 'org.bluez.audio.Manager')
path = audio.CreateDevice('00:0D:3C:44:33:22')
audio.ChangeDefaultDevice(path)
sink = dbus.Interface(bus.get_object(conn, path), 'org.bluez.audio.Sink')
sink.Connect()

FINALLY: play a song

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

Headset Audio

Neo1973_Audio_Subsystem has detail about alsa settings and a proposal for audio scenario management.

To try this out, follow the instructions in the a2dp section to install software and run the passkey agent.

Remove or disable the stuff you put in asound.conf. When using a voice headset, the application uses the regular system audio device and it gets routed to bluetooth in the codec.

Put the headset in pairing mode. Replace the bluetooth address below with your headset's and run the python script:

#!/usr/bin/python
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'), 'org.bluez.audio.Manager')
path = audio.CreateHeadset('00:0B:2E:39:33:22')
audio.ChangeDefaultHeadset(path)
headset = dbus.Interface (bus.get_object(conn, path), 'org.bluez.audio.Headset')
headset.Connect()
headset.Play()

Now place a call and try to route it to bluetooth (after it's in progress):

alsactl -f /etc/gsmbluetooth.state restore

You may also be able to listen to system audio given the right state file:

alsactl -f /etc/systembluetooth.state restore
madplay song.mp3

Bluetooth on Freerunner

NOTE: work in progress


This thread suggests the following:

Turn on bluetooth
Pair your headset according to these instructions.
Create the following python script to set up the audio service and set the headset as the default device:
http://handheldshell.com/BtHeadset.py
http://handheldshell.com/BtHeadsetDisconnect.py
This is the compiled the binary from the wiki page http://wiki.openmoko.org/wiki/Neo1973_audio_subsystem
http://handheldshell.com/bluetooth_pcm
Get the [alsa state file]
BtHeadset.py <headset mac address> & 
Now start the call and then run
alsactl restore 0 -f gsm_headset.txt
bluetooth_pcm
End the call
 BtHeadsetDisconnect.py <headset mac address> & 

You should now hear the call in your headset. I have not tried to see if the mic is working yet. This was all done with the 2008-updates image from sept 4.

Further reading

http://www.holtmann.org/papers/bluetooth/ols2006_slides.pdf http://wiki.bluez.org/wiki/Audio#org.bluez.Audio

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

Power up the adapter by clicking on the bluetooth icon in the top bar and selecting power on.

The old way to do it is a shell command (for kernels before 2.6.24):

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

For kernel 2.6.24 (or later) use

root@om-gta02:~# echo 1 > /sys/bus/platform/devices/neo1973-pm-bt.0/power_on

and on the GTA02 *only* (i.e. not on the GTA01) also use

root@om-gta02:~# echo 0 > /sys/bus/platform/devices/neo1973-pm-bt.0/reset


At the shell, "hciconfig" should print information about the adapter if it powered up properly:

hciconfig

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 2.6.21.6-moko11)

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 2.6.21.6 as of at least since August 27 (maybe earlier).

HID (Human Input Device)

Being able to use HID devices

Using a bluetooth keyboard with the built-in terminal is a little funky... I can only type into the console using the bt keyboard if the onscreen keyboard is visible. Also, pressing "p" twice on the bt keyboard actually gives you a "q".

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. Alternately, if you know that only one BT-Keyboard is within range, you can just:

hidd --search

to find and connect to any BT-Keyboard.

Tested on:

  • Logitech Dinovo Edge
  • Logitech Dinovo Media Desktop (keyboard)
  • Nokia SU-8W. Switched on the BT keyboard, scanned for BT address and ran the connect statement above. Works fine.
  • Chordite. This keyboard uses the Broadcom BCM2042 BT keyboard controller along with a custom driver.
  • Apple's Aluminum Keyboard. You may have to add 'auth enable; encrypt enable;' to device {} in hcid.conf. Run the passkey agent the first time. --search works to pair and every time after. (Might be obvious for those who have used BT in other spots, but you have to type in y our passkey on the keyboard as the connect is happening, otherwise pairing doesn't take place. I don't think there is a prompt on the Neo for this)
  • Apple's white "Wireless Keyboard (original)" - details may be the same as above. (tested some time ago)
  • FrogPad - as above
  • The freedom keyboard and its many rebranded models (they look like this: [1]) need 'modprobe uinput' to circumvent the 'Can't open input device: No such file or directory (2)' error of 'hidd --search'. It works as of february 7th 2008.
  • Logitech Playstation 3 Keyboard Works well, Mouse pad works.
  • iGo Stowaway UltraSlim (which was apparently discontinued early 2008, but can still be bought in some places) (user:ChristW I have 2008.8 on it, and using hidd --search to connect to the iGo works perfectly. I also used it to edit a new contact, dial a number and edit a settings text box in TangoGPS. So far, no problems...)
  • I-Tech Virtual Laser Keyboard works. Cursor keys not recognized as such, but produce keycodes than can be mapped.

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. See Software_Bluetooth_HID_Keyboard

RFCOMM

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

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

 hcitool scan

Then, edit /etc/bluetooth/rfcomm.conf, 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 
 $GPGGA,111748.000,5907.6964,N,01121.1787,E,1,06,1.2,57.7,M,40.1,M,,0000*6F
 $GPRMC,111748.000,A,5907.6964,N,01121.1787,E,0.00,94.94,160807,,,A*50
 $GPVTG,94.94,T,,M,0.00,N,0.0,K,A*3D

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

OBEX

Networking

Using PC's connection from Neo

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
/etc/init.d/bluetooth start
  • Start pand as server
pand -s
  • As soon as pand is started on the phone configure your IP address
ip a add 10.0.0.1/24 dev bnep0
ip l set bnep0 up
  • Configure IP forwarding and masquerading to your liking (see USB_Networking). You can even set up Udev rules to do this for you once the bnep0 interface appears.


On the Neo

  • There is a little script that does the steps below (and retries the pand -c command; I had issues with it not working the first time every time) at Bt-net-script You shouldn't need the other steps below if you use the script.
  • 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 10.0.0.2/24 dev bnep0
ip r add default via 10.0.0.1
  • Sometimes you may need to bring up the bnep0 on the phone as well:
ip l set bnep0 up
  • Enjoy
Bluetooth networking with a MacOS X system

Please refer to MacOS_X#Bluetooth_2

For using the Neo as a dialup Bluetooth server and the Mac as the client, please see below at Manually_using_Bluetooth#PPP_Networking

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 10.0.0.2/24 dev bnep0
ip r add default via 10.0.0.1

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 PPP and a DUN (dialup-networking) emulation mode. On the Neo:

  • Edit the /etc/default/bluetooth file and set the following options:
RFCOMM_ENABLE=true
DUND_ENABLE=true
DUND_OPTIONS="--listen --persist call dun"
  • Create an /etc/ppp/peers/dun file with options like the following:
115200
192.168.2.202:192.168.2.200
passive
local
noipdefault
noauth
nodefaultroute

  • 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 192.168.2.200 and you will be able to access your Neo at 192.168.2.202.
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
address 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
       post-up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.1.0/24
       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 192.168.1.2
root@fic-gta01:~$ route add default gateway 192.168.1.1
  • Enjoy

Using Neo's connection from PC

This section not written yet. Has someone set it up?

Calling Neo's GPRS modem via Bluetooth

In this mode, Neo would behave like any other phone which can be used from a PC to get a network connection.

Sharing existing Neo's connection

In this mode, Neo would already have a network connection (GPRS, WLAN, ...), and it should get shared to the PC.

A2DP quickie

  • If you experience problems with choppyness, try changing your hcid.conf to include "lm accept,master;" and "lp hold,sniff,park;" You may also have to bond (commonly known as 'pairing') your phone and your headset. See http://wiki.bluez.org/wiki/HOWTO/Bonding for details. Mercury 17:36, 5 September 2008 (UTC)

It's now possible (if a little hackish) to stream mp3 to a bluetooth headset. It's a known problem that the playback rate changes (pitch varies). Timing issues are also likely the reason for gaps in playback.

If the bluez packages are recent enough, you can use a shortcut. I'll document it here and leave the longer version below (the long version also demonstrates the API used by the GUI to manage headsets)

Create /etc/asound.conf with your bluetooth headset's address filled in:

pcm.!default {
 type bluetooth
 device "xx:xx:xx:xx:xx:xx"
}

then play a song

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

or for smoother results...

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

A2DP

If that doesn't work... all the more hackish... install required packages:

echo "src/gz python http://www.angstrom-distribution.org/unstable/feed/armv4t/python/" >> /etc/ipkg/angstrom-python.conf 
echo "src/gz base http://www.angstrom-distribution.org/unstable/feed/armv4t/base/" >> /etc/ipkg/angstrom-base.conf
ipkg update ; ipkg install python-core python-xml 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 turned on)

#!/usr/bin/python
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'), 'org.bluez.audio.Manager')
path = audio.CreateDevice('00:0D:3C:44:33:22')
audio.ChangeDefaultDevice(path)
sink = dbus.Interface(bus.get_object(conn, path), 'org.bluez.audio.Sink')
sink.Connect()

FINALLY: play a song

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

Headset Audio

Neo1973_Audio_Subsystem has detail about alsa settings and a proposal for audio scenario management.

To try this out, follow the instructions in the a2dp section to install software and run the passkey agent.

Remove or disable the stuff you put in asound.conf. When using a voice headset, the application uses the regular system audio device and it gets routed to bluetooth in the codec.

Put the headset in pairing mode. Replace the bluetooth address below with your headset's and run the python script:

#!/usr/bin/python
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'), 'org.bluez.audio.Manager')
path = audio.CreateHeadset('00:0B:2E:39:33:22')
audio.ChangeDefaultHeadset(path)
headset = dbus.Interface (bus.get_object(conn, path), 'org.bluez.audio.Headset')
headset.Connect()
headset.Play()

Now place a call and try to route it to bluetooth (after it's in progress):

alsactl -f /etc/gsmbluetooth.state restore

You may also be able to listen to system audio given the right state file:

alsactl -f /etc/systembluetooth.state restore
madplay song.mp3

Bluetooth on Freerunner

NOTE: work in progress


This thread suggests the following:

Turn on bluetooth
Pair your headset according to these instructions.
Create the following python script to set up the audio service and set the headset as the default device:
http://handheldshell.com/BtHeadset.py
http://handheldshell.com/BtHeadsetDisconnect.py
This is the compiled the binary from the wiki page http://wiki.openmoko.org/wiki/Neo1973_audio_subsystem
http://handheldshell.com/bluetooth_pcm
Get the [alsa state file]
BtHeadset.py <headset mac address> & 
Now start the call and then run
alsactl restore 0 -f gsm_headset.txt
bluetooth_pcm
End the call
 BtHeadsetDisconnect.py <headset mac address> & 

You should now hear the call in your headset. I have not tried to see if the mic is working yet. This was all done with the 2008-updates image from sept 4.

Further reading

http://www.holtmann.org/papers/bluetooth/ols2006_slides.pdf http://wiki.bluez.org/wiki/Audio#org.bluez.Audio