Merge pull request #7461 from tannewt/add_mdns_comments

Add comments for MDNS code
This commit is contained in:
Scott Shawcroft 2023-01-17 16:19:08 -08:00 committed by GitHub
commit 1c1cf1cf56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 7 deletions

View File

@ -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();
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;