feat(mDNS): Add mDNS server
This commit is contained in:
parent
5ab0a62cd3
commit
faefa979dd
|
@ -1,4 +1,5 @@
|
||||||
.vscode/
|
.vscode/
|
||||||
build/
|
build/
|
||||||
tmp/
|
tmp/
|
||||||
.history/
|
.history/
|
||||||
|
sdkconfig.old
|
|
@ -1,3 +1,6 @@
|
||||||
[submodule "ESP8266_RTOS_SDK"]
|
[submodule "ESP8266_RTOS_SDK"]
|
||||||
path = ESP8266_RTOS_SDK
|
path = ESP8266_RTOS_SDK
|
||||||
url = https://github.com/espressif/ESP8266_RTOS_SDK
|
url = https://github.com/espressif/ESP8266_RTOS_SDK
|
||||||
|
[submodule "components/corsacOTA"]
|
||||||
|
path = components/corsacOTA
|
||||||
|
url = https://github.com/windowsair/corsacOTA.git
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
# Colored Compiler Output with ninja
|
||||||
|
add_compile_options (-fdiagnostics-color=always)
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1be2289fcd68672f5d6bf6aafa4f4b57b20527a4
|
Subproject commit a7677d6d678dcbb74f4f9162123fe4462676b590
|
|
@ -52,6 +52,13 @@ You can also specify your IP in the above file (We recommend using the static ad
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
There is built-in ipv4 only mDNS server. You can access the device using `dap.local` .
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Debugger
|
### Debugger
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 98e9ffeb3b08e91743b147cf292dfd76259fc380
|
33
main/main.c
33
main/main.c
|
@ -31,6 +31,7 @@
|
||||||
#include "lwip/sys.h"
|
#include "lwip/sys.h"
|
||||||
#include <lwip/netdb.h>
|
#include <lwip/netdb.h>
|
||||||
|
|
||||||
|
#include "mdns.h"
|
||||||
|
|
||||||
extern void DAP_Setup(void);
|
extern void DAP_Setup(void);
|
||||||
extern void DAP_Thread(void *argument);
|
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()
|
void app_main()
|
||||||
{
|
{
|
||||||
// struct rst_info *rtc_info = system_get_rst_info();
|
// struct rst_info *rtc_info = system_get_rst_info();
|
||||||
|
@ -174,6 +204,9 @@ void app_main()
|
||||||
DAP_Setup();
|
DAP_Setup();
|
||||||
timer_init();
|
timer_init();
|
||||||
|
|
||||||
|
#if (USE_MDNS == 1)
|
||||||
|
mdns_setup();
|
||||||
|
#endif
|
||||||
// Specify the usbip server task
|
// Specify the usbip server task
|
||||||
#if (USE_KCP == 1)
|
#if (USE_KCP == 1)
|
||||||
xTaskCreate(kcp_server_task, "kcp_server", 4096, NULL, 7, NULL);
|
xTaskCreate(kcp_server_task, "kcp_server", 4096, NULL, 7, NULL);
|
||||||
|
|
|
@ -14,6 +14,11 @@
|
||||||
#define WIFI_PASS "12345678"
|
#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
|
#define USE_STATIC_IP 1
|
||||||
// If you don't want to specify the ip configuration, then ignore the following items.
|
// If you don't want to specify the ip configuration, then ignore the following items.
|
||||||
#define DAP_IP_ADDRESS 192, 168, 137, 123
|
#define DAP_IP_ADDRESS 192, 168, 137, 123
|
||||||
|
|
|
@ -384,7 +384,9 @@ CONFIG_ESP_SHA=y
|
||||||
CONFIG_ESP_AES=y
|
CONFIG_ESP_AES=y
|
||||||
CONFIG_ESP_MD5=y
|
CONFIG_ESP_MD5=y
|
||||||
CONFIG_ESP_ARC4=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_PROTOCOL_311=y
|
||||||
CONFIG_MQTT_TRANSPORT_SSL=y
|
CONFIG_MQTT_TRANSPORT_SSL=y
|
||||||
CONFIG_MQTT_TRANSPORT_WEBSOCKET=y
|
CONFIG_MQTT_TRANSPORT_WEBSOCKET=y
|
||||||
|
|
Loading…
Reference in New Issue