Book Image

IoT Projects with Bluetooth Low Energy

By : Madhur Bhargava
Book Image

IoT Projects with Bluetooth Low Energy

By: Madhur Bhargava

Overview of this book

Bluetooth Low Energy, or Bluetooth Smart, is Wireless Personal Area networking aimed at smart devices and IoT applications. BLE has been increasingly adopted by application developers and IoT enthusiasts to establish connections between smart devices. This book initially covers all the required aspects of BLE, before you start working on IoT projects. In the initial stages of the book, you will learn about the basic aspects of Bluetooth Low Energy—such as discovering devices, services, and characteristics—that will be helpful for advanced-level projects. This book will guide you through building hands-on projects using BLE and IoT. These projects include tracking health data, using a mobile App, and making this data available for health practitioners; Indoor navigation; creating beacons using the Raspberry Pi; and warehouse weather Monitoring. This book also covers aspects of Bluetooth 5 (the latest release) and its effect on each of these projects. By the end of this book, you will have hands-on experience of using Bluetooth Low Energy to integrate with smart devices and IoT projects.
Table of Contents (15 chapters)
Title Page
Credits
Foreword
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Services


Extending further from the previous section, we saw that the GATT profile imposes a client–server architecture to facilitate the communication between Bluetooth Low Energy devices (the sensor and the collector) and Bluetooth Low Energy technology. Following a service-oriented architecture, the blood pressure sensor (or any other Bluetooth Low Energy device playing a GATT Server role) exposes some services.

Remember, how we compared Bluetooth Low Energy to a very intelligent database in the previous section, and that is exactly what is happening here. The primary reason for the existence of a blood pressure device sensor (or any other Bluetooth Low Energy sensor/device) is extremely simple. It measures the correct data (blood pressure levels in this case), stores it, and then makes the data available when requested by a client. A service is a wrapper on top of this data (this data is also known as characteristics and more on characteristics later). Similar kinds of data or characteristics are bundled together in a single service. This is a key factor in understanding the design of services, which exist to bundle similar kinds of data together. Perhaps an example will provide further clarity to this. The Blood Pressure Profile indicated the existence of two kinds of services:

  • Blood Pressure Service: This consists of Blood Pressure Measurement data/characteristics
  • Device Information Service: This consists of device data (Manufacturer Name, Model Number, Serial Number, and Hardware Revision):

Figure 13: Services in a Blood Pressure Profile

Did you notice how each service consists of different kinds of data, which is similarly pertaining to itself? If you want to get blood pressure data, you should go and interrogate the blood pressure service and if you need information about the device itself, then you should go and talk to the device service. This is the primary reason for the existence of services. We had already established in the previous section that a profile can have multiple services. Like Bluetooth profiles, the Bluetooth SIG defines a number of official services.

Note

Visit https://www.bluetooth.com/specifications/gatt/services for more insight on service definitions by bluetooth SIG.

Each official service is assigned a unique 16-bit UUID so that it can distinguish itself from others; for example, a blood pressure service has a UUID of 0x1810 and a device information service has a UUID of 0x180A. You can also write your own custom service for a specific purpose, but then it will need to have a 128-bit custom UUID.

Once again, I will strongly advise you to go over the relevant documentation of Blood Pressure Service and Device Information Service. Not only will this be very helpful in the discussion ahead, it will also clarify the information indicated in the preceding diagram.

The documents outline what characteristics each of the services contain or what information can be found on interrogating relevant services. For example, the blood pressure service contains three distinct characteristics:

  • Blood Pressure Measurement
  • Intermediate Cuff Pressure
  • Blood Pressure Feature

The documentation also indicates what kind of data each characteristic holds; for example, the Blood Pressure Feature characteristic is used to describe the supported features of the blood pressure sensor. And by that, we have already started touching base on characteristics which deserve a topic of their own.