Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
IoT Projects with Bluetooth Low Energy

You're reading from  IoT Projects with Bluetooth Low Energy

Product type Book
Published in Aug 2017
Publisher Packt
ISBN-13 9781788399449
Pages 278 pages
Edition 1st Edition
Languages
Author (1):
Madhur Bhargava Madhur Bhargava
Profile icon Madhur Bhargava

Chapter 3. Building a Service Explorer App

I hear and I forget. I see and I remember. I do and I understand.

- Confucius

In the last chapter, we configured our systems so that we could build apps to gain a better understanding of Bluetooth Low Energy. In this chapter, we will build a Service Explorer app using which you can explore all kinds of Bluetooth Low Energy devices for their services. Also, as a bonus, we will simulate our very own homemade fitness tracker and explore its services and characteristics using the same app.

We hope that you remember our discussions regarding Bluetooth Low Energy architecture from the first chapter. Even if our deep discussions in the last chapter regarding the setup of our development environment has made it a little foggy, worry not, as we start with a refresher of the BLE architecture concepts in this chapter.

We will be creating a Service Explorer App by covering the following topics in this chapter:

  • Central Peripheral Architecture for BLE
  • Services and...

Central Peripheral Architecture for BLE


As understanding of Bluetooth Low Energy architecture in terms of Central and Peripheral roles is essential to understand how Bluetooth Low Energy devices advertise and connect to each other.

A Central is a device, which scans for Bluetooth devices to connect and utilize the information hosted by them. Usually, Central devices are richer in terms of resources such as computing power compared to the Peripheral devices. Specific to the use case that we will describe in this chapter, the role of a Central will be played by a mobile phone (Android/iOS):

Figure 1: Central and Peripheral Roles in Bluetooth Low Energy; source: developer.apple.com

Peripherals, on the other hand, are devices, which advertise their presence, and it is by virtue of this advertisement that the Central knows that a Peripheral device is nearby and it can connect to enquire about its data. For this chapter, we will be using the following to act as peripherals:

  • A fitness tracker
  • A mobile...

Services and Characteristics


We have already covered services and characteristics in extensive detail in the first chapter; however, we will still do a quick refresher here, just in case. We will go bottom up this time starting with characteristics first.

Characteristics are the lowest and the most important echelon of the Bluetooth Low Energy technology. Encapsulated by a related service, these are the actual state variables, each of which stores a single piece of relevant measurement and information data. It is worthwhile reading about the Heart Rate Measurement characteristic, which we will be covering extensively in this chapter.

Characteristics have a UUID, which can be 16-bit or 128-bit based on whether a characteristic has a standard or custom definition. A manufacturer is free to define custom...

Creating a Service Explorer App


The best way to test and master the theoretical knowledge is by doing and creating stuff and we will do the same by sticking to this well known and practiced philosophy. In this section, we will create a Service Explorer app for both Android and iOS platforms, which will help us in understanding the very intricacies of Bluetooth Low Energy as a technology. While similar in their functionalities, the Android app will scan manually through the use of start/stop buttons. The iOS app, however, will scan automatically as soon as the App is launched.

Following are the pre-requisites for this section,

Android:

  • Latest Android Studio
  • A Latest Android Device (Preferable Samsung Galaxy S8, since it has support for Bluetooth 5; otherwise Any Device with an API Level of 23(Android M) is fine)
  • Basic familiarity with Java and Android

iOS:

  • XCode 8.2
  • A latest iOS device (Our development device uses iOS 9.3.5)
  • Basic familiarity with Swift 2.3 and iOS

We request you to please do the following...

Summary


If you covered this chapter completely and have made it this far, then you can give yourself a pat on the back. Having an understanding of Bluetooth Low Energy on two major mobile platforms is no small feat.

As your creative juices start flowing, you will have realized the endless possibilities that Bluetooth Low Energy can generate together when combined with a backend. For example, reading data from a heart rate monitor (or any other BLE Peripheral) is one thing, but making it available to be accessed remotely, already opens doors to many interesting IoT applications of Bluetooth Low Energy, which are not just limited to healthcare.

There is so much more to come and, in the coming chapters we will go in even deeper and explore how we can make use of Bluetooth Low Energy in areas other than healthcare, such as indoor positioning/navigation, Beacon based local adverts and other commercial solutions.

In the next chapter, we will shift our focus away a little bit from the healthcare and...

lock icon The rest of the chapter is locked
You have been reading a chapter from
IoT Projects with Bluetooth Low Energy
Published in: Aug 2017 Publisher: Packt ISBN-13: 9781788399449
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}