1.. zephyr:code-sample:: zbus-runtime-obs-registration 2 :name: Runtime observer registration 3 :relevant-api: zbus_apis 4 5 Use zbus' runtime observer registration to filter data generated by a producer. 6 7Overview 8******** 9The sample illustrates a way of using the runtime observer registration feature. The developer can understand how to use static and runtime observer registration with this sample. 10 11In this sample, we have the threads producer and consumer. In the middle of the communication, we have the filter responsible for filtering the data generated by the producer. In a loop, the code activates the filter. After 5 seconds, the filter is disabled, and the filter bypass is enabled. At last, 5 seconds later, the filter bypass is disabled, and the loop repeats everything. 12 13Building and Running 14******************** 15 16This project outputs to the console. It can be built and executed 17on QEMU as follows: 18 19.. zephyr-app-commands:: 20 :zephyr-app: samples/subsys/zbus/runtime_obs_registration 21 :host-os: unix 22 :board: qemu_x86 23 :goals: run 24 25Sample Output 26============= 27 28.. code-block:: console 29 30 I: System started 31 I: Activating filter 32 I: >-- Raw data fetched 33 I: -|- Filtering data 34 I: --> Consuming data: Acc x=0, y=0, z=0 35 I: >-- Raw data fetched 36 I: -|- Filtering data 37 I: --> Consuming data: Acc x=2, y=2, z=2 38 I: >-- Raw data fetched 39 I: -|- Filtering data 40 I: --> Consuming data: Acc x=0, y=0, z=0 41 I: >-- Raw data fetched 42 I: -|- Filtering data 43 I: --> Consuming data: Acc x=4, y=4, z=4 44 I: >-- Raw data fetched 45 I: -|- Filtering data 46 I: --> Consuming data: Acc x=0, y=0, z=0 47 I: Deactivating filter 48 I: Bypass filter 49 I: >-- Raw data fetched 50 I: --> Consuming data: Acc x=6, y=6, z=6 51 I: >-- Raw data fetched 52 I: --> Consuming data: Acc x=7, y=7, z=7 53 I: >-- Raw data fetched 54 I: --> Consuming data: Acc x=8, y=8, z=8 55 I: >-- Raw data fetched 56 I: --> Consuming data: Acc x=9, y=9, z=9 57 I: >-- Raw data fetched 58 I: --> Consuming data: Acc x=10, y=10, z=10 59 I: Disable bypass filter 60 I: >-- Raw data fetched 61 I: >-- Raw data fetched 62 I: >-- Raw data fetched 63 I: >-- Raw data fetched 64 I: >-- Raw data fetched 65 66 <continues> 67 68Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`. 69