I'm using Arduino IDE 1.6 nightly with Generic ESP8266 Board.
Why this code runs in mesh mode instead of simply connecting to my wifi? My goal is to test out MDNS, but so far I found this:
- board connects to my wifi
- but board also opens an
ESP-
access point - when connected to my wifi on my computer I cannot resolve http://esp8266-webupdate.local/update
- when connected to the open
ESP-
wifi I can resolve http://esp8266-webupdate.local/update
To my understanding such code should just connect to my wifi and I would then be able to navigate to http://esp8266-webupdate.local/update, am I missing something?
output (note STA+AP)
Booting Sketch...
......
Connected, IP address: 192.168.1.20
Mode: STA+AP
PHY mode: N
Channel: 10
AP id: 0
Status: 5
Auto connect: 1
code
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <ESP8266HTTPUpdateServer.h>
const char* host = "esp8266-webupdate";
const char* ssid = "myhomeap";
const char* password = "blabla";
ESP8266WebServer httpServer(80);
ESP8266HTTPUpdateServer httpUpdater;
void setup(void){
Serial.begin(115200);
Serial.println();
Serial.println("Booting Sketch...");
WiFi.mode(WIFI_AP_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.print("Connected, IP address: ");
Serial.println(WiFi.localIP());
WiFi.printDiag(Serial);
MDNS.begin(host);
httpUpdater.setup(&httpServer);
httpServer.begin();
MDNS.addService("http", "tcp", 80);
Serial.printf("HTTPUpdateServer ready! Open http://%s.local/update in your browser\n", host);
}
void loop(void){
httpServer.handleClient();
}
1 Answer 1
It goes into STA+AP mode because your code is telling it to do that.
If you want it to just go into STA mode then your line:
WiFi.mode(WIFI_AP_STA);
should be
WiFi.mode(WIFI_STA);
-
thanks, the code was taken from examples, do you know if going into AP mode is necessary for MDNS to work at all?John Smith– John Smith2018年06月09日 05:10:07 +00:00Commented Jun 9, 2018 at 5:10
-
In theory MDNS should work in any mode, but of course would only be visible on networks that the ESP was actually connected to. There are several issues filed on the MDNS code that show other people having trouble with STA+AP mode. There was a fix checked in but it's not clear that it really resolved the problem. So you're not the only one with problems with it; I wouldn't expect it to definitely work, unfortunately.romkey– romkey2018年06月09日 15:28:37 +00:00Commented Jun 9, 2018 at 15:28
WiFi.mode(WIFI_AP_STA);
line?