send

xod/esp8266/send

Sends a message through an opened TCP/UDP connection
send
@/send
Sends a message through an opened TCP/UDP connection
SOCKxod/net/socket
A socket
INET@/esp8266-inet
An internet connection
MSGstring
The message to send
SENDpulse
Send the message
send
SOCK
INET
MSG
SEND
DONE
ERR
ERRpulse
Pulses when sending failed (for example, the connection is not open)
DONEpulse
Pulses when the message is successfully sent

C++ implementation

struct State {
};

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

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

    auto req = getValue<input_MSG>(ctx);
    auto inet = getValue<input_INET>(ctx);

    char _req[length(req) + 1] = { 0 };
    dump(req, _req);

    if (inet.wifi->send(_req)) {
        emitValue<output_DONE>(ctx, 1);
    } else {
        emitValue<output_ERR>(ctx, 1);
    }
}