Skip to content

Commit 0b2528b

Browse files
authored
Merge pull request #6787 from Neradoc/nera-web-workflow
Add serial number to version.json (as UID)
2 parents d3e244b + dfd6fa2 commit 0b2528b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

supervisor/shared/web_workflow/web_workflow.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "shared-bindings/hashlib/Hash.h"
5050
#include "shared-bindings/mdns/RemoteService.h"
5151
#include "shared-bindings/mdns/Server.h"
52+
#include "shared-bindings/microcontroller/Processor.h"
5253
#include "shared-bindings/socketpool/__init__.h"
5354
#include "shared-bindings/socketpool/Socket.h"
5455
#include "shared-bindings/socketpool/SocketPool.h"
@@ -768,8 +769,17 @@ static void _reply_with_version_json(socketpool_socket_obj_t *socket, _request *
768769
"\"creator_id\": %u, "
769770
"\"creation_id\": %u, "
770771
"\"hostname\": \"%s\", "
771-
"\"port\": %d, "
772-
"\"ip\": \"%s\"}", CIRCUITPY_CREATOR_ID, CIRCUITPY_CREATION_ID, hostname, web_api_port, _our_ip_encoded);
772+
"\"port\": %d, ", CIRCUITPY_CREATOR_ID, CIRCUITPY_CREATION_ID, hostname, web_api_port, _our_ip_encoded);
773+
#if CIRCUITPY_MICROCONTROLLER && COMMON_HAL_MCU_PROCESSOR_UID_LENGTH > 0
774+
uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH];
775+
common_hal_mcu_processor_get_uid(raw_id);
776+
mp_printf(&_socket_print, "\"UID\": \"");
777+
for (uint8_t i = 0; i < COMMON_HAL_MCU_PROCESSOR_UID_LENGTH; i++) {
778+
mp_printf(&_socket_print, "%02X", raw_id[i]);
779+
}
780+
mp_printf(&_socket_print, "\", ");
781+
#endif
782+
mp_printf(&_socket_print, "\"ip\": \"%s\"}", _our_ip_encoded);
773783
// Empty chunk signals the end of the response.
774784
_send_chunk(socket, "");
775785
}

0 commit comments

Comments
 (0)