From 96f2358caadfd55d6fd3b888ef5d21f22fc2439c Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 20 Apr 2024 22:08:08 +0200 Subject: firmware: Add 64 bit MAC to shell prompt This demonstrates that the readout of the 64 bit MAC address from the STM32WL55 microcontroller works and is useful to recognize used devices. --- firmware/src/main.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'firmware/src/main.c') diff --git a/firmware/src/main.c b/firmware/src/main.c index 7a1076c..e1c85c6 100644 --- a/firmware/src/main.c +++ b/firmware/src/main.c @@ -1,6 +1,38 @@ +#include + #include +#include +#include + +#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; } -- cgit v1.2.3-70-g09d2