Using the async branch, delay()
s inside of "for" loops aren't honored after a websockets connection is established. The same loop performs as expected before the ws connection is made. Is this expected behavior? Is there a workaround?
Generic ESP-12E board
Sketch#include <ESP8266WiFi.h> #include <ESP8266WiFiMulti.h> #include <WebSocketsClient.h> #include <Hash.h> ESP8266WiFiMulti WiFiMulti; WebSocketsClient webSocket; void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) { // Immediately exits the for loop and prints 1-255 in the console for(uint8_t c = 255; c > 0; c--) { Serial.println(c); delay(1000); } } void setup() { Serial.begin(115200); WiFiMulti.addAP("myNetworkName", "myPassword"); while(WiFiMulti.run() != WL_CONNECTED) { delay(100); } webSocket.begin("192.168.1.119", 1440); webSocket.onEvent(webSocketEvent); // Works as expected for(uint8_t c = 255; c > 0; c--) { Serial.println(c); delay(1000); } } void loop() { }
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4