First Technology Transfer

Standard and Advanced Technical Training, Consultancy and Mentoring

ZEPH 102 - BLE Programming with Zephyr RTOS using the nRF Connect SDK

Duration: 5 Days

Intended Audience

Attendees are expected to be proficient C programmers and have a good working knowledge of Zephyr RTOS such as might be acquired in the Zephyr RTOS Real Time C Programming course.


The emphasis in this course is on programming BLE applications with Zephyr RTOS using Nordic Semiconductor Devices and the nRF Connect SDK
Nordic Semiconductor processors with built in BLE hardware are widely used in many IoT and IIoT applications, as well as in peripheral devices such as BLE enabled mouse, keyboard and joystick devices. Nordic Semiconductor has migrated from the nRF SDK which was RTOS agnostic and used for developing bare metal applications to nRF Connect SDK which builds on top of the Zephyr RTOS framework. For many organisations the task of migrating to the nRF Connect SDK involves upskilling their firmware developers to be able to make good use of the potential advantages offered by adopting Zephyr RTOS.
As well as mastering the Zephyr RTOS C API and commonly used RTOS programming idioms and design patterns the migration process involves gaining familiarity with the Zephyr RTOS BLE API and device driver framework and understanding the differences between working with the Nordic BLE stack and the Zephyr RTOS open source BLE stack.
This course will be based on the NRF52840-DK, nRF52840-DK and nRF52840 Dongle boards and make extensive use of the nRF Connect for Desktop application and the nRF Connect Mobile apps on iPhone and Android phone devices.

Course Overview

Course Outline

The course will review the key Zephyr RTOS features
  • Scheduling, Interrupts and Synchronisation
  • Data Passing
  • Memory Management
  • Timing and timers
  • Interrupt handlers

The course will, also, include coverage of

  • The BLE standards and protocols
  • Developing BLE Central and BLE Peripheral applications
  • Power consumption aspects of BLE
  • Examining BLE traffic using the Wireshark protocol analyzer

Suitable for which kinds of attendee ?

This course is for software engineers, field engineers and (project) managers planning to build relatively sophisticated IoT and IIoT applications running on Nordic Semiconductor nRF5x processors.


Attendees must be experienced C programmers with a good basic knowledge of embedded processor architectures and a basic knowledge of the Zephyr RTOS architecture and API.

Foundations of Bluetooth Low Energy Application Development and Programming Using Nordic nRF5x Processors and Zephyr RTOS with the nRF Connect SDK

This course is for developers who have a reasonable working knowledge of embedded systems programming in C. It does not assume any great experience of developing embedded RTOS applications. Neither does it assume any detailed knowledge of the BLE (Bluetooth Low Energy) communications protocol and its sub-protocols. The course is oriented towards nRF52 devices and will make use of the nRF52840 DK, the nRF5340 DK, the nRF5340 audio DK and the nRF52840 dongle. At the end of the course attendees should

  • Have a good understanding of the benefits of using Zephyr RTOS in embedded applications
  • A good understanding of multi-tasking inter-task communications idioms and design patterns
  • The use of VSCode with the nRF Connect SDK plugin for VSCode for building, testing and debugging Zephyr RTOS applications
  • A good understanding of the BLE protocol and the Zephyr RTOS BLE APIs
  • How to develop applications using Zephyr's open source BLE stack and Nordic's closed source BLE stack.
  • An understanding of the Nordic nRF Connect for Desktop tool framework and how to use it to develop and test BLE applications.
  • A basic understanding of Zephyr's West tool, CMake and Zephyr's use of DeviceTree and KConfig.
  • Be able to implement, test and deploy BLE applications involving BLE Central and BLE Peripheral applications, Peripheral GATT and Peripheral HID.

  • Use of peripherals and sensors - GPIO, Timer, PPI, GPIOTE, UART, Temperature Sensor, PWM , I2C and SPI sensors.

Detailed Course Outline

Multitasking in Embedded Systems Applications

  • The nature of multi-tasking
  • Bare Metal multi-tasking -with Interrupts, Timers and an Infinite Loop
  • Multi-tasking using an RTOS
    • Threads
    • Schedulers
    • Interrupts
  • Thread priorities, thread synchronisation and inter-thread communication
    • Pre-emptive multitasking and thread priorities
    • Co-operative multitasking and task sleeping
    • Interrupt handling tasks
    • Splitting interrupt handling into interrupt context work and thread context work
    • Mutexes and Semaphores and their usage patterns
    • Data exchange using message queues and mailboxes
    • Multitasking in networked applications
  • Synchronous vs. asynchronous APIs

Introduction to the Zephyr RTOS
  • A short history of Zephyr
  • Design goals of Zephyr
  • Comparison of Zephyr with FreeRTOS
  • Introduction to the Zephyr application building framework and tools
    • West, CMake, KConfig
    • Building Zephyr applications using West and the CLI (Command Line Interface)
    • Introduction to the Zephyr Device Driver Model and DeviceTree
  • Zephyr and the nRF Connect SDK
  • Nordic nrf additions to Zephyr
  • Introducing the Zephyr thread API
  • Implementing simple multi-threading tasks using GPIO (Leds and Buttons)

Introduction to Bluetooth Low Energy (BLE)

  • What is BLE
  • The BLE layered protocol architecture
  • BLE connection oriented and connectionless communication
  • Advantages and Disadvantages of BLE

nRF52 Processor Architecture and Tools

  • ARM Cortex M4 processor architecture - an overview
  • Addition of BLE hardware
  • Nordic BLE protocol stack implementation - overview
  • Zephyr RTOS open source BLE protocol stack implementation - overview
  • nRF Connect for Desktop Applicatiom
  • Introduction to VSCode and the nRF Connect SDK plugin
  • nRF Connect for Desktop Application
  • Building a Bluetooth Low Energy app in nRF Connect for Desktop
  • BLE protocol analysis using Wireshark and a BLE sniffer dongle

BLE Broadcasting Data with Advertisements

  • Device GAP advertiser role
  • Advertising channels and packets
  • Active and passive scanning
  • Public addresses
  • Random addresses - static and private
  • Broadcasting sensor data

BLE Connections and Services

  • GAP and GATT
  • Peripheral and Central
  • GATT attributes - services,characteristics and descriptors
  • Attribute structure - handle, type, permission, value
  • GATT Server - services, characteristics and descriptors
  • Implementing a Zephyr RTOS based nRF52 BLE GATT Server

BLE Connection Security

  • BLE connection security architecture
  • Pairing and bonding
  • Security modes and levels
  • Encryption and authentication
  • Implementing a secure Zephyr + nRF5x sensor BLE application

BLE Profiles and Roles

  • Generic profiles
  • GATT profiles and examples
    • HID
    • HDP

BLE Peripheral and Service case studies

  • BLE direction finding peripheral
  • Nordic BLE UART service

nRF5340 BLE

  • ARM Cortex M33 architecture overview
  • ARM Trust Zone technology overview
  • nRF5340 - a dual ARM Cortex M33 processor
    • ARM Trust Zone supporting core
    • Basic ARM Cortex M33 core
    • Introduction to nRF5340 Zephyr RTOS dual core programming
    • Introduction to security and security partitions
  • Developing BLE audio applications using the nRF5340
    • Bluetooth LE audio standard
    • Audio processing technology overview - ADC, DAC and DSP

BLE Mesh protocol

  • Overview of the BLE Mesh protocol
  • nRF Connect SDK support for BLE Mesh
  • Developing Zephyr RTOS BLE Mesh applications using the nRF Connect SDK
  • Mesh example case studies
    • Light control and light switch
    • Sensor client and sensor server
    • Chat