Read a single byte of the response from an opened connection
read-byte
@/read-byte
Read a single byte of the response from an opened connection
INET@/esp8266-mcu-inet
An internet connection
SOCKxod/net/socket
A socket
READpulse
Read the byte
NApulse
Pulses when there is no byte to read
DONEpulse
Pulses when the byte is read
Bbyte
The last read byte
To use the node in your project you should have the xod-dev/esp8266-mcu 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 evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_READ
node {
void evaluate(Context ctx) {
if (!isInputDirty<input_READ>(ctx))
return;
auto socketIdx = getValue<input_SOCK>(ctx);
auto inet = getValue<input_INET>(ctx);
auto client = inet.sockets[socketIdx];
int b = client->read();
if (b < 0) {
emitValue<output_NA>(ctx, 1);
return;
}
emitValue<output_B>(ctx, (uint8_t)b);
emitValue<output_DONE>(ctx, 1);
}
}