Now working

This commit is contained in:
Lukas Bachschwell 2019-05-17 18:50:14 +02:00
parent e3d514d931
commit b734aa8763
2 changed files with 10 additions and 7 deletions

View File

@ -1,5 +1,5 @@
{
"board": "esp8266:esp8266:d1",
"configuration": "xtal=80,vt=flash,exception=disabled,eesz=4M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600",
"port": "/dev/cu.wchusbserial144220"
"port": "/dev/cu.usbserial-144220"
}

View File

@ -10,7 +10,7 @@
#define blinkDuration 500
#define connectDuration 1000
#define lampOutputPin 12
#define lampOutputPin 5
bool isBlinking = false;
bool lampState = false;
@ -141,13 +141,13 @@ void browseService(const char *service, const char *proto) {
Serial.print(MDNS.port(i));
Serial.println(")");
if (MDNS.hostname(i) == "a2clcontroller") {
if (MDNS.hostname(i).startsWith("a2clcontroller")) {
Serial.println("Trying to connect");
Serial.println(MDNS.IP(i));
foundIp = true;
ip = MDNS.IP(i);
webSocket.begin(ip, 80, "/ws");
webSocket.begin(ip.toString(), 80, "/ws");
webSocket.onEvent(webSocketEvent);
// webSocket.setAuthorization("user", "Password");
webSocket.setReconnectInterval(3000);
@ -160,7 +160,8 @@ void browseService(const char *service, const char *proto) {
void loop() {
if (!foundIp && eth_connected && ((millis() - connectTimer) > connectDuration)) {
// browseService("http", "tcp");
browseService("http", "tcp");
/*
ip = MDNS.queryHost("a2clcontroller");
Serial.println(ip);
foundIp = true;
@ -168,12 +169,14 @@ void loop() {
webSocket.onEvent(webSocketEvent);
// webSocket.setAuthorization("user", "Password");
webSocket.setReconnectInterval(3000);
*/
connectTimer = millis();
}
// webSocket.loop();
if (foundIp)
webSocket.loop();
if (millis() - blinkTimer > blinkDuration) {
if (isBlinking && millis() - blinkTimer > blinkDuration) {
lampState = !lampState;
digitalWrite(lampOutputPin, lampState);
blinkTimer = millis();