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
}
}