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
struct State {
};
{{ GENERATED_CODE }}
void evaluate(Context ctx) {
char packetBuffer[8] = { 0 };
char Servo[100]={0};
char Button[100]={0};
if (isInputDirty<input_CONN2>(ctx)){udp.begin(localPort);}
if (isInputDirty<input_CONN>(ctx)){
if(WiFi.status() == WL_CONNECTED){
int cb = udp.parsePacket();
if (cb) {
int len=udp.read(packetBuffer, 255); // read the packet into the buffer, we are reading only one byte
if (len > 0)
{
packetBuffer[len] = 0;
}
Serial.println(len);
sscanf(packetBuffer, "%[^','],%[^',']", &Servo, &Button);
// Serial.println(Servo);
//Serial.println(Button);
// Serial.println(packetBuffer);
auto servo1 = atoi(Servo);
auto servo=servo1/1024.;
auto button = false;
button = atoi(Button);
emitValue<output_servo>(ctx, servo);
emitValue<output_servo1>(ctx,1-servo);
emitValue<output_button>(ctx, button);
packetBuffer[8] = { 0 };
Servo[100]={0};
Button[100]={0};
}
}else if(WiFi.status() != WL_CONNECTED){Serial.println("disconect");}}}