File tree Expand file tree Collapse file tree 4 files changed +13
-7
lines changed
espressif/common-hal/mdns
raspberrypi/common-hal/mdns Expand file tree Collapse file tree 4 files changed +13
-7
lines changed Original file line number Diff line number Diff line change 33
33
34
34
#include "components/mdns/include/mdns.h"
35
35
36
- STATIC bool inited = false;
36
+ // Track whether the underlying IDF mdns has been started so that we only
37
+ // create a single inited MDNS object to CircuitPython. (After deinit, another
38
+ // could be created.)
39
+ STATIC bool mdns_started = false;
37
40
38
41
void mdns_server_construct (mdns_server_obj_t * self , bool workflow ) {
39
- if (inited ) {
42
+ if (mdns_started ) {
43
+ // Mark this object as deinited because another is already using MDNS.
40
44
self -> inited = false;
41
45
return ;
42
46
}
43
47
mdns_init ();
48
+ mdns_started = true;
44
49
45
50
uint8_t mac [6 ];
46
51
esp_netif_get_mac (common_hal_wifi_radio_obj .netif , mac );
@@ -81,7 +86,7 @@ void common_hal_mdns_server_deinit(mdns_server_obj_t *self) {
81
86
return ;
82
87
}
83
88
self -> inited = false;
84
- inited = false;
89
+ mdns_started = false;
85
90
mdns_free ();
86
91
}
87
92
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ typedef struct {
32
32
mp_obj_base_t base ;
33
33
const char * hostname ;
34
34
const char * instance_name ;
35
- // "cpy-" " XXXXXX" "\0"
36
- char default_hostname [ 4 + 6 + 1 ];
35
+ char default_hostname [ sizeof ( "cpy-XXXXXX" )];
36
+ // Track if this object owns access to the underlying MDNS service.
37
37
bool inited ;
38
38
} mdns_server_obj_t ;
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ STATIC bool object_inited = false;
48
48
49
49
void mdns_server_construct (mdns_server_obj_t * self , bool workflow ) {
50
50
if (object_inited ) {
51
+ // Mark the object as deinit since another is already using MDNS.
51
52
self -> inited = false;
52
53
return ;
53
54
}
Original file line number Diff line number Diff line change @@ -34,8 +34,8 @@ typedef struct {
34
34
mp_obj_base_t base ;
35
35
const char * hostname ;
36
36
const char * instance_name ;
37
- // "cpy-" "XXXXXX" "\0"
38
- char default_hostname [4 + 6 + 1 ];
37
+ char default_hostname [sizeof ("cpy-XXXXXX" )];
39
38
const char * service_type [MDNS_MAX_SERVICES ];
39
+ // Track if this object owns access to the underlying MDNS service.
40
40
bool inited ;
41
41
} mdns_server_obj_t ;
You can’t perform that action at this time.
0 commit comments