Add comments for MDNS code
This commit is contained in:
parent
79b76f7bea
commit
683e393878
|
@ -33,14 +33,19 @@
|
|||
|
||||
#include "components/mdns/include/mdns.h"
|
||||
|
||||
STATIC bool inited = false;
|
||||
// Track whether the underlying IDF mdns has been started so that we only
|
||||
// create a single inited MDNS object to CircuitPython. (After deinit, another
|
||||
// could be created.)
|
||||
STATIC bool mdns_started = false;
|
||||
|
||||
void mdns_server_construct(mdns_server_obj_t *self, bool workflow) {
|
||||
if (inited) {
|
||||
if (mdns_started) {
|
||||
// Mark this object as deinited because another is already using MDNS.
|
||||
self->inited = false;
|
||||
return;
|
||||
}
|
||||
mdns_init();
|
||||
mdns_started = true;
|
||||
|
||||
uint8_t mac[6];
|
||||
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) {
|
|||
return;
|
||||
}
|
||||
self->inited = false;
|
||||
inited = false;
|
||||
mdns_started = false;
|
||||
mdns_free();
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ typedef struct {
|
|||
mp_obj_base_t base;
|
||||
const char *hostname;
|
||||
const char *instance_name;
|
||||
// "cpy-" "XXXXXX" "\0"
|
||||
char default_hostname[4 + 6 + 1];
|
||||
char default_hostname[sizeof("cpy-XXXXXX")];
|
||||
// Track if this object owns access to the underlying MDNS service.
|
||||
bool inited;
|
||||
} mdns_server_obj_t;
|
||||
|
|
|
@ -48,6 +48,7 @@ STATIC bool object_inited = false;
|
|||
|
||||
void mdns_server_construct(mdns_server_obj_t *self, bool workflow) {
|
||||
if (object_inited) {
|
||||
// Mark the object as deinit since another is already using MDNS.
|
||||
self->inited = false;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ typedef struct {
|
|||
mp_obj_base_t base;
|
||||
const char *hostname;
|
||||
const char *instance_name;
|
||||
// "cpy-" "XXXXXX" "\0"
|
||||
char default_hostname[4 + 6 + 1];
|
||||
char default_hostname[sizeof("cpy-XXXXXX")];
|
||||
const char *service_type[MDNS_MAX_SERVICES];
|
||||
// Track if this object owns access to the underlying MDNS service.
|
||||
bool inited;
|
||||
} mdns_server_obj_t;
|
||||
|
|
Loading…
Reference in New Issue