Skip to content

Commit 02877a4

Browse files
donghengdongheng
authored andcommitted
feat(mdns_example): Sync code from esp-idf
Commit ID: 2f8508c7
1 parent 9a72ce0 commit 02877a4

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# The following five lines of boilerplate have to be in your project's
2-
# CMakeLists in this exact order for cmake to work correctly
1+
# The following lines of boilerplate have to be in your project's CMakeLists
2+
# in this exact order for cmake to work correctly
33
cmake_minimum_required(VERSION 3.5)
44

55
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
6-
project(mdns)
6+
project(mdns-test)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
set(COMPONENT_SRCS "mdns_example_main.c")
2+
set(COMPONENT_ADD_INCLUDEDIRS ".")
23

34
register_component()

examples/protocols/mdns/main/Kconfig.projbuild

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ config WIFI_SSID
88

99
config WIFI_PASSWORD
1010
string "WiFi Password"
11-
default "myssid"
11+
default "mypassword"
1212
help
1313
WiFi password (WPA or WPA2) for the example to use.
1414

@@ -26,4 +26,4 @@ config MDNS_INSTANCE
2626
help
2727
mDNS Instance Name for example to use
2828

29-
endmenu
29+
endmenu

examples/protocols/mdns/main/mdns_example_main.c

100755100644
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ static void mdns_print_results(mdns_result_t * results){
137137
if(r->txt_count){
138138
printf(" TXT : [%u] ", r->txt_count);
139139
for(t=0; t<r->txt_count; t++){
140-
printf("%s=%s; ", r->txt[t].key, r->txt[t].value);
140+
printf("%s=%s; ", r->txt[t].key, r->txt[t].value?r->txt[t].value:"NULL");
141141
}
142142
printf("\n");
143143
}
144144
a = r->addr;
145145
while(a){
146-
if(a->addr.type == MDNS_IP_PROTOCOL_V6){
146+
if(a->addr.type == IPADDR_TYPE_V6){
147147
printf(" AAAA: " IPV6STR "\n", IPV62STR(a->addr.u_addr.ip6));
148148
} else {
149149
printf(" A : " IPSTR "\n", IP2STR(&(a->addr.u_addr.ip4)));
@@ -162,7 +162,7 @@ static void query_mdns_service(const char * service_name, const char * proto)
162162
mdns_result_t * results = NULL;
163163
esp_err_t err = mdns_query_ptr(service_name, proto, 3000, 20, &results);
164164
if(err){
165-
ESP_LOGE(TAG, "Query Failed");
165+
ESP_LOGE(TAG, "Query Failed: %s", esp_err_to_name(err));
166166
return;
167167
}
168168
if(!results){
@@ -184,10 +184,10 @@ static void query_mdns_host(const char * host_name)
184184
esp_err_t err = mdns_query_a(host_name, 2000, &addr);
185185
if(err){
186186
if(err == ESP_ERR_NOT_FOUND){
187-
ESP_LOGW(TAG, "Host was not found!");
187+
ESP_LOGW(TAG, "%s: Host was not found!", esp_err_to_name(err));
188188
return;
189189
}
190-
ESP_LOGE(TAG, "Query Failed");
190+
ESP_LOGE(TAG, "Query Failed: %s", esp_err_to_name(err));
191191
return;
192192
}
193193

0 commit comments

Comments
 (0)