Getting Started with Bluetooth Low Energy
Kevin Townsend
Carles Cuf
Akiba
Robert Davidson
Preface
Bluetooth Low Energy (BLE), which was introduced as part of the Bluetooth 4.0 specification, is an exciting wireless technology that gives mobile application developers unprecedented access to external hardware and provides hardware engineers with easy and reliable access to their devices from every major mobile operating system.
This book aims to provide a solid, practical, high-level understanding of Bluetooth Low Energy: how data is organized, how devices communicate with each other, and the key design decisions and tradeoffs that were made by the protocol design teams. It should leave you with enough of an understanding of BLE to approach the high-level APIs on most modern embedded devices and mobile operating systems with confidence and enable you to make sense of the terminology and naming conventions in more in-depth technical documentation when you need to dig deeper. It should also clarify some of the specific strengths and limitations that distinguish BLE from other wireless technologies, such as WiFi, NFC, classic Bluetooth, Zigbee, and so on.
Experienced embedded firmware engineers will leave better prepared to dive deeper into the existing technical documentation, and mobile application developers will have a clearer idea of how data is organized in BLE devices and how to communicate with existing hardware.
Who This Book Is For
This book intends to serve two main audiences:
Mobile application developers First, the book serves as a high-level conceptual overview of Bluetooth Low Energy for mobile application developers who want to design applications capable of talking to physical devices in the outside world, but who might not find the official 2,600-page Bluetooth Core Specification 4.1 particularly easy to approach. Embedded engineers On the other side of the coin, the book is also for traditional embedded engineers who are considering Bluetooth Low Energy from a product design point of view. If you need to get up to speed quickly on what BLE is and isnt, this book should help you quickly evaluate its strengths and weaknesses as a wireless protocol for your project.
How to Use This Book
This book is organized into three main sections.
Overview of BLE
The first four chapters provide a high-level overview of Bluetooth Low Energy as a technology, explaining how data is organized and what its key limitations are, while also introducing all the key concepts that youre likely to encounter working with BLE:
The first chapter introduces the basic concepts of the wireless standard known as Bluetooth Low Energy. It briefly describes the essentials required for understanding the most important elements of the technology and gives an outline of the different specification and chip configurations that can be found today. This chapter also introduces and explains elementary concepts fundamental to BLE, such as broadcasting, connections, and the different roles that devices can assume.This chapter focuses on the protocol stack as a whole and the different entities that belong to it. It gives an overview of each of the protocol layers and their essential features, filtering out details from the specification that are not directly relevant to BLE application developers. Each layer is described in the context of the role it assumes as part of the bigger picture, with special attention to the impact it might have in real-life scenarios.This chapter presents the Generic Access Profile (GAP), which governs the advertising process as well as connections. It gives an overview of the modes and procedures that allow devices to interact using both advertising packets to broadcast information and connections to exchange data.This chapter provides an overview of the Generic Attribute Profile (GATT), which establishes the hierarchy and format used to represent and manipulate data in BLE. It introduces the fundamental concepts of services and characteristics, as well as the procedures that allow connected devices to exchange data with each other.
Tools for Development and Testing
The next three chapters present useful tools (both hardware and software) for developing or testing BLE-enabled applications or devices. These chapters focus on low-cost, easily accessible tools to help you get started without investing thousands of dollars:
This chapter provides product designers with an overview of some of the latest embedded development platforms for BLE peripherals or products.Whether youre designing your own device or designing an application that talks to existing hardware, youll almost certainly have many hours of debugging ahead of you. Debugging wireless devices is a different process than purely software-based development. This chapter presents some useful debugging tools for working with BLE and seeing whats actually being sent over the air.This chapter presents key tools for mobile application developers working with BLE. These tools will help you quickly test and verify your software or even simulate devices, if you dont have access to real hardware early in the design process.
Development Platforms
Finally, the last three chapters introduce the main development platforms you are likely to work with for BLE (iOS and Android for appication developers, and various embedded platforms for product designs and embedded harware engineers):
This chapter provides a basic overview of the hardware, software, and processes required to implement Bluetooth Low Energy on the Android operating system.This chapter explores some of the key iOS 7 frameworks, classes, and methods that support BLE application development. Examples explore application development using BLE to read the battery level of a peripheral and an application that uses the iBeacon for location determination.This chapter introduces the tools needed to compile code for embedded devices. Using the nRF51822-EK discussed in with the free, open source GNU toolchain and cross-compiler for ARM, youll create a heart rate monitor example to run natively on the nRF51822 SoC.
Conventions Used in This Book
The following typographical conventions are used in this book:
Italic Indicates new terms, URLs, email addresses, filenames, and file extensions. Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords. Constant width bold
Shows commands or other text that should be typed literally by the user. Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.
Tip
This element signifies a tip, suggestion, or general note.
Warning
This element indicates a warning or caution.
Using Code Examples
Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/microbuilder/IntroToBLE.
This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless youre reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from OReilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your products documentation does require permission.