@@ -125,6 +125,7 @@ static socketpool_socket_obj_t active;
125
125
static _request active_request ;
126
126
127
127
static char _api_password [64 ];
128
+ static char web_instance_name [50 ];
128
129
129
130
// Store the encoded IP so we don't duplicate work.
130
131
static uint32_t _encoded_ip = 0 ;
@@ -283,6 +284,11 @@ void supervisor_start_web_workflow(void) {
283
284
return ;
284
285
}
285
286
287
+ result = common_hal_os_getenv_str ("CIRCUITPY_WEB_INSTANCE_NAME" , web_instance_name , sizeof (web_instance_name ));
288
+ if (result != GETENV_OK || web_instance_name [0 ] == '\0' ) {
289
+ strcpy (web_instance_name , MICROPY_HW_BOARD_NAME );
290
+ }
291
+
286
292
if (!common_hal_wifi_radio_get_enabled (& common_hal_wifi_radio_obj )) {
287
293
common_hal_wifi_init (false);
288
294
common_hal_wifi_radio_set_enabled (& common_hal_wifi_radio_obj , true);
@@ -329,7 +335,7 @@ void supervisor_start_web_workflow(void) {
329
335
mdns_server_construct (& mdns , true);
330
336
mdns .base .type = & mdns_server_type ;
331
337
if (!common_hal_mdns_server_deinited (& mdns )) {
332
- common_hal_mdns_server_set_instance_name (& mdns , MICROPY_HW_BOARD_NAME );
338
+ common_hal_mdns_server_set_instance_name (& mdns , web_instance_name );
333
339
}
334
340
}
335
341
if (!common_hal_mdns_server_deinited (& mdns )) {
@@ -796,9 +802,11 @@ static void _reply_with_version_json(socketpool_socket_obj_t *socket, _request *
796
802
mp_print_t _socket_print = {socket , _print_chunk };
797
803
798
804
const char * hostname = "" ;
805
+ const char * instance_name = "" ;
799
806
#if CIRCUITPY_MDNS
800
807
if (!common_hal_mdns_server_deinited (& mdns )) {
801
808
hostname = common_hal_mdns_server_get_hostname (& mdns );
809
+ instance_name = common_hal_mdns_server_get_instance_name (& mdns );
802
810
}
803
811
#endif
804
812
_update_encoded_ip ();
@@ -807,13 +815,13 @@ static void _reply_with_version_json(socketpool_socket_obj_t *socket, _request *
807
815
"{\"web_api_version\": 2, "
808
816
"\"version\": \"" MICROPY_GIT_TAG "\", "
809
817
"\"build_date\": \"" MICROPY_BUILD_DATE "\", "
810
- "\"board_name\": \"" MICROPY_HW_BOARD_NAME " \", "
818
+ "\"board_name\": \"%s \", "
811
819
"\"mcu_name\": \"" MICROPY_HW_MCU_NAME "\", "
812
820
"\"board_id\": \"" CIRCUITPY_BOARD_ID "\", "
813
821
"\"creator_id\": %u, "
814
822
"\"creation_id\": %u, "
815
823
"\"hostname\": \"%s\", "
816
- "\"port\": %d, " , CIRCUITPY_CREATOR_ID , CIRCUITPY_CREATION_ID , hostname , web_api_port , _our_ip_encoded );
824
+ "\"port\": %d, " , instance_name , CIRCUITPY_CREATOR_ID , CIRCUITPY_CREATION_ID , hostname , web_api_port , _our_ip_encoded );
817
825
#if CIRCUITPY_MICROCONTROLLER && COMMON_HAL_MCU_PROCESSOR_UID_LENGTH > 0
818
826
uint8_t raw_id [COMMON_HAL_MCU_PROCESSOR_UID_LENGTH ];
819
827
common_hal_mcu_processor_get_uid (raw_id );
0 commit comments