Skip to content

Commit ca80f30

Browse files
committed
Share the web workflow MDNS object with the user
Fixes #7369
1 parent 75241c4 commit ca80f30

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

shared-bindings/mdns/Server.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
#include "shared-bindings/mdns/Server.h"
3434
#include "shared-bindings/util.h"
3535

36+
#if CIRCUITPY_WEB_WORKFLOW
37+
#include "supervisor/shared/web_workflow/web_workflow.h"
38+
#endif
39+
3640
//| class Server:
3741
//| """The MDNS Server responds to queries for this device's information and allows for querying
3842
//| other devices."""
@@ -53,6 +57,13 @@ STATIC mp_obj_t mdns_server_make_new(const mp_obj_type_t *type, size_t n_args, s
5357
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
5458
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
5559

60+
#if CIRCUITPY_WEB_WORKFLOW
61+
mdns_server_obj_t *web_workflow_mdns = supervisor_web_workflow_mdns(args[ARG_network_interface].u_obj);
62+
if (web_workflow_mdns != NULL) {
63+
return web_workflow_mdns;
64+
}
65+
#endif
66+
5667
mdns_server_obj_t *self = m_new_obj(mdns_server_obj_t);
5768
self->base.type = &mdns_server_type;
5869
common_hal_mdns_server_construct(self, args[ARG_network_interface].u_obj);

supervisor/shared/web_workflow/web_workflow.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,15 @@ STATIC void _update_encoded_ip(void) {
200200
}
201201
}
202202

203+
mdns_server_obj_t *supervisor_web_workflow_mdns(mp_obj_t network_interface) {
204+
#if CIRCUITPY_MDNS
205+
if (network_interface == &common_hal_wifi_radio_obj) {
206+
return &mdns;
207+
}
208+
#endif
209+
return NULL;
210+
}
211+
203212
#if CIRCUITPY_STATUS_BAR
204213
bool supervisor_web_workflow_status_dirty(void) {
205214
return common_hal_wifi_radio_get_enabled(&common_hal_wifi_radio_obj) != _last_enabled ||

supervisor/shared/web_workflow/web_workflow.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include <stdbool.h>
3030

31+
#include "shared-bindings/mdns/Server.h"
3132
#include "shared-bindings/socketpool/Socket.h"
3233

3334
// This background function should be called repeatedly. It cannot be done based
@@ -38,5 +39,8 @@ void supervisor_web_workflow_status(void);
3839
void supervisor_start_web_workflow(void);
3940
void supervisor_stop_web_workflow(void);
4041

42+
// Share the MDNS object with user code.
43+
mdns_server_obj_t *supervisor_web_workflow_mdns(mp_obj_t network_interface);
44+
4145
// To share with websocket.
4246
void web_workflow_send_raw(socketpool_socket_obj_t *socket, const uint8_t *buf, int len);

0 commit comments

Comments
 (0)