0
0
Fork 0

feat(mDNS): Add mDNS server

This commit is contained in:
windowsair 2022-01-16 20:12:42 +08:00
parent 5ab0a62cd3
commit faefa979dd
10 changed files with 57 additions and 3 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
.vscode/
build/
tmp/
.history/
.history/
sdkconfig.old

3
.gitmodules vendored
View File

@ -1,3 +1,6 @@
[submodule "ESP8266_RTOS_SDK"]
path = ESP8266_RTOS_SDK
url = https://github.com/espressif/ESP8266_RTOS_SDK
[submodule "components/corsacOTA"]
path = components/corsacOTA
url = https://github.com/windowsair/corsacOTA.git

View File

@ -1,4 +1,6 @@
cmake_minimum_required(VERSION 3.5)
# Colored Compiler Output with ninja
add_compile_options (-fdiagnostics-color=always)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})

@ -1 +1 @@
Subproject commit 1be2289fcd68672f5d6bf6aafa4f4b57b20527a4
Subproject commit a7677d6d678dcbb74f4f9162123fe4462676b590

View File

@ -52,6 +52,13 @@ You can also specify your IP in the above file (We recommend using the static ad
![WIFI](https://user-images.githubusercontent.com/17078589/118365659-517e7880-b5d0-11eb-9a5b-afe43348c2ba.png)
There is built-in ipv4 only mDNS server. You can access the device using `dap.local` .
![mDNS](https://user-images.githubusercontent.com/17078589/149659052-7b29533f-9660-4811-8125-f8f50490d762.png)
### Debugger

1
components/corsacOTA Submodule

@ -0,0 +1 @@
Subproject commit 98e9ffeb3b08e91743b147cf292dfd76259fc380

View File

@ -31,6 +31,7 @@
#include "lwip/sys.h"
#include <lwip/netdb.h>
#include "mdns.h"
extern void DAP_Setup(void);
extern void DAP_Thread(void *argument);
@ -149,6 +150,35 @@ static void wait_for_ip()
}
static const char *MDNS_TAG = "server_common";
void mdns_setup() {
// initialize mDNS
int ret;
ret = mdns_init();
if (ret != ESP_OK) {
ESP_LOGW(MDNS_TAG, "mDNS initialize failed:%d", ret);
return;
}
// set mDNS hostname
ret = mdns_hostname_set(MDNS_HOSTNAME);
if (ret != ESP_OK) {
ESP_LOGW(MDNS_TAG, "mDNS set hostname failed:%d", ret);
return;
}
ESP_LOGI(MDNS_TAG, "mDNS hostname set to: [%s]", MDNS_HOSTNAME);
// set default mDNS instance name
ret = mdns_instance_name_set(MDNS_INSTANCE);
if (ret != ESP_OK) {
ESP_LOGW(MDNS_TAG, "mDNS set instance name failed:%d", ret);
return;
}
ESP_LOGI(MDNS_TAG, "mDNS instance name set to: [%s]", MDNS_INSTANCE);
}
void app_main()
{
// struct rst_info *rtc_info = system_get_rst_info();
@ -174,6 +204,9 @@ void app_main()
DAP_Setup();
timer_init();
#if (USE_MDNS == 1)
mdns_setup();
#endif
// Specify the usbip server task
#if (USE_KCP == 1)
xTaskCreate(kcp_server_task, "kcp_server", 4096, NULL, 7, NULL);

0
main/uart_bridge.c Normal file
View File

View File

@ -14,6 +14,11 @@
#define WIFI_PASS "12345678"
#define USE_MDNS 1
// Use the address "dap.local" to access the device
#define MDNS_HOSTNAME "dap"
#define MDNS_INSTANCE "DAP mDNS"
#define USE_STATIC_IP 1
// If you don't want to specify the ip configuration, then ignore the following items.
#define DAP_IP_ADDRESS 192, 168, 137, 123

View File

@ -384,7 +384,9 @@ CONFIG_ESP_SHA=y
CONFIG_ESP_AES=y
CONFIG_ESP_MD5=y
CONFIG_ESP_ARC4=y
# CONFIG_ENABLE_MDNS is not set
CONFIG_ENABLE_MDNS=y
# CONFIG_ENABLE_MDNS_CONSOLE is not set
CONFIG_MDNS_MAX_SERVICES=1
CONFIG_MQTT_PROTOCOL_311=y
CONFIG_MQTT_TRANSPORT_SSL=y
CONFIG_MQTT_TRANSPORT_WEBSOCKET=y