bt.html 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <!DOCTYPE HTML>
  2. <html lang="en">
  3. <head lang="en">
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="Author" content="Eric S. Raymond">
  6. <meta name="Description" content="Blutooth setup instructions for GPSD">
  7. <meta name="Keywords" content="GPS, gpsd, bluetooth">
  8. <meta name="Revised" content="24 June 2020">
  9. <meta name="robots" content="index,follow">
  10. <link rel="stylesheet" href="main.css" type="text/css">
  11. <title>Bluetooth and GPSD</title>
  12. </head>
  13. <body>
  14. <div id="Header">Bluetooth and <code>gpsd</code></div>
  15. <div id="Menu">
  16. <img src="gpsd-logo-small.png" alt="Small gpsd Logo" height="126"
  17. width="105"><br>
  18. <a href="index.html">Home</a><br>
  19. <a href="index.html#news">News</a><br>
  20. <a href="index.html#downloads">Downloads</a><br>
  21. <a href="index.html#mailing-lists">Mailing lists</a><br>
  22. <a href="index.html#documentation">Documentation</a><br>
  23. <a href="faq.html">FAQ</a><br>
  24. <a href="xgps-sample.html">Screenshots</a><br>
  25. <a href="index.html#recipes">Recipes</a><br>
  26. <a href="index.html#others">Other GPSDs</a><br>
  27. <a href="hardware.html">Hardware</a><br>
  28. <a href="for-vendors.html">For GPS Vendors</a><br>
  29. <a href="wishlist.html">Wish List</a><br>
  30. <a href="hall-of-shame.html">Hall of Shame</a><br>
  31. <a href="troubleshooting.html">Troubleshooting Guide</a><br>
  32. <a href="hacking.html">Hacker's Guide</a><br>
  33. <a href="protocol-transition.html">Application Compatibility</a>
  34. <a href="references.html">References</a><br>
  35. <a href="history.html">History</a><br>
  36. <a href="future.html">Future</a><br>
  37. <a href='http://www.catb.org/hacker-emblem/'><img
  38. src='glider.png' alt='hacker emblem' height="55" width="55"></a><br>
  39. <script src="https://www.openhub.net/p/3944/widgets/project_thin_badge.js"></script>
  40. <a href="https://validator.w3.org/check/referer"><img
  41. src="https://www.w3.org/Icons/valid-html401"
  42. alt="Valid HTML 4.01!" height="31" width="88"></a>
  43. </div>
  44. <div id="Content">
  45. <p>Bluetooth connections work with <code>gpsd</code> by leveraging the
  46. rfcomm serial port emulation. Rfcomm provides a serial port interface
  47. to a BT device and has been designed to allow for automated
  48. connect/disconnect operations over Bluetooth. The steps below will
  49. allow you to use your BT GPS device automatically whenever it is
  50. powered on and gpsd is running.</p>
  51. <p>Note that you must be logged in as root for most of these steps.</p>
  52. <h2>Installation</h2>
  53. <p>If your system comes with Bluetooth tools preinstalled (look for
  54. <img src="bt.png" alt="Bluetooth icon"> on your status bar) you can
  55. probably skip these steps.</p>
  56. <ol>
  57. <li><p>First, the Bluez protocol stack must be installed. All the
  58. documentation can be found on <a
  59. href='http://bluez.sourceforge.net/'>http://bluez.sourceforge.net/</a>.</p></li>
  60. <li><p>Install bluetooth for your device with the "rfcomm" module to
  61. allow for serial port emulation.</p>
  62. <p>This procedure has been verified against Blues version 5.54, but
  63. should work with any recent version.</p></li>
  64. <li><p>Next, load the following modules:</p>
  65. <pre>
  66. # modprobe hci_xxx (xxx depend on your type of device)
  67. # modprobe bluez
  68. # modprobe l2cap
  69. # modprobe rfcomm
  70. </pre>
  71. </li>
  72. <li><p>If the modules have loaded successfully, type "hciconfig" and you
  73. should see your BT interface listed under the "hci0" name. "hciconfig" is
  74. part of the Bluez stack. Not all distributions install it by default.
  75. Gentoo requires USE="deprecated" with bluez to install hciconfig.</p></li>
  76. </ol>
  77. <h2>Configuration</h2>
  78. <ol>
  79. <li><p>Turn on your BT GPS device and scan for remote BT devices:</p>
  80. <pre>
  81. # hciconfig hci0 up
  82. # hcitool scan
  83. </pre>
  84. </li>
  85. <li><p>Write down the address of your BT GPS receiver (xx:xx:xx:xx:xx:xx).
  86. At this point, it is quite likely that passing the address to gpsd will work.</p></li>
  87. <li><p>If you're using a smartphone app to send your GPS data via
  88. Bluetooth Start the GPS app on your phone, altering any settings needed
  89. to make it send NMEA strings over Bluetooth.</p></li>
  90. <li><p>Check the protocol and channel that your device supports.</P>
  91. <pre>
  92. # sdptool browse xx:xx:xx:xx:xx:xx
  93. </pre>
  94. <p>A smartphone app will look something like this in the output. Note
  95. the channel number is 2:</p>
  96. <pre>
  97. Service Name: GPS2BT
  98. Service RecHandle: 0x1000b
  99. Service Class ID List:
  100. UUID 128: 00001101-0000-1000-8000-00805f9b34fb
  101. Protocol Descriptor List:
  102. "L2CAP" (0x0100)
  103. "RFCOMM" (0x0003)
  104. Channel: 2
  105. </pre>
  106. <p>A standalone Bluetooth GPS may look like this. Note the channel
  107. number is 1:</p>
  108. <pre>
  109. Service Name: SPP slave
  110. Service RecHandle: 0x10000
  111. Service Class ID List:
  112. "Serial Port" (0x1101)
  113. Protocol Descriptor List:
  114. "L2CAP" (0x0100)
  115. "RFCOMM" (0x0003)
  116. Channel: 1
  117. Language Base Attr List:
  118. code_ISO639: 0x656e
  119. encoding: 0x6a
  120. base_offset: 0x100
  121. </pre>
  122. <p>The Service name will vary based on the app or device. Write down the
  123. channel number and use it in the next step instead of channel 1. The channel
  124. number will likely vary each time the app is started, so you will probably
  125. need some scripting or other additional configuration to fix that. If gpsd or
  126. gpsctl is reporting "connection refused" it is likely that you have the
  127. wrong channel number.</p>
  128. <p>If you're using a smartphone app you will probably need to specify a
  129. channel other than 1.</p>
  130. </li>
  131. <li><p>The /etc/bluetooth/rfcomm.conf file is no longer used by rfcomm.
  132. Previous versions of this procedure used that file.<p>
  133. </li>
  134. <li><p>Bind rfcomm0 to the serial data channel, in this case 1, of the BT
  135. GPS. Then verify it worked:</p>
  136. <pre>
  137. # rfcomm bind rfcomm0 xx:xx:xx:xx:xx:xx 1
  138. # rfcomm -a
  139. rfcomm0: xx:xx:xx:xx:xx:xx channel 1 clean
  140. # ls /dev/rfcomm0
  141. /dev/rfcomm0
  142. </pre>
  143. <p>You will now have a new device file, /dev/rfcomm0, that you will
  144. use for gpsd to connect to the BT GPS.
  145. </li>
  146. <li>
  147. <p>Under most Linux distros, GPSD is by default configured to start gpsd on
  148. a hotplug event announcing a USB GPS. You need to reconfigure the GPSD
  149. installation so the daemon will be started at boot time listening to
  150. /dev/rfcomm0 (it will still work with hotplugged USB GPSes after you
  151. do this).</p>
  152. <p>Under Debian and Ubuntu Linux, <code>"dpkg-reconfigure gpsd"</code>
  153. will start a dialog that will reconfigure the device for you. You
  154. will need to reboot for this change to take effect.</p>
  155. </li>
  156. <li><p>You may find it easier just to start gpsd manually.</p>
  157. <pre>
  158. # gpsd -n /dev/rfcomm0
  159. </pre>
  160. </ol>
  161. <p>At this point, your system should be configured to use gpsd with
  162. your BT GPS device. You should test operation in the normal way
  163. described in the <a href="troubleshooting.html">Troubleshooting Guide</a>.</p>
  164. <h2>Known Issues:</h2>
  165. <ul>
  166. <li><p>Apparmor may silently prevent gpsd from using rfcomm. Check
  167. your "dmesg" output for signs of Apparmor interference.</p></li>
  168. <li><p>Creating rfcomm to bind on startup, and then starting gpsd, is
  169. very init system dependent and is not covered here.</p>
  170. </li>
  171. <li>
  172. <p>In February 2009 it was reported that there are some issues with
  173. the Bluetooth stack in Ubuntu Intrepid. <a
  174. href="http://cris.bytesnblades.net/2009/02/20/starting-gpsd-automatically-with-a-bluetooth-gps/">This
  175. report advocates using a different Bluetooth device manager and describes some
  176. additional udev rules.</a></p>
  177. </li>
  178. </ul>
  179. <h2>Contributors:</h2>
  180. <ul>
  181. <li><p>Jean-Michel Bouffard</p></li>
  182. <li><p>Joshua Layne</p></li>
  183. <li><p>Lukasz Stelmach</p></li>
  184. <li><p>Bertolt Loprets</p></li>
  185. <li><p>Rob Shinn</p></li>
  186. <li><p>Tomáš Ebenlendr</p></li>
  187. </ul>
  188. <hr>
  189. <script src="datestamp.js"></script>
  190. </div>
  191. </body>
  192. </html>