summaryrefslogtreecommitdiff
path: root/firmware/src/main.c
blob: e18cc77bb0f93e87fb63a58d27e6c83f6002e58e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdbool.h>

#include <zephyr/device.h>
#include <zephyr/drivers/uart.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/util.h>

#include "eui64.h"
#include "data_link.h"

#define UART_DEVICE_NODE DT_CHOSEN(zephyr_shell_uart)
static const struct device *const uart_dev = DEVICE_DT_GET(UART_DEVICE_NODE);

int main(void)
{
	if (!device_is_ready(uart_dev)) {
		printk("UART device not found");
		return 0;
	}

	if (!eui64_available()) {
		printk("No EUI-64 address available");
		return 0;
	}

	uint8_t payload[] = {0xDE, DL_SLIP_END, DL_SLIP_ESC, 0xAD};

	while (true) {
		k_sleep(K_MSEC(1000));
		dl_send_frame(uart_dev, payload, ARRAY_SIZE(payload));
	}

	return 0;
}