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:

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

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

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