Appendix A. tBlue Library for Android

In the Bluetooth examples you’ve seen in this book, the interactions have been simple: opening a connection and sending a few characters. But to use Bluetooth, you must also:

  • Find the cell phone’s Bluetooth adapter.

  • Define a Bluetooth object that represents the device you are talking to (such as an Arduino).

  • Open a socket that represents the Bluetooth serial connection.

  • Open some stream objects: one for sending messages, one for receiving.

Because the Android Bluetooth APIs are complex, we created the class TBlue, which keeps things simple. Chapter 8 has example code that shows you how to use the tBlue library. Here is the source of the TBlue class:

// tBlue.java - simple wrapper for Android Bluetooth libraries ...

Get Make: Arduino Bots and Gadgets now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.