publish

nusabotid/nusabot-mqtt/publish

Publish a message to a Topic. (Publish sebuah pesan ke Topic yang sudah ditentukan)
publish
@/publish
Publish a message to a Topic. (Publish sebuah pesan ke Topic yang sudah ditentukan)
MQTTnusabotid/nusabot-mqtt-broker/nusabot-device
Topicstring
The topic to publish to
Payloadstring
The message to publish
Retaineboolean
QOSnumber
INITpulse
SEND
publish
MQTT
Topic
Payload
Retaine
QOS
INIT
OUT
OUTnusabotid/nusabot-mqtt-broker/nusabot-device
To use the node in your project you should have the nusabotid/nusabot-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);
}