1 /*
2 * Copyright (c) 2022 Rodrigo Peixoto <rodrigopex@gmail.com>
3 * SPDX-License-Identifier: Apache-2.0
4 */
5 #include "messages.h"
6
7 #include <zephyr/logging/log.h>
8 #include <zephyr/zbus/zbus.h>
9 LOG_MODULE_DECLARE(zbus, CONFIG_ZBUS_LOG_LEVEL);
10
11 ZBUS_SUBSCRIBER_DEFINE(consumer_sub, 4);
12
consumer_subscriber_thread(void)13 static void consumer_subscriber_thread(void)
14 {
15 const struct zbus_channel *chan;
16
17 while (!zbus_sub_wait(&consumer_sub, &chan, K_FOREVER)) {
18 struct sensor_msg acc;
19
20 zbus_chan_read(chan, &acc, K_MSEC(500));
21 LOG_INF(" --> Consuming data: Acc x=%d, y=%d, z=%d", acc.x, acc.y, acc.z);
22 }
23 }
24
25 K_THREAD_DEFINE(consumer_thread_id, 1024, consumer_subscriber_thread, NULL, NULL, NULL, 3, 0, 0);
26