-
Notifications
You must be signed in to change notification settings - Fork 26
Home
the client is able to handle as many MQTTPublish
and MQTTSubscribe
FBs as your runtime ist able to. The limitations are given by memory and cycle time.
Be aware, the client is not thread save, use all FBs in on TASK.
The client is able to handle 50 packets in each direction at once. If this is to low for you, you can change the QoS_BUFFER_SIZE
value in HANDLE_MQTT
for more packets.
The client is configured to receive payloads with max 2000 bytes. You can increase this in COM_CONFIG.MaxPayloadSize
This memory is allocated dynamically.
Sending packet have only the system borders of memory supplied by your runtime system(packets are being splited automatically).
Send and receive topics are being splited in every sub topiv for better performance. The standard limits for this are:
MaxTopicLevels:=25
and
MaxTopicElementSize:=255
these values changed be changed in COM_CONFIG
.
This memory for receive and subscribe topics is allocated dynamically.
use one MQTTPublish
or MQTTValue
FB for each state, value, text you want to transmitt.
You must not change the values of the topic and the payload until send is set!
You can specify connection options in MQTT_IN_OUT, they are predefined and can be changed.
ClientID:STRING(23):='CODESYS_MQTT';
WillTopicBase:STRING(255) := 'MQTTWill';
ClientWillTopic:STRING(30) := 'DEAD';
ClientWillMessage:STRING(30) := 'DIED';
These options are concatenated for the will topic.
Welcome to the CODESYS-MQTT wiki! TYPE COM_CONFIG : STRUCT //max payload size MaxPayloadSize : UDINT := 2000; //max topic levels MaxTopicLevels:UINT := 25; //Max Topic elemt size MaxTopicElementSize:UINT:=255;
END_STRUCT END_TYPE
TYPE MQTT_IN_OUT : STRUCT In: POINTER TO PAKET_DATA; //in free true if free InFree: BOOL := TRUE; //time, date, impulse... TDI : CommonTypesAndFunctions.TIME_DATE_IMPULS_DATA; //TLS stuff data TLS_CONFIG : POINTER TO CommonTypesAndFunctions.TLS_CONFIG := 0; OUT:DATA_FROM_BROKER;
BROKER_CONNECTED:BOOL;
//Number of FB, auto increment
FB_NO_AUTO:UINT;//
//FBs count
FB_NO_AUTO_COUNT:UINT;
//FB Token
FB_NO_AUTO_TOKEN:UINT := 1;
//config for boot up
COM_CONFIG:COM_CONFIG;
(*client ID, only chars 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
System never can be anonymos
*)
ClientID:STRING(23):='CODESYS_MQTT';
WillTopicBase:STRING(255) := 'MQTTWill';
ClientWillTopic:STRING(30) := 'DEAD';
ClientWillMessage:STRING(30) := 'DIED';
//usage of dynamic RAM
dynMemUsage:UDINT;
END_STRUCT END_TYPE
TYPE SPLIT_TOPIC :
STRUCT
//this is going to be a pointer to a array of pointer to stings
Topics:POINTER TO POINTER TO STRING;
//count of vailid fields in the array
ValidFields:UINT;
END_STRUCT END_TYPE