Now working
This commit is contained in:
parent
e3d514d931
commit
b734aa8763
2
.vscode/arduino.json
vendored
2
.vscode/arduino.json
vendored
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"board": "esp8266:esp8266:d1",
|
"board": "esp8266:esp8266:d1",
|
||||||
"configuration": "xtal=80,vt=flash,exception=disabled,eesz=4M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600",
|
"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"
|
||||||
}
|
}
|
@ -10,7 +10,7 @@
|
|||||||
#define blinkDuration 500
|
#define blinkDuration 500
|
||||||
#define connectDuration 1000
|
#define connectDuration 1000
|
||||||
|
|
||||||
#define lampOutputPin 12
|
#define lampOutputPin 5
|
||||||
bool isBlinking = false;
|
bool isBlinking = false;
|
||||||
bool lampState = false;
|
bool lampState = false;
|
||||||
|
|
||||||
@ -141,13 +141,13 @@ void browseService(const char *service, const char *proto) {
|
|||||||
Serial.print(MDNS.port(i));
|
Serial.print(MDNS.port(i));
|
||||||
Serial.println(")");
|
Serial.println(")");
|
||||||
|
|
||||||
if (MDNS.hostname(i) == "a2clcontroller") {
|
if (MDNS.hostname(i).startsWith("a2clcontroller")) {
|
||||||
Serial.println("Trying to connect");
|
Serial.println("Trying to connect");
|
||||||
Serial.println(MDNS.IP(i));
|
Serial.println(MDNS.IP(i));
|
||||||
|
|
||||||
foundIp = true;
|
foundIp = true;
|
||||||
ip = MDNS.IP(i);
|
ip = MDNS.IP(i);
|
||||||
webSocket.begin(ip, 80, "/ws");
|
webSocket.begin(ip.toString(), 80, "/ws");
|
||||||
webSocket.onEvent(webSocketEvent);
|
webSocket.onEvent(webSocketEvent);
|
||||||
// webSocket.setAuthorization("user", "Password");
|
// webSocket.setAuthorization("user", "Password");
|
||||||
webSocket.setReconnectInterval(3000);
|
webSocket.setReconnectInterval(3000);
|
||||||
@ -160,7 +160,8 @@ void browseService(const char *service, const char *proto) {
|
|||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
if (!foundIp && eth_connected && ((millis() - connectTimer) > connectDuration)) {
|
if (!foundIp && eth_connected && ((millis() - connectTimer) > connectDuration)) {
|
||||||
// browseService("http", "tcp");
|
browseService("http", "tcp");
|
||||||
|
/*
|
||||||
ip = MDNS.queryHost("a2clcontroller");
|
ip = MDNS.queryHost("a2clcontroller");
|
||||||
Serial.println(ip);
|
Serial.println(ip);
|
||||||
foundIp = true;
|
foundIp = true;
|
||||||
@ -168,12 +169,14 @@ void loop() {
|
|||||||
webSocket.onEvent(webSocketEvent);
|
webSocket.onEvent(webSocketEvent);
|
||||||
// webSocket.setAuthorization("user", "Password");
|
// webSocket.setAuthorization("user", "Password");
|
||||||
webSocket.setReconnectInterval(3000);
|
webSocket.setReconnectInterval(3000);
|
||||||
|
*/
|
||||||
connectTimer = millis();
|
connectTimer = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
// webSocket.loop();
|
if (foundIp)
|
||||||
|
webSocket.loop();
|
||||||
|
|
||||||
if (millis() - blinkTimer > blinkDuration) {
|
if (isBlinking && millis() - blinkTimer > blinkDuration) {
|
||||||
lampState = !lampState;
|
lampState = !lampState;
|
||||||
digitalWrite(lampOutputPin, lampState);
|
digitalWrite(lampOutputPin, lampState);
|
||||||
blinkTimer = millis();
|
blinkTimer = millis();
|
||||||
|
Loading…
Reference in New Issue
Block a user