Implementing a Bluetooth gateway on the Raspberry Pi

In this section, we will study the Bluetooth gateway server (as described in ~/Desktop/BluetoothGateway/gateway). We will study the RESTful services offered by the gateway and we will jump into the gateway code. The gateway server, as described in the previous section, is a web server that runs on Node.js and implements GAP, GATT, and RESTful web services. In order to get a recap of the Bluetooth GAP and GATT architecture, you can refer to Chapter 1, BLE and the Internet of Things

The code for the gateway can be found in the gateway folder of the project source. The core API used by this project is developed by the Bluetooth SIG, and the detailed documentation, including whitepapers, can be found at https://www.bluetooth.com/develop-with-bluetooth/white-papers.

The architecture of a Bluetooth gateway consists of three main components:

  • Bluetooth nodes (or smart devices)
  • Bluetooth gateway/server (Raspberry Pi)
  • Internet-enabled client (such as a cellphone or web browser)

The functionality of these three components can be understood by considering an example smart home. You have a temperature sensor in a Bluetooth beacon that is constantly broadcasting the temperature information about a room to its surroundings. In this case, the Bluetooth beacon is one of the Bluetooth nodes. A Raspberry Pi acting as a Bluetooth gateway/server is listening to all the devices in its surrounding and making that information available to the web server. You are somewhere outside your house but have a customized application installed that polls the server to obtain the information once every 5 minutes. In this case, your cellular phone is an Internet-enabled client that is listening to the server for potential informational messages. Imagine that an abrupt or unusual change in temperature is detected by the Bluetooth beacon. The information is then passed to the gateway, which will make this information available to potential clients. If a client is listening to the server, it will generate an alert, notifying the user that there is a potential fire in the apartment. This is how a complete Bluetooth gateway cycle is performed from a local Bluetooth network to a notification message on a client's cellular phone.

Here is a visual representation of the Bluetooth gateway architecture:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.199.243