Skip to content

Commit 78cf0dd

Browse files
committed
Merge branch 'feature/sync_mdns_from_espidf' into 'master'
mdns: sync code from esp-idf See merge request sdk/ESP8266_RTOS_SDK!943
2 parents ff9d310 + 02877a4 commit 78cf0dd

File tree

13 files changed

+285
-86
lines changed

13 files changed

+285
-86
lines changed

components/esp8266/include/esp_event.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
#include "lwip/ip_addr.h"
2424
#include "tcpip_adapter.h"
2525

26+
#include "freertos/FreeRTOS.h"
27+
#include "freertos/task.h"
28+
#include "freertos/queue.h"
29+
#include "freertos/semphr.h"
30+
2631
#ifdef __cplusplus
2732
extern "C" {
2833
#endif

components/mdns/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
if(CONFIG_ENABLE_MDNS)
22
set(COMPONENT_SRCS "src/mdns.c"
3-
"src/mdns_console.c"
43
"src/mdns_networking.c")
54

65
set(COMPONENT_PRIV_INCLUDEDIRS "private_include")
@@ -9,5 +8,12 @@ endif()
98
set(COMPONENT_ADD_INCLUDEDIRS "include")
109
set(COMPONENT_REQUIRES "lwip" "ssl" "tcpip_adapter")
1110

11+
if(CONFIG_ENABLE_MDNS_CONSOLE)
12+
set(COMPONENT_SRCS "${COMPONENT_SRCS}"
13+
"src/mdns_console.c")
14+
endif()
15+
16+
set(COMPONENT_REQUIRES "console" "tcpip_adapter" "newlib")
17+
1218
register_component()
1319

components/mdns/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ config ENABLE_MDNS
77
help
88
Enable this option and then mDNS is to be used.
99

10+
config ENABLE_MDNS_CONSOLE
11+
bool "Enable mDNS console"
12+
default n
13+
depends on ENABLE_MDNS
14+
select USING_ESP_CONSOLE
15+
help
16+
Enable this option and then mDNS console is to be used.
17+
1018
config MDNS_MAX_SERVICES
1119
int "Max number of services"
1220
range 1 64

components/mdns/component.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ COMPONENT_PRIV_INCLUDEDIRS := private_include
44
ifdef CONFIG_ENABLE_MDNS
55
COMPONENT_SRCDIRS := src
66
endif
7+
8+
ifndef CONFIG_ENABLE_MDNS_CONSOLE
9+
COMPONENT_OBJEXCLUDE := src/mdns_console.o
10+
endif

components/mdns/private_include/mdns_networking.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* MDNS Server Networking -- private include
66
*
77
*/
8+
#include "mdns.h"
9+
810
#include "sdkconfig.h"
911
#include "freertos/FreeRTOS.h"
1012
#include "freertos/queue.h"
@@ -19,8 +21,7 @@
1921
#include "esp_system.h"
2022
#include "esp_timer.h"
2123
#include "esp_event_loop.h"
22-
#include "mdns.h"
23-
#include "mdns_private.h"
24+
2425

2526
/**
2627
* @brief Queue RX packet action

components/mdns/private_include/mdns_private.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
#ifndef MDNS_PRIVATE_H_
1515
#define MDNS_PRIVATE_H_
1616

17+
#include <stdint.h>
18+
#include <stdbool.h>
19+
#include "tcpip_adapter.h"
20+
#include "esp_timer.h"
21+
#include "mdns.h"
22+
1723
//#define MDNS_ENABLE_DEBUG
1824

1925
#ifdef MDNS_ENABLE_DEBUG
@@ -52,7 +58,7 @@
5258
#define MDNS_ANSWER_SDPTR 0x80
5359

5460
#define MDNS_SERVICE_PORT 5353 // UDP port that the server runs on
55-
#define MDNS_SERVICE_STACK_DEPTH CONFIG_MDNS_STACKSIZE // Stack size for the service thread
61+
#define MDNS_SERVICE_STACK_DEPTH 4096 // Stack size for the service thread
5662
#define MDNS_PACKET_QUEUE_LEN 16 // Maximum packets that can be queued for parsing
5763
#define MDNS_ACTION_QUEUE_LEN 16 // Maximum actions pending to the server
5864
#define MDNS_TXT_MAX_LEN 1024 // Maximum string length of text data in TXT record
@@ -115,9 +121,9 @@
115121
#define PCB_STATE_IS_ANNOUNCING(s) (s->state > PCB_PROBE_3 && s->state < PCB_RUNNING)
116122
#define PCB_STATE_IS_RUNNING(s) (s->state == PCB_RUNNING)
117123

118-
#define MDNS_SEARCH_LOCK() xSemaphoreTake(_mdns_server->search.lock, portMAX_DELAY)
119-
#define MDNS_SEARCH_UNLOCK() xSemaphoreGive(_mdns_server->search.lock)
120-
124+
#ifndef HOOK_MALLOC_FAILED
125+
#define HOOK_MALLOC_FAILED ESP_LOGE(TAG, "Cannot allocate memory (line: %d, free heap: %d bytes)", __LINE__, esp_get_free_heap_size());
126+
#endif
121127

122128
typedef enum {
123129
PCB_OFF, PCB_DUP, PCB_INIT,
@@ -289,6 +295,7 @@ typedef struct mdns_tx_packet_s {
289295
mdns_out_answer_t * answers;
290296
mdns_out_answer_t * servers;
291297
mdns_out_answer_t * additional;
298+
bool queued;
292299
} mdns_tx_packet_t;
293300

294301
typedef struct {
@@ -315,7 +322,7 @@ typedef struct mdns_search_once_s {
315322
uint32_t started_at;
316323
uint32_t sent_at;
317324
uint32_t timeout;
318-
SemaphoreHandle_t lock;
325+
SemaphoreHandle_t done_semaphore;
319326
uint16_t type;
320327
uint8_t max_results;
321328
uint8_t num_results;

0 commit comments

Comments
 (0)