@@ -125,6 +125,7 @@ static socketpool_socket_obj_t active;
125125static _request active_request ;
126126
127127static char _api_password [64 ];
128+ static char web_instance_name [50 ];
128129
129130// Store the encoded IP so we don't duplicate work.
130131static uint32_t _encoded_ip = 0 ;
@@ -283,6 +284,11 @@ void supervisor_start_web_workflow(void) {
283284 return ;
284285 }
285286
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+
286292 if (!common_hal_wifi_radio_get_enabled (& common_hal_wifi_radio_obj )) {
287293 common_hal_wifi_init (false);
288294 common_hal_wifi_radio_set_enabled (& common_hal_wifi_radio_obj , true);
@@ -329,7 +335,7 @@ void supervisor_start_web_workflow(void) {
329335 mdns_server_construct (& mdns , true);
330336 mdns .base .type = & mdns_server_type ;
331337 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 );
333339 }
334340 }
335341 if (!common_hal_mdns_server_deinited (& mdns )) {
@@ -796,9 +802,11 @@ static void _reply_with_version_json(socketpool_socket_obj_t *socket, _request *
796802 mp_print_t _socket_print = {socket , _print_chunk };
797803
798804 const char * hostname = "" ;
805+ const char * instance_name = "" ;
799806 #if CIRCUITPY_MDNS
800807 if (!common_hal_mdns_server_deinited (& mdns )) {
801808 hostname = common_hal_mdns_server_get_hostname (& mdns );
809+ instance_name = common_hal_mdns_server_get_instance_name (& mdns );
802810 }
803811 #endif
804812 _update_encoded_ip ();
@@ -807,13 +815,13 @@ static void _reply_with_version_json(socketpool_socket_obj_t *socket, _request *
807815 "{\"web_api_version\": 2, "
808816 "\"version\": \"" MICROPY_GIT_TAG "\", "
809817 "\"build_date\": \"" MICROPY_BUILD_DATE "\", "
810- "\"board_name\": \"" MICROPY_HW_BOARD_NAME " \", "
818+ "\"board_name\": \"%s \", "
811819 "\"mcu_name\": \"" MICROPY_HW_MCU_NAME "\", "
812820 "\"board_id\": \"" CIRCUITPY_BOARD_ID "\", "
813821 "\"creator_id\": %u, "
814822 "\"creation_id\": %u, "
815823 "\"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 );
817825 #if CIRCUITPY_MICROCONTROLLER && COMMON_HAL_MCU_PROCESSOR_UID_LENGTH > 0
818826 uint8_t raw_id [COMMON_HAL_MCU_PROCESSOR_UID_LENGTH ];
819827 common_hal_mcu_processor_get_uid (raw_id );
0 commit comments