esp-sta-v2

maks971014/esp8266-ap/esp-sta-v2

No description
esp-sta-v2
@/esp-sta-v2
DEVxod-dev/esp8266/esp8266-device
An ESP8266 device connected as internet provider
SSIDstring
Name of the Wi-Fi network
PWDstring
Wi-Fi network password
CONNpulse
Establish the connection
esp-sta-v2
DEV
SSID
PWD
CONN
To use the node in your project you should have the maks971014/esp8266-ap library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD error_raise enable

// clang-format off
{{#global}}
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
WiFiUDP udp;
unsigned int localPort = 2000; // local port to listen for UDP packets
IPAddress ServerIP(192, 168, 4, 1);
IPAddress ClientIP(192, 168, 4, 2);
{{/global}}
// clang-format on

struct State {
};

// clang-format off
{{ GENERATED_CODE }}
// clang-format on

void evaluate(Context ctx) {
    if (!isInputDirty<input_CONN>(ctx))
        return;

    auto device = getValue<input_DEV>(ctx);

    auto ssid = getValue<input_SSID>(ctx);
    char _ssid[length(ssid) + 1] = { 0 };
    dump(ssid, _ssid);

    auto password = getValue<input_PWD>(ctx);
    char _password[length(password) + 1] = { 0 };
    dump(password, _password);
    WiFi.connect(_ssid, _password);

    if (done) {
        emitValue<output_DONE>(ctx, 1);
    } else {
        raiseError(ctx); // Connection failed
    }
}