From dfd6fa2114853327320db89235888506aa6ecb17 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Sun, 21 Aug 2022 03:32:02 +0200 Subject: [PATCH] add serial number to version.json, UID like in boot_out.txt --- supervisor/shared/web_workflow/web_workflow.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/supervisor/shared/web_workflow/web_workflow.c b/supervisor/shared/web_workflow/web_workflow.c index 5d1cbe1c76..3f942b91d3 100644 --- a/supervisor/shared/web_workflow/web_workflow.c +++ b/supervisor/shared/web_workflow/web_workflow.c @@ -49,6 +49,7 @@ #include "shared-bindings/hashlib/Hash.h" #include "shared-bindings/mdns/RemoteService.h" #include "shared-bindings/mdns/Server.h" +#include "shared-bindings/microcontroller/Processor.h" #include "shared-bindings/socketpool/__init__.h" #include "shared-bindings/socketpool/Socket.h" #include "shared-bindings/socketpool/SocketPool.h" @@ -768,8 +769,17 @@ static void _reply_with_version_json(socketpool_socket_obj_t *socket, _request * "\"creator_id\": %u, " "\"creation_id\": %u, " "\"hostname\": \"%s\", " - "\"port\": %d, " - "\"ip\": \"%s\"}", CIRCUITPY_CREATOR_ID, CIRCUITPY_CREATION_ID, hostname, web_api_port, _our_ip_encoded); + "\"port\": %d, ", CIRCUITPY_CREATOR_ID, CIRCUITPY_CREATION_ID, hostname, web_api_port, _our_ip_encoded); + #if CIRCUITPY_MICROCONTROLLER && COMMON_HAL_MCU_PROCESSOR_UID_LENGTH > 0 + uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH]; + common_hal_mcu_processor_get_uid(raw_id); + mp_printf(&_socket_print, "\"UID\": \""); + for (uint8_t i = 0; i < COMMON_HAL_MCU_PROCESSOR_UID_LENGTH; i++) { + mp_printf(&_socket_print, "%02X", raw_id[i]); + } + mp_printf(&_socket_print, "\", "); + #endif + mp_printf(&_socket_print, "\"ip\": \"%s\"}", _our_ip_encoded); // Empty chunk signals the end of the response. _send_chunk(socket, ""); }