Skip to content

BojanSof/emPub

Repository files navigation

emPub is publisher-subscriber library for embedded systems, written in C++20.

Features

  • Header-only
  • No external dependencies, except for C++ standard library
  • No dynamic memory allocation
  • No RTTI
  • No exceptions
  • Provides platform-agnostic interface for thread-safe operation
  • Supports synchronous and deferred message delivery
  • Supports message filtering
  • Supports identification of publishers

Supported Platforms

  • Any platform with a C++20 compliant compiler
  • Zephyr RTOS module

Documentation

Check the examples in the examples directory and the unit-tests in the test directory.

Zephyr RTOS

There is example application in examples/zephyr directory, which demonstrates sample usage of emPub in Zephyr RTOS environment. Ensure to add the emPub module in your manifest file. This example provides hypothetical device that reads the heart rate and blood oxygen saturation at fixed time intervals, publishes the sensor data payload to serializer, which prepares the data in byte-stream format, suitable for sending over communication interface. emPub is used to deliver all the messages between the components.

To build the example application for nrf54l15dk board, assuming the emPub module is located at modules/lib directory in the workspace, use the following command:

west build -p always -b nrf54l15dk/nrf54l15/cpuapp modules/lib/empub/examples/zephyr/app_demo

After flashing the board, the serial output should look like this:

*** Booting Zephyr OS build v4.2.0-5539-ga8677f5fc4f0 ***
--- Zephyr emPub Wearable Demo (Stack Allocated) ---
System Initialized. Starting sensor timer...

[EventDispatcher] Thread started.
[ProcessingEngine] Received raw data: HR=87, SpO2=99%
[DataSerializer] Received validated data, preparing packet...
[CommsManager] Transmitting 4 bytes: 0x01 0x57 0x02 0x63

[ProcessingEngine] Received raw data: HR=77, SpO2=99%
[DataSerializer] Received validated data, preparing packet...
[CommsManager] Transmitting 4 bytes: 0x01 0x4D 0x02 0x63
...

About

Pub/sub for embedded systems in modern C++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors