Bluetooth connections work with gpsd by leveraging the rfcomm serial port emulation. Rfcomm provides a serial port interface to a BT device and has been designed to allow for automated connect/disconnect operations over Bluetooth. The steps below will allow you to use your BT GPS device automatically whenever it is powered on and gpsd is running.

Note that you must be logged in as root for most of these steps.

Installation

If your system comes with Bluetooth tools preinstalled (look for Bluetooth icon on your status bar) you can probably skip these steps.

  1. First, the Bluez protocol stack must be installed. All the documentation can be found on http://bluez.sourceforge.net/.

  2. Install bluetooth for your device with the "rfcomm" module to allow for serial port emulation.

    This procedure has been verified against Blues version 5.54, but should work with any recent version.

  3. Next, load the following modules:

            # modprobe hci_xxx (xxx depend on your type of device)
            # modprobe bluez
            # modprobe l2cap
            # modprobe rfcomm
    
  4. If the modules have loaded successfully, type "hciconfig" and you should see your BT interface listed under the "hci0" name. "hciconfig" is part of the Bluez stack. Not all distributions install it by default. Gentoo requires USE="deprecated" with bluez to install hciconfig.

Configuration

  1. Turn on your BT GPS device and scan for remote BT devices:

        # hciconfig hci0 up
        # hcitool scan
    
  2. Write down the address of your BT GPS receiver (xx:xx:xx:xx:xx:xx). At this point, it is quite likely that passing the address to gpsd will work.

  3. If you're using a smartphone app to send your GPS data via Bluetooth Start the GPS app on your phone, altering any settings needed to make it send NMEA strings over Bluetooth.

  4. Check the protocol and channel that your device supports.

        # sdptool browse xx:xx:xx:xx:xx:xx
    

    A smartphone app will look something like this in the output. Note the channel number is 2:

      Service Name: GPS2BT
      Service RecHandle: 0x1000b
      Service Class ID List:
        UUID 128: 00001101-0000-1000-8000-00805f9b34fb
      Protocol Descriptor List:
        "L2CAP" (0x0100)
        "RFCOMM" (0x0003)
          Channel: 2
    

    A standalone Bluetooth GPS may look like this. Note the channel number is 1:

      Service Name: SPP slave
      Service RecHandle: 0x10000
      Service Class ID List:
        "Serial Port" (0x1101)
      Protocol Descriptor List:
        "L2CAP" (0x0100)
        "RFCOMM" (0x0003)
          Channel: 1
      Language Base Attr List:
        code_ISO639: 0x656e
        encoding:    0x6a
        base_offset: 0x100
    

    The Service name will vary based on the app or device. Write down the channel number and use it in the next step instead of channel 1. The channel number will likely vary each time the app is started, so you will probably need some scripting or other additional configuration to fix that. If gpsd or gpsctl is reporting "connection refused" it is likely that you have the wrong channel number.

    If you're using a smartphone app you will probably need to specify a channel other than 1.

  5. The /etc/bluetooth/rfcomm.conf file is no longer used by rfcomm. Previous versions of this procedure used that file.

  6. Bind rfcomm0 to the serial data channel, in this case 1, of the BT GPS. Then verify it worked:

        # rfcomm bind rfcomm0 xx:xx:xx:xx:xx:xx 1
        # rfcomm -a
        rfcomm0: xx:xx:xx:xx:xx:xx channel 1 clean 
        # ls /dev/rfcomm0
        /dev/rfcomm0
    

    You will now have a new device file, /dev/rfcomm0, that you will use for gpsd to connect to the BT GPS.

  7. Under most Linux distros, GPSD is by default configured to start gpsd on a hotplug event announcing a USB GPS. You need to reconfigure the GPSD installation so the daemon will be started at boot time listening to /dev/rfcomm0 (it will still work with hotplugged USB GPSes after you do this).

    Under Debian and Ubuntu Linux, "dpkg-reconfigure gpsd" will start a dialog that will reconfigure the device for you. You will need to reboot for this change to take effect.

  8. You may find it easier just to start gpsd manually.

        # gpsd -n /dev/rfcomm0
    

At this point, your system should be configured to use gpsd with your BT GPS device. You should test operation in the normal way described in the Troubleshooting Guide.

Known Issues:

Contributors: