Home Wireless
Published in

Home Wireless

Building Bluetooth Services in Zephyr

Part 2: Implementing the Services

In part 1, I showed how to start up Bluetooth with advertising. That included source code that set up advertising for a few different Bluetooth services.

Overview

A Bluetooth peripheral device is defined by the set of Bluetooth services that it supports. The peripheral advertises those services. A service is like a mini application. There are many standard services: see Bluetooth-Guids.

Each service contains a set of characteristics — which are like ports that are read from and/or written to.

Device Information Service

The Device Information Service is a read-only collection of string data defining the device.

Implementing the service is easy. It’s statically defined and has no actual ‘code’. Since the startup code advertises the DIS that’s all we need.

Here you can see the Model Number String, Manufacturer Name String, … that all come from those statically defined sets of a data and one simple read method shared by all of the characteristics.

Battery Level Service

The battery level service contains one BLE read-only characteristic that is programmatically updated. When the value is updated any connected devices get a notification.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mark Zachmann

Mark Zachmann

Entrepreneur, software architect, electrical engineer. Ex-academic.