Merge pull request #7461 from tannewt/add_mdns_comments
Add comments for MDNS code
This commit is contained in:
commit
1c1cf1cf56
|
@ -33,14 +33,19 @@
|
||||||
|
|
||||||
#include "components/mdns/include/mdns.h"
|
#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) {
|
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;
|
self->inited = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mdns_init();
|
mdns_init();
|
||||||
|
mdns_started = true;
|
||||||
|
|
||||||
uint8_t mac[6];
|
uint8_t mac[6];
|
||||||
esp_netif_get_mac(common_hal_wifi_radio_obj.netif, mac);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
self->inited = false;
|
self->inited = false;
|
||||||
inited = false;
|
mdns_started = false;
|
||||||
mdns_free();
|
mdns_free();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ typedef struct {
|
||||||
mp_obj_base_t base;
|
mp_obj_base_t base;
|
||||||
const char *hostname;
|
const char *hostname;
|
||||||
const char *instance_name;
|
const char *instance_name;
|
||||||
// "cpy-" "XXXXXX" "\0"
|
char default_hostname[sizeof("cpy-XXXXXX")];
|
||||||
char default_hostname[4 + 6 + 1];
|
// Track if this object owns access to the underlying MDNS service.
|
||||||
bool inited;
|
bool inited;
|
||||||
} mdns_server_obj_t;
|
} mdns_server_obj_t;
|
||||||
|
|
|
@ -48,6 +48,7 @@ STATIC bool object_inited = false;
|
||||||
|
|
||||||
void mdns_server_construct(mdns_server_obj_t *self, bool workflow) {
|
void mdns_server_construct(mdns_server_obj_t *self, bool workflow) {
|
||||||
if (object_inited) {
|
if (object_inited) {
|
||||||
|
// Mark the object as deinit since another is already using MDNS.
|
||||||
self->inited = false;
|
self->inited = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,8 @@ typedef struct {
|
||||||
mp_obj_base_t base;
|
mp_obj_base_t base;
|
||||||
const char *hostname;
|
const char *hostname;
|
||||||
const char *instance_name;
|
const char *instance_name;
|
||||||
// "cpy-" "XXXXXX" "\0"
|
char default_hostname[sizeof("cpy-XXXXXX")];
|
||||||
char default_hostname[4 + 6 + 1];
|
|
||||||
const char *service_type[MDNS_MAX_SERVICES];
|
const char *service_type[MDNS_MAX_SERVICES];
|
||||||
|
// Track if this object owns access to the underlying MDNS service.
|
||||||
bool inited;
|
bool inited;
|
||||||
} mdns_server_obj_t;
|
} mdns_server_obj_t;
|
||||||
|
|
Loading…
Reference in New Issue