Building Bluetooth Services in Zephyr

Part 2: Implementing the Services

Mark Zachmann
May 10, 2020 · 2 min read

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.

Home Wireless

Home automation in the wireless IOT era

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

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