You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello Stéphane,
a really nice project! Could you perhaps publish the code from #13 again? I tried to implement your code for several LEDs and buttons but it doesn't work. The leds on the breadboard work (2 leds, 2 buttons) but the dashboard does not. There are problems with: function onMessage(event) {
let data = JSON.parse(event.data);
document.getElementById('led_' + data.rank).className = data.status;
} specifically with 'led_' + data.rank.
Is that right?
String processor(const String &var) {
return String(var == "STATE_1" && led[0].on ? "on" : "off" );
Hello Stéphane,
a really nice project! Could you perhaps publish the code from #13 again? I tried to implement your code for several LEDs and buttons but it doesn't work. The leds on the breadboard work (2 leds, 2 buttons) but the dashboard does not. There are problems with: function onMessage(event) {
let data = JSON.parse(event.data);
document.getElementById('led_' + data.rank).className = data.status;
} specifically with 'led_' + data.rank.
Is that right?
String processor(const String &var) {
return String(var == "STATE_1" && led[0].on ? "on" : "off" );
}
and: void notifyClients() {
ws.textAll(led[0].on ? "on" : "off" );
}
void handleWebSocketMessage(void *arg, uint8_t data, size_t len) {
AwsFrameInfo info = (AwsFrameInfo)arg;
if (info->final && info->index == 0 && info->len == len && info->opcode == WS_TEXT) {
data[len] = 0;
if (strcmp((char)data, "toggle") == 0) {
led[0].on = !led[0].on;
notifyClients();
}
}
I don't think so.
led[0].on = !led[0].on;
How do you think that?........
(The text was updated successfully, but these errors were encountered: