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(start_measurement_chan);
12
13 ZBUS_CHAN_DEFINE(version_chan, /* Name */
14 struct version_msg, /* Message type */
15
16 NULL, /* Validator */
17 NULL, /* User data */
18 ZBUS_OBSERVERS_EMPTY, /* observers */
19 ZBUS_MSG_INIT(.major = 0, .minor = 1,
20 .build = 1023) /* Initial value major 0, minor 1, build 1023 */
21 );
22
core_thread(void)23 static void core_thread(void)
24 {
25 struct action_msg start = {false};
26
27 while (1) {
28 LOG_DBG("Core sending start measurement with status %d", start.status);
29
30 start.status = !start.status;
31 zbus_chan_pub(&start_measurement_chan, &start, K_MSEC(500));
32
33 k_msleep(1000);
34 }
35 }
36
37 K_THREAD_DEFINE(core_thread_id, 1024, core_thread, NULL, NULL, NULL, 3, 0, 0);
38