Connecting a Bluetooth GPS in Linux on the Ipaq 3975


Software/Hardware Overview

Computer Specifications

iPAQ h3975 running Familiar Linux 0.8.2

BlueZ tools –should be pre-installed

Globalsat BT-338


Setting up the Software

The Bluez tools should be installed in the default image. You can verify that the following packages are installed using Package Manager

  • Bluez-utils-nodbus
  • Opie-bluetoothapplet
  • Opie-bluetoothmanager – you probably don’t need this since we’ll do our editing manually
  • GPSD

 

The good news it pretty much works out the box if you’re using GPE (only need to set up rfcomm) but for you OPIE users you’ll need to do some tweaking

 

If that’s all good you should be able to add the Bluetooth applet to the taskbar using the launcher application.

 

In theory, the bluepin utility should either use the PIN in /etc/bluetooth/pin or prompt you when it needs a PIN.

However, on Familiar, the PIN exchange silently fails. So, we need to replace bluepin with a script

that spat out the PIN in /etc/bluetooth/pin:

 

Replace Bluepin – ONLY FOR OPIE GPE USERS IGNORE

#!/bin/sh

# file: /usr/local/bin/bluepincat

echo -n "PIN:"

cat /etc/bluetooth/pin

 

 

Then we set the pin_helper line in /etc/bluetooth/hcid.conf:

 

Set pin_helper line in /etc/Bluetooth/hcid.conf – ONLY FOR OPIE GPE USERS IGNORE

#
# HCI daemon configuration file.
#
# $Id: hcid.conf,v 1.4 2004/04/29 20:14:21 holtmann Exp $
#
 
# HCId options
options {
        # Automatically initialize new devices
        autoinit yes;
 
        # Security Manager mode
        #   none - Security manager disabled
        #   auto - Use local PIN for incoming connections
        #   user - Always ask user for a PIN
        #
        security auto;
 
        # Pairing mode
        #   none  - Pairing disabled
        #   multi - Allow pairing with already paired devices
        #   once  - Pair once and deny successive attempts
        pairing multi;
 
        # PIN helper
        pin_helper /usr/local/bin/bluepincat;
# /opt/QtPalmtop/bin/bluepin;
 
        # D-Bus PIN helper
        # dbus_pin_helper;
}
 
# Default settings for HCI devices
device {
        # Local device name
        #   %d - device id
        #   %h - host name
name "ipaq";
 
        # Local device class
        class 0x120112;
 
        # Default packet type
        #pkt_type DH1,DM1,HV1;
 
        # Inquiry and Page scan
iscan enable;pscan enable;
 
        # Default link mode
        #   none   - no specific policy 
        #   accept - always accept incoming connections
        #   master - become master on incoming connections,
        #            deny role switch on outgoing connections
        #
        #lm accept,master;
        #
        lm accept;
 
        # Default link policy
        #   none    - no specific policy
        #   rswitch - allow role switch
        #   hold    - allow hold mode
        #   sniff   - allow sniff mode
        #   park    - allow park mode
        #
        #lp hold,sniff;
        #
        lp rswitch,hold,sniff,park;
 
        # Authentication and Encryption
        auth enable;
        encrypt enable;
}
        

 

Set Default Pin in /etc/bluetooth/pin

0000

 

Turn the Radio ON

 
        Click on the Bluetooth Icon on the taskbar and select Enable Bluetooth
        

 

Restart hcid  after PIN changes – ONLY FOR OPIE GPE USERS IGNORE

root@3900:/#  killall hcid
root@3900:/#  hcid
        

 

Open up a Console Window– ONLY FOR OPIE GPE USERS IGNORE

root@3900:/#  hciconfig –a
hci0:   Type: UART
        BD Address: 00:02:C7:11:89:0F ACL MTU: 128:8 SCO MTU: 64:8
        UP RUNNING PSCAN ISCAN AUTH ENCRYPT 
        RX bytes:565 acl:0 sco:0 events:15 errors:0
        TX bytes:475 acl:0 sco:0 commands:14 errors:0
        Features: 0xff 0xff 0x05 0x00 0x00 0x00 0x00 0x00
        Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
        Link policy: RSWITCH HOLD SNIFF PARK 
        Link mode: SLAVE ACCEPT 
        Name: 'ipaq'
        Class: 0x120112
        Service Classes: Networking
        Device Class: Computer, Handheld
        HCI Ver: 1.1 (0x1) HCI Rev: 0x72 LMP Ver: 1.1 (0x1) LMP Subver: 0x72
        Manufacturer: Cambridge Silicon Radio (10)
        

 

If it says DOWN instead of UP– ONLY FOR OPIE GPE USERS IGNORE

root@3900:/#  hciconfig hci0 up
root@3900:/#  hciconfig -a
hci0:   Type: UART
        BD Address: 00:02:C7:11:89:0F ACL MTU: 128:8 SCO MTU: 64:8
        UP RUNNING PSCAN ISCAN AUTH ENCRYPT
        RX bytes:565 acl:0 sco:0 events:15 errors:0
        TX bytes:475 acl:0 sco:0 commands:14 errors:0
        Features: 0xff 0xff 0x05 0x00 0x00 0x00 0x00 0x00
        Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
        Link policy: RSWITCH HOLD SNIFF PARK 
        Link mode: SLAVE ACCEPT 
        Name: 'ipaq'
        Class: 0x120112
        Service Classes: Networking
        Device Class: Computer, Handheld
        HCI Ver: 1.1 (0x1) HCI Rev: 0x72 LMP Ver: 1.1 (0x1) LMP Subver: 0x72
        Manufacturer: Cambridge Silicon Radio (10)
        

 

Probe the GPS– ONLY FOR OPIE GPE USERS IGNORE

root@3900:/#  hcitool scan
Scanning ...
        00:0D:B5:30:17:04      BT-GPS-301704  

You should ‘discover’ the GPS as you can see about the GPS replied with it’s name and MAC address. Take note of the MAC you’ll need it below

Now we know the MAC address of the device, we can set up our system to automatically bind to it every reboot. This is accomplished by editing the file /etc/bluetooth/rfcomm.conf. In that file identifiers are listed with parameters enclosed in curly braces.

Set Automatic Binding

#
# RFCOMM configuration file.
#
# $Id: rfcomm.conf,v 1.1 2002/10/07 05:58:18 maxk Exp $
#
 
rfcomm0 {
        # Automatically bind the device at startup
        bind yes;
 
        # Bluetooth address of the device
        device 00:0D:B5:30:17:04;
 
        # RFCOMM channel for the connection
        channel 1;
 
        # Description of the connection
        comment "BT-338 GPS";
}
        

 

By setting bind yes; we are making it bind every time the system starts up. This is not creating a connection, but instead binding /dev/bluetooth/rfcomm/0 (major 216 minor 0) to the address listed in device on the specified channel. Then when anything tries to access /dev/bluetooth/rfcomm/0 it will create the bluetooth link at that point. To bind the device to this connection without rebooting all that is needed is the following command

Bind without restarting

root@3900:/#  rfcomm bind rfcomm0
        

 

Test The GPS Connection

root@3900:/#  cat /dev/bluetooth/rfcomm/0
$GPGGA,190328.722,,,,,0,00,,,M,0.0,M,,0000*50
 
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
 
$GPRMC,190328.722,V,,,,,,,290905,,*2E
 
$GPVTG,,T,,M,,N,,K*4E
 
$GPGGA,190329.722,,,,,0,00,,,M,0.0,M,,0000*51
 
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
 
$GPRMC,190329.722,V,,,,,,,290905,,*2F
 
$GPVTG,,T,,M,,N,,K*4E
 
$GPGGA,190330.722,,,,,0,00,,,M,0.0,M,,0000*59
 
$GPGSA,A,1,,,,,,,,,,,,,,,*1E   

You should see NMEA 0813 output from the GPS.

Verify with GPSD

root@3900:/# gpsd –f /dev/Bluetooth/rfcomm/0
root@3900:/# telnet localhost 2947
r
$GPGGA,190328.722,,,,,0,00,,,M,0.0,M,,0000*50
 
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
 
$GPRMC,190328.722,V,,,,,,,290905,,*2E
 
$GPVTG,,T,,M,,N,,K*4E
 
$GPGGA,190329.722,,,,,0,00,,,M,0.0,M,,0000*51
 
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
 
$GPRMC,190329.722,V,,,,,,,290905,,*2F
 
$GPVTG,,T,,M,,N,,K*4E
 
$GPGGA,190330.722,,,,,0,00,,,M,0.0,M,,0000*59
 
$GPGSA,A,1,,,,,,,,,,,,,,,*1E   

 

Congratulations!

 

Your GPS now works!

 

Troubleshooting

 

root@3900:/#  root@3900:/#  cat /dev/bluetooth/rfcomm/0
cat: /dev/bluetooth/rfcomm/0: Permission Denied
This is caused by a PIN error. Double check the pin workaround above, turn off the radio, restart hcid

 

  O’Reilly Publishing A COMPLETE GUIDE TO WIRELESS CONFIGURATION - Linux Unwired