From 2c9c484d60d095a3e1b316ea911772fb0b6b9359 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Mon, 31 Oct 2022 11:34:14 +0100 Subject: add hostname to esp commands --- stm32f091/esp8266.c | 6 ++++++ stm32f091/esp8266.h | 2 ++ stm32f091/setup.c | 3 +++ 3 files changed, 11 insertions(+) diff --git a/stm32f091/esp8266.c b/stm32f091/esp8266.c index 8ff9547..e92149d 100644 --- a/stm32f091/esp8266.c +++ b/stm32f091/esp8266.c @@ -75,9 +75,11 @@ void ws_esp8266_ap_client_mode() { } void ws_esp8266_start_tcp_server() { + ws_esp8266_send_seq("AT+CIPSTATUS\r\n"); // show ip ws_esp8266_send_seq("AT+CIPSERVER=0\r\n"); // stop tcp server (if running) ws_esp8266_send_seq("AT+CIPMUX=1\r\n"); // enable multiplexing (allow multiple connections) ws_esp8266_send_seq("AT+CIPSERVER=1," WS_SERVER_PORT_STR "\r\n"); // start tcp server + ws_esp8266_send_seq("AT+CIPSTA?\r\n"); } void ws_esp8266_set_mac() { @@ -87,3 +89,7 @@ void ws_esp8266_set_mac() { void ws_esp8266_set_ip() { ws_esp8266_send_seq("AT+CIPSTA=\"" WS_ESP8266_WLAN_IP "\"\r\n"); } + +void ws_esp8266_set_hostname() { + ws_esp8266_send_seq("AT+CWHOSTNAME=\"" WS_ESP8266_WLAN_HOSTNAME "\"\r\n"); +} diff --git a/stm32f091/esp8266.h b/stm32f091/esp8266.h index 94a7356..3138bc7 100644 --- a/stm32f091/esp8266.h +++ b/stm32f091/esp8266.h @@ -36,3 +36,5 @@ void ws_esp8266_start_tcp_server(); void ws_esp8266_set_mac(); /** @brief set static ip address of the esp client */ void ws_esp8266_set_ip(); +/** @brief set hostname of the esp client */ +void ws_esp8266_set_hostname(); diff --git a/stm32f091/setup.c b/stm32f091/setup.c index 658e1bb..6fd0b73 100644 --- a/stm32f091/setup.c +++ b/stm32f091/setup.c @@ -101,6 +101,9 @@ void ws_io_setup() { #endif ws_esp8266_ap_client_mode(); +#ifdef WS_ESP8266_WLAN_HOSTNAME + ws_esp8266_set_hostname(); +#endif #ifdef WS_ESP8266_WLAN_MAC ws_esp8266_set_mac(); #endif -- cgit v1.2.3