To use the node in your project you should have the bradzilla84/pubsub-mqtt 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) {
if (!isInputDirty<input_INIT>(ctx)){
emitValue<output_OUT>(ctx, getValue<input_MQTT>(ctx));
return;}
auto MQTT = getValue<input_MQTT>(ctx);
auto payload = getValue<input_Payload>(ctx);
auto payloadLength = length(payload);
char _payload[payloadLength + 1];
dump(payload, _payload);
_payload[payloadLength] = '\0';
auto topic = getValue<input_Topic>(ctx);
auto topicLength = length(topic);
char _topic[topicLength + 1];
dump(topic, _topic);
_topic[topicLength] = '\0';
MQTT->publish(_topic, _payload, getValue<input_Retaine>(ctx), getValue<input_QOS>(ctx));
emitValue<output_OUT>(ctx, MQTT);
}