From 84c72863e12b634d68bec585552af816a978d16e Mon Sep 17 00:00:00 2001 From: suda-morris <362953310@qq.com> Date: Mon, 14 Oct 2019 13:41:46 +0800 Subject: [PATCH] add netbios support in restful server example --- components/lwip/CMakeLists.txt | 1 + components/lwip/component.mk | 1 + examples/protocols/http_server/restful_server/README.md | 2 ++ .../http_server/restful_server/main/esp_rest_main.c | 5 ++++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/components/lwip/CMakeLists.txt b/components/lwip/CMakeLists.txt index 81e8f15055..3024c65d4a 100644 --- a/components/lwip/CMakeLists.txt +++ b/components/lwip/CMakeLists.txt @@ -20,6 +20,7 @@ set(srcs "lwip/src/api/sockets.c" "lwip/src/api/tcpip.c" "lwip/src/apps/sntp/sntp.c" + "lwip/src/apps/netbiosns/netbiosns.c" "lwip/src/core/def.c" "lwip/src/core/dns.c" "lwip/src/core/inet_chksum.c" diff --git a/components/lwip/component.mk b/components/lwip/component.mk index a92b888693..bea9d738f0 100644 --- a/components/lwip/component.mk +++ b/components/lwip/component.mk @@ -16,6 +16,7 @@ COMPONENT_SRCDIRS := \ apps/sntp \ lwip/src/api \ lwip/src/apps/sntp \ + lwip/src/apps/netbiosns \ lwip/src/core \ lwip/src/core/ipv4 \ lwip/src/core/ipv6 \ diff --git a/examples/protocols/http_server/restful_server/README.md b/examples/protocols/http_server/restful_server/README.md index 9923d4232c..84808ae2ec 100644 --- a/examples/protocols/http_server/restful_server/README.md +++ b/examples/protocols/http_server/restful_server/README.md @@ -108,6 +108,8 @@ openocd-esp32/bin/openocd -s openocd-esp32/share/openocd/scripts -f interface/ft In your browser, enter the URL where the website located (e.g. `http://esp-home.local`). You can also enter the IP address that ESP32 obtained if your operating system currently don't have support for mDNS service. +Besides that, this example also enables the NetBIOS feature with the domain name `esp-home`. If your OS supports NetBIOS and has enabled it (e.g. Windows has native support for NetBIOS), then the URL `http://esp-home` should also work. + ![esp_home_local](https://dl.espressif.com/dl/esp-idf/docs/_static/esp_home_local.gif) ### ESP monitor output diff --git a/examples/protocols/http_server/restful_server/main/esp_rest_main.c b/examples/protocols/http_server/restful_server/main/esp_rest_main.c index c82711ca4b..0f03f65a0f 100644 --- a/examples/protocols/http_server/restful_server/main/esp_rest_main.c +++ b/examples/protocols/http_server/restful_server/main/esp_rest_main.c @@ -6,6 +6,7 @@ software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +#include "sdkconfig.h" #include "driver/sdmmc_host.h" #include "driver/gpio.h" #include "esp_vfs_semihost.h" @@ -17,8 +18,8 @@ #include "esp_event.h" #include "esp_log.h" #include "mdns.h" +#include "lwip/apps/netbiosns.h" #include "protocol_examples_common.h" -#include "sdkconfig.h" #define MDNS_INSTANCE "esp home web server" @@ -126,6 +127,8 @@ void app_main(void) tcpip_adapter_init(); ESP_ERROR_CHECK(esp_event_loop_create_default()); initialise_mdns(); + netbiosns_init(); + netbiosns_set_name(CONFIG_EXAMPLE_MDNS_HOST_NAME); ESP_ERROR_CHECK(example_connect()); ESP_ERROR_CHECK(init_fs()); -- 2.40.0