I'm currently facing a problem with setting a hostname for the ESP8266. My STM32 is connected to the ESP over Uart and the connection is working. So I'm able so set up a Acccess Point or connect to a Wifi by using AT-commands. Problem is that i always need to figure out my IP and put the IP in the browser which is uncomftable.
I spent the last days to solve this issue and looked in some Arduino/ESP librarys without any success.
In the code there are some lines commented out whith some AT-commands I tried to use. But those weren't working or had issues. The reply of the ESP I put behind the command
...some other code
Uart_sendstring("AT+RST\r\n", wifi_uart);
for (int i=0; i<5; i++)
{
HAL_Delay(1000);
}
/********* AT **********/
Uart_flush(wifi_uart);
Uart_sendstring("AT\r\nAT\r\n", wifi_uart);
while(!(Wait_for("OK\r\n", wifi_uart)));
Uart_flush(wifi_uart);
if (AP == CONNECT_AP)
{
//test
Uart_flush(wifi_uart);
//Uart_sendstring("AT+MDNS=1, my_test, iot, 80\r\n", wifi_uart); ->reply: get hostname fail when mdns
//Uart_sendstring("AT+CWHOSTNAME=my_test\r\n", wifi_uart); -> reply: ERROR
//Uart_sendstring("AT+CWHOSTNAME?\r\n", wifi_uart); -> reply: ERROR
while (!(Wait_for("OK\r\n", wifi_uart)));
//test end
/********* AT+CWMODE=1 **********/
Uart_flush(wifi_uart);
Uart_sendstring("AT+CWMODE=1\r\n", wifi_uart); // connect to AP
while (!(Wait_for("OK\r\n", wifi_uart)));
/********* AT+CWJAP="SSID","PASSWD" **********/
Uart_flush(wifi_uart);
sprintf (data, "AT+CWJAP=\"%s\",\"%s\"\r\n", SSID, PASSWD);
Uart_sendstring(data, wifi_uart);
while (!(Wait_for("OK\r\n", wifi_uart)));
/********* AT+CIFSR **********/
// Zum Anzeigen von IP und Mac-Adresse
Uart_flush(wifi_uart);
Uart_sendstring("AT+CIFSR\r\n", wifi_uart);
while (!(Wait_for("CIFSR:STAIP,\"", wifi_uart)));
while (!(Copy_upto("\"",My_IP, wifi_uart)));
while (!(Wait_for("OK\r\n", wifi_uart)));
}
else if (AP == OPEN_AP)
{
//test
Uart_flush(wifi_uart);
//Uart_sendstring("AT+MDNS=1, my_test, iot, 80\r\n", wifi_uart);
//Uart_sendstring("AT+CWHOSTNAME=my_test\r\n", wifi_uart);
//Uart_sendstring("AT+CWHOSTNAME?\r\n", wifi_uart);
while (!(Wait_for("OK\r\n", wifi_uart)));
//end test
/********* AT+CWMODE=2 **********/
Uart_flush(wifi_uart);
Uart_sendstring("AT+CWMODE=2\r\n", wifi_uart); // open AP
while (!(Wait_for("OK\r\n", wifi_uart)));
/********* AT+CWJAP="SSID","PASSWD" **********/
Uart_flush(wifi_uart);
sprintf (data, "AT+CWSAP=\"%s\",\"%s\",%d,%d\r\n", SSID, PASSWD, 11, 3);
Uart_sendstring(data, wifi_uart);
while (!(Wait_for("OK\r\n", wifi_uart)));
}
/********* AT+CIPMUX **********/
Uart_flush(wifi_uart);
Uart_sendstring("AT+CIPMUX=1\r\n", wifi_uart);
while (!(Wait_for("OK\r\n", wifi_uart)));
/********* AT+CIPSERVER **********/
Uart_flush(wifi_uart);
Uart_sendstring("AT+CIPSERVER=1,80\r\n", wifi_uart);
while (!(Wait_for("OK\r\n", wifi_uart)));
I would be very thankful if someone could help me solving this problem.
I'm not very deep in the mdns topic and setting up a Access Point. I'm just trying to open a Website to connect.
Best regards Max