Skip to content

Commit 7bf6a0d

Browse files
author
gemi254
committed
Updated v1.0.4
1 parent b6c1e9d commit 7bf6a0d

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

examples/ControlAssist-Simple/ControlAssist-Simple.ino

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#if defined(ESP32)
22
#include <WebServer.h>
33
WebServer server(80);
4-
#define ADC_PIN 36
4+
#include <ESPmDNS.h>
5+
#define ADC_PIN 36
56
#else
67
#include <ESP8266WebServer.h>
7-
ESP8266WebServer server(80);
8+
ESP8266WebServer server(80);
9+
#include <ESP8266mDNS.h>
810
#define ADC_PIN A0
911
#endif
1012

@@ -105,7 +107,7 @@ void setup() {
105107
String mac = WiFi.macAddress();
106108
mac.replace(":","");
107109
String hostName = "ControlAssist_" + mac.substring(6);
108-
WiFi.mode(WIFI_AP_STA);
110+
WiFi.mode(WIFI_AP);
109111
WiFi.softAP(hostName.c_str(),"",1);
110112
LOG_I("Wifi AP SSID: %s started, use 'http://%s' to connect\n", WiFi.softAPSSID().c_str(), WiFi.softAPIP().toString().c_str());
111113
if (MDNS.begin(hostName.c_str())) LOG_I("AP MDNS responder Started\n");
@@ -132,7 +134,6 @@ void setup() {
132134
}
133135

134136
void loop() {
135-
if(WiFi.status() != WL_CONNECTED ) return;
136137
//Change html control values
137138
if (millis() - pingMillis >= 3000){
138139
ctrl.put("span_ctrl", analogRead(ADC_PIN) );
@@ -151,6 +152,12 @@ void loop() {
151152
buttonState = !buttonState;
152153
pingMillis = millis();
153154
}
154-
ctrl.loop();
155+
156+
#if not defined(ESP32)
157+
if(MDNS.isRunning()) MDNS.update(); //Handle MDNS
158+
#endif
159+
//Handler webserver clients
155160
server.handleClient();
156-
}
161+
//Handle websockets
162+
ctrl.loop();
163+
}

0 commit comments

Comments
 (0)