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_CHAN_DECLARE(sensor_data_chan);
12
peripheral_thread(void)13 void peripheral_thread(void)
14 {
15 struct sensor_msg sm = {0};
16
17 while (1) {
18 LOG_DBG("Sending sensor data...");
19
20 sm.press += 1;
21 sm.temp += 10;
22 sm.humidity += 100;
23
24 zbus_chan_pub(&sensor_data_chan, &sm, K_MSEC(250));
25
26 k_msleep(500);
27 }
28 }
29
30 K_THREAD_DEFINE(peripheral_thread_id, 1024, peripheral_thread, NULL, NULL, NULL, 5, 0, 0);
31