PubSub can inform us that a message has been received via .MessageReceived().
The message & topic then can be obtained via .getmessage().
Example
IF PubSub.MessageReceived() THEN myRecvMessage := PubSub.MyMessage( wsTopic => MyTopic); // pass the message to the payload decoder MyDecodedMessage := Payload.Decode( pBuf:=ADR(myRecvMessage),udiBufSize:=SIZEOF(myRecvMessage)); END_IF;
=> Passing a pointer/length of the blob (the undecoded received message) is far superior in speed and resources as no data is physically copied around. Binding a dynamic buffer is under future consideration.
=> Interaction/handshaking between PubSub and Payload in the usual way (xbusy, xdone, xerror) and methods for this are provided.
=> according to the documentation of the CODESYTS IIoT lib, there is a maximum message payload length.
In the CODESYS IIot MQTT library, is a single subscriber only capable of just subscribing to a single topic?
=> I Assume so, as the provided example shows a single topic per subscriber instance.
Diff:
Diff:
Diff:
Diff:
Diff:
Diff:
Diff:
Diff:
Diff:
You can use the wildcards defined my MQTT, but I don't see anyway to add a list of topics.
So '#' is multilevel topic subscription. '+' is single level topic subscription.
I assume that the subscriber implemented in the IIoT suite MQTT library can only subscribe a single topic.
That is why I allready implemented two subscribers in the FB_MQTT_PubSub located in in my private branch as a single topic does not suffice for sparkplugB.
I checked the CODESYS documentation whether a list of topics can be added to a single subscriber, but I gathered it cannot be achieved. The provided example also implements two seperate subscribers. Granted I didn't try it, but the example should have shown this if it was a feature.
I still have to merge it into the trunk and add the appropriate unittests.