summaryrefslogtreecommitdiff
path: root/firmware/src/main.c
blob: e1c85c61286f9f24e3871536964acceff998398d (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
35
36
37
38
#include <stdio.h>

#include <zephyr/kernel.h>
#include <zephyr/shell/shell.h>
#include <zephyr/shell/shell_backend.h>

#include "uid64.h"

static uint64_t uid = 0;
static char uid_str[UID64_STR_LEN];

#define MAX_PROMPT_SIZE 80
char prompt[MAX_PROMPT_SIZE];

void init_uid64(void) {
	uid = uid64_get();
	uid64_to_string(uid, uid_str);
}

void init_shell_prompt(void) {
	if (uid64_available()) {
		snprintf(prompt, MAX_PROMPT_SIZE, "[iot-core %s] ", uid_str);
	} else {
		strncpy(prompt, "[iot-core without MAC] ", MAX_PROMPT_SIZE);
	}
	for (int i = 0; i < shell_backend_count_get(); i++) {
		const struct shell *sh = shell_backend_get(i);
		(void) shell_prompt_change(sh, (const char *)prompt);
	}
}

int main(void)
{
	init_uid64();
	init_shell_prompt();

	return 0;
}