Book Image

Building Bluetooth Low Energy Systems

By : Muhammad Usama bin Aftab
Book Image

Building Bluetooth Low Energy Systems

By: Muhammad Usama bin Aftab

Overview of this book

Bluetooth Low Energy (BLE) is a Wireless Personal Area network technology aimed at novel applications for smart devices. High-tech BLE profiles and services are being increasingly used by application developers and hardware enthusiasts to allow devices to interact with the surrounding world. This book will focus on a technical introduction to BLE and how it is reshaping small-distance communication. We will start with IoT, where many technologies such as BLE, Zigbee, and IEEE 802.15.4 Mesh will be introduced. The book will present BLE from an engineering perspective, from which the protocol stack, architecture, and layers are discussed. You will learn to implement customized projects for Peripheral/Central communication, BLE Beacons, indoor navigation using triangulation, and the Internet gateway for Bluetooth Low Energy Personal Network, all using various code samples and APIs on Android, iOS, and the Web. Finally, the book will conclude with a glimpse into future technologies destined to be prominent in years to come.
Table of Contents (14 chapters)
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Technologies in the Internet of Things


The Internet of Things is a network of smart devices who are aware of their surroundings. These devices achieve this awareness by constantly or eventually send/receive data with the connected devices. The user, on the other hand, can get access to these devices remotely. In some cases, these IoT devices can let the user perform things autonomously. For example, Tesla cars let the user drive it automatically and Robotic Vacuum Cleaner cleans the house without any master. These functionalities are only possible when these devices are connected and constantly learning about their surroundings. The connectivity is an integral part of these smart devices.

History tells us that the evolution of the Internet was not an easy task. Many standards came and went by before Internet started to converge towards a single most widely used standard. For example, there use to be many networks like ARPANET, UUCP, CYCLADES, NPL and many others before they started to converge under TCP/IP layer model which is now globally used as a standard. It was not before 1984 when CERN began the operation and implementation of TCP/IP as its basic computer networking scheme. The penetration of this new standard was seen in Asia when South Korea adopted TCP/IP communication model in 1982. Australia, on the other hand, was hesitant to adopt this new standard but later in 1989 Australia managed to get rid of their standards before forming AARNet (Australian Academic and Research Network) which provided a dedicated IPv4 based network throughout the country.

The devices in the Internet of Things are connected through one way or another. Sometimes a device can contain multiple modes of communication in order to perform multiple tasks. For example, a smart watch contains Bluetooth to communicate with the cell phone and Wi-Fi to talk directly to the Internet. Similarly, 2nd Generation Chromecast provides Wi-Fi for local and the Internet connectivity and uses HDMI to connect the Television. In IoT, the emphasis is more towards the wireless standards to ensure portability. That is the reason why many experts consider the connectivity of smart devices to smartphones really important. Thus, special emphasis on the wireless technologies will be seen in this book.

Wireless Local Area Network (WLAN)

Wireless Local Area Network or simply WLAN is a network that connects two or more devices wirelessly. A full TCP/IP protocol stack is followed in order to achieve end-to-end communication. This technology is based on IEEE 802.11 standard in which the communication between devices is achieved by a centralized hub/router. The devices are commonly referred to as nodes and the centralized router is referred to as wireless access point. In a usual situation, the wireless access point has a fixed location where the nodes can freely roam around within the coverage area of the access point. The connected devices can be tablet computers, laptops, desktops, cell phones or any IoT device (such as a smartwatch or Google Chromecast). Residentially, a typical access point covers an apartment but in commercial situations multiple access points can be bind to one SSID. If a node travels from Router 1's coverage area to Router 2's coverage area, they will perform a seamless handover between each other. Modern day WLAN are advertised under the Wi-Fi brand name.

Following mentioned diagram shows how Wi-Fi router communicates to its nodes. It is a typical working model of a WLAN:

Wireless Local Area Network architecture

This technology is proven to be very effective in modern day Internet of Things because the architecture is simple and can easily be implemented on a device with limited capabilities. Moreover, IPv6 gives us approximately 3 x 10^38 addresses which are more than enough to give identity to every atom in the world, let alone smart devices.

Note

WLAN is sold under the name Wi-Fi and can work on five different spectrums. 5.9 GHz, 5 GHz, 4.9 GHz, 3.6 GHz and 2.4 GHz. Each frequency range is further divided into many channels and countries impose their radio regulations independently.

Wireless Local Area Network is an important technology in the Internet of Things and devices like smart watches, media players and autonomous vehicles often use this technology to transfer information. Sometimes, this technology is used to give a control to the smart devices over a long distance.

Wireless Ad-hoc Networks

Wireless Ad-hoc Networks lies under the umbrella of IEEE 802.11 standard as well but unlike WLAN, they don't have a centralized hub/router. The devices are responsible for routing the packets across the networks. Wireless Mesh Network (WMN) is a sibling of Ad-hoc Networks with the only difference of traffic abnormalities and mobility. Ad-hoc networks are more dynamics as compare to WMN and they have more traffic irregularity than WMN.

In Ad-hoc networks, the device acts as a router to transmit traffic between peers if the destination device is not directly connected to the sender device. This formation of devices is reliable because each device is connected to another device in a mesh, giving alternate routes to any possible incoming packet. These networks are also self-organized, so if a device leaves the network, the network will reconfigure itself for new potential routes for forwarding packets. Due to their architecture, they are widely used in small and large networks. They run on TCP/IP based model and can easily be implemented in any lite-weight smart device.

Since they are connected to one another directly, they are also called peer-to-peer networks. The architecture of Ad-hoc networks is different than WLAN which brings advantage and disadvantage at the same time. Ad-hoc networks are fast and don't contain a single point of failure like a router, but they are more prone to network attacks. Ad-hoc networks are easily scalable networks where devices can come and go at their will. On the other hand, those devices are responsible for routing the packets, which make them weak for Man in the Middleattacks.

Wireless Ad-hoc Networks are further classified into five types:

  • Mobile Ad-hoc Networks (MANETs)
  • Smartphone Ad-hoc Networks (SPANs)
  • Vehicular Ad-hoc Networks (VANETs)
  • Internet-based Mobile Ad-hoc Networks (iMANETs)
  • Military Mobile Ad-hoc Networks

Note

Further information on Ad-hoc networks can be found on https://en.wikipedia.org/wiki/Wireless_ad_hoc_network.

The inclusion of Ad-hoc networks in the smart device makes them vulnerable because they normally contain personal and sensitive information. This brings a threat to the Internet of Things. On the other hand, Ad-hoc is almost the perfect topology for IoT devices as they are fast, scalable, easily maintainable and cheap.

To understand how a mesh is connected, consult the following figure:

An illustration of a fully connected Ad-hoc Network

ZigBee

ZigBee is a wireless mesh network built on IEEE 802.15.4 standard. With the advancement in sensors and low-powered smart devices, there was a need for a technology that can connect them wirelessly in the form of a mesh. The ZigBee technology was introduced which works on a Personal Area Network and works on low power. Internet of Things searches for the technology with low power consumption because it is built with the devices with limited power capabilities. For that purpose, ZigBee is considered as a technology with a seamless connection flexibility, ideal power consumption, and reliability.

ZigBee gives a 10-100m line of sight coverage for connectivity. Typically, it works on a 2.4 GHz band (ISM) but can be found on other frequency like 784 MHz, 868 MHz, and 915 MHz. With the wide variety in the spectrum, the data rates in ZigBee varies from 20 Kbit/s to 300 Kbit/s. The ZigBee module can be of 0.5 inches which are easily implementable in any Internet of Things device. One of the attractive parts of ZigBee is that it has out of the box capabilities of wireless mesh, star and tree architecture:

ZigBee Logo

A significant disadvantage of ZigBee lies in its adoption in computing devices. Typically, a smartphone or a laptop does not come with this module. Computers and cellular phones are the basic connection points for IoT devices. For example, if a person has ZigBee-based smart-home device, he will not be able to control it with his cellular phone or laptop without connecting additional hardware. This is a very crucial disadvantage as IoT devices mostly, if not always, rely on a smartphone-based remote control. Philips Hue (a smart bulb) can not be remotely controlled by a smartphone if its major technology of communication is ZigBee.

This disadvantage leaves a question mark on the technology but the other side can not be neglected as well. ZigBee is the only lite-weighted-low-power-consumption technology available in the market which supports mesh communication out of the box. Companies like smart plugs and smart energy interface use ZigBee as their main mode of communication. Let's take the example of Philips Hue Wireless dimming kit. It comes with a separate controller which talks to the smart bulb without any need of the smartphone. In this scenario, ZigBee can be the most practical solution.

A demonstration of the Philips Hue smart bulb can be seen here:

Phillips Hue wireless dimming kit with ZigBee technology