-
Notifications
You must be signed in to change notification settings - Fork 19
/
MQTT_Main_CP.scl
569 lines (478 loc) · 19.5 KB
/
MQTT_Main_CP.scl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
FUNCTION_BLOCK "MQTT"
TITLE = 'MQTT MAIN Function(CP)'
{ S7_Optimized_Access := 'FALSE' }
AUTHOR : Maul
VERSION : 1.0
//ported by Groschke to TIA V13
VAR_INPUT
connectionID : Int := 1; // S7 Connection ID for CP Ethernet
cpLADDR : Word := W#16#0100; // S7 LADDR for CP Ethernet
END_VAR
VAR_OUTPUT
pubTopic : String[254];
pubTopicChar { S7_HMI_Accessible := 'False'; S7_HMI_Visible := 'False'} AT pubTopic : Array[0..255] of Char;
payload : Array[0..4096] of Byte; // Must match mqttGlobals.TCP_MAXRECVSIZE
payloadSize : Int;
END_VAR
VAR_IN_OUT
callback : Bool;
callbackPacketType : Int;
END_VAR
VAR
tcpState : Int := 0; // TCP state: TCP_UNINITIALIZED MQTT Protocol State Control
intState : Int; // State Machine
lastState : Int; // State Machine
tcpRecByte : Byte; // Next incoming TCP byte
myPacketReader : "mqttPacketReader"; // MQTT PacketReader Instance
msgId : Int;
typeOfPacket : Int;
Runtimer : "mqttRuntime";
resetTime : Time;
tl : Int;
paylPos : Int;
paylSize : Int; // debug
recBufLeft : Int; // Send TCP State
act_send : Bool;
snd_busy : Bool;
last_snd_err : Word; // Receive TCP State
last_rec_err : Word; // Control TCP State
cntrl_done : Bool;
cntrl_error : Bool;
cntrl_status : Word;
cntrl_lastErrStatus : Word;
cntrl_res1 : DWord;
cntrl_res2 : DWord;
netcmd_success : Bool := FALSE;
netcmd_busy : Bool := FALSE;
netcmd_error : Bool := FALSE;
netcmd_status : Word;
netcmd_datareceived : Bool := FALSE;
netcmd_datalength : Int;
netcmd_recvdlength : Int;
T_DIAG {OriginalPartName := 'T_DIAG'; LibVersion := '1.2'} : T_DIAG;
TDIAG_Status {OriginalPartName := 'TDiag_Status'; LibVersion := '1.0'} : TDiag_Status;
T_RESET {OriginalPartName := 'T_RESET'; LibVersion := '1.2'} : T_RESET;
TSEND {OriginalPartName := 'T__SEND'; LibVersion := '4.0'} : TSEND;
TRCV {OriginalPartName := 'T__RCV'; LibVersion := '4.0'} : TRCV;
END_VAR
VAR_TEMP
i : Int;
intTemp : Int;
TOP_SI {OriginalPartName := 'SI_classic'; LibVersion := '1.0'} : SI_classic;
START_UP_SI {OriginalPartName := 'SI_classic'; LibVersion := '1.0'} : SI_classic;
tmpPacketID : Int;
structTmpPacketId AT tmpPacketID : Struct
byteLSB : Byte;
byteMSB : Byte; // TCP State Control
END_STRUCT;
END_VAR
VAR CONSTANT
TCP_STATE_UNINITIALIZED : Int := 0;
TCP_STATE_INITIALIZING : Int := 1;
TCP_STATE_INITIALIZED : Int := 2;
TCP_STATE_CONNECTING : Int := 3;
TCP_STATE_CONNECTED : Int := 4;
TCP_STATE_DISCONNECTING : Int := 5;
TCP_STATE_DISCONNECTED : Int := 6; // MQTT States
MQTT_STATE_DISCONNECT : Int := -6;
MQTT_STATE_DISCONNECTING : Int := -5;
MQTT_STATE_DISCONNECTED : Int := -1;
MQTT_STATE_CONNECTING : Int := 0;
MQTT_STATE_CONNECTED : Int := 1; // packet reading States
WAIT_FOR_RECEIVED_PACKET : Int := 0;
READ_COMPLETE_PACKET : Int := 1; // MQTT Message Types
MQTT_CONNECT : Int := 16;
MQTT_CONNACK : Int := 32;
MQTT_PUBLISH : Int := 48;
MQTT_PUBACK : Int := 64;
MQTT_PUBREC : Int := 80;
MQTT_PUBREL : Int := 96;
MQTT_PUBCOMP : Int := 112;
MQTT_SUBSCRIBE : Int := 130;
MQTT_SUBACK : Int := 144;
MQTT_UNSUBSCRIBE : Int := 160;
MQTT_UNSUBACK : Int := 176;
MQTT_PINGREQ : Int := 192;
MQTT_PINGRESP : Int := 208;
MQTT_DISCONNECT : Int := 224; // Types of Ethernet Adapters
PN : Int := 0;
CP : Int := 1; // CP AG_CTRL COMMANDS
CN_NOP : Int := 0; // do nothing
CN_STATUS : Int := 1;
CN_RESET : Int := 2;
CN_STATUS_ALL : Int := 3; // get status for ALL connections
CN_RESET_ALL : Int := 4; // reset ALL connections
CN_CLEAR_RESET : Int := 5;
CN_DISCON : Int := 6; // disconnect the connection, no automatic reconnect
CN_STARTCON : Int := 7; // initiate connection
END_VAR
BEGIN
(* Check if CPU had a reset, trigger network reinitialization on reset *)
#intTemp := RD_SINFO(TOP_SI => #TOP_SI, START_UP_SI => #START_UP_SI);
IF #TOP_SI.EV_NUM <> 3 THEN
#tcpState := #TCP_STATE_UNINITIALIZED;
"mqttData".ethTCPConnected := false;
"mqttData"._state := #MQTT_STATE_DISCONNECTED;
END_IF; *)
(*
******************************
TCP/IP State Machine
******************************
*)
CASE (#tcpState) OF
#TCP_STATE_UNINITIALIZED:
"mqttData".ethTCPConnected := false;
#tcpState := #TCP_STATE_INITIALIZING;
;
#TCP_STATE_INITIALIZING:
#tcpState := #TCP_STATE_INITIALIZED;
;
#TCP_STATE_INITIALIZED:
#tcpState := #TCP_STATE_CONNECTING;
;
#TCP_STATE_CONNECTING:
// *** CP CODE ***
(* AG_CNTRL(ACT := 1,
ID := #connectionID,
LADDR := #cpLADDR,
CMD := #CN_STATUS,
DONE => #netcmd_success,
ERROR => #netcmd_error,
STATUS => #netcmd_status,
RESULT1 => #cntrl_res1,
RESULT2 => #cntrl_res2
); *)
#T_DIAG(REQ := NOT #netcmd_busy,
ID := W#16#100,
DONE => #netcmd_success,
BUSY => #netcmd_busy,
ERROR => #netcmd_error,
STATUS => #netcmd_status,
RESULT := #TDIAG_Status
);
IF #netcmd_success AND NOT #netcmd_error THEN
// New in S7-1500 and 1200 CPU's check TDIAG.State == Byte Bit 2
IF ((#TDIAG_Status.State AND B#16#04) = B#16#04) THEN
#tcpState := #TCP_STATE_CONNECTED;
"mqttData".ethTCPConnected := true;
END_IF;
END_IF;
IF #netcmd_error THEN
#cntrl_lastErrStatus := #cntrl_status;
#tcpState := #TCP_STATE_DISCONNECTED;
END_IF;
// *** CP CODE END ***
;
#T_DIAG(REQ := NOT #netcmd_busy,
ID := W#16#100,
DONE => #netcmd_success,
BUSY => #netcmd_busy,
ERROR => #netcmd_error,
STATUS => #netcmd_status,
RESULT := #TDIAG_Status
);
IF #netcmd_success AND NOT #netcmd_error THEN
// Check bits 12+13 (connection status, 11=>connection establishes)
// AND bit 14 (CP state : run=1, stop=0) by apply and compare bitmask hex 7000
IF NOT ((#TDIAG_Status.State AND B#16#04) = B#16#04) THEN
#tcpState := #TCP_STATE_DISCONNECTED;
"mqttData".ethTCPConnected := false;
END_IF;
END_IF;
IF #netcmd_error THEN
// the CP reported an error, reset the connection
#tcpState := #TCP_STATE_DISCONNECTED;
"mqttData".ethTCPConnected := false;
#cntrl_lastErrStatus := #cntrl_status;
END_IF;
// *** CP CODE END ***
;
#TCP_STATE_DISCONNECTING:
"mqttData".ethTCPConnected := false;
#T_RESET(REQ := NOT #netcmd_busy,
ID := W#16#100,
DONE => #netcmd_success,
BUSY => #netcmd_busy,
ERROR => #netcmd_error,
STATUS => #netcmd_status
);
IF #netcmd_success AND NOT #netcmd_error THEN
#tcpState := #TCP_STATE_DISCONNECTED;
END_IF;
IF #netcmd_error THEN
#cntrl_lastErrStatus := #cntrl_status;
END_IF;
// *** CP CODE END ***
;
#TCP_STATE_DISCONNECTED:
"mqttData".ethTCPConnected := false;
#tcpState := #TCP_STATE_UNINITIALIZED;
;
END_CASE;
(*
*******************************************
MQTT Timout Handling without TCP Connection
*******************************************
*)
#Runtimer(IN := (("mqttData"._state = #MQTT_STATE_CONNECTING) OR ("mqttData"._state = #MQTT_STATE_CONNECTED) OR ("mqttData"._state = #MQTT_STATE_DISCONNECTING)),
RES := false);
"mqttData".runTime := #Runtimer.RTIME;
//Recalculate timeouts when timer is set to T#0
IF TIME_TO_DINT("mqttData".runTime) = 0 AND (TIME_TO_DINT("mqttData".lastInActivity) <> 0 OR TIME_TO_DINT("mqttData".lastOutActivity) <> 0) THEN
#Runtimer.run := TIME_TO_DINT("mqttGlobals".MQTT_KEEPALIVE) / 1000;
IF TIME_TO_DINT("mqttData".lastOutActivity) <> 0 THEN
"mqttData".lastOutActivity := "mqttGlobals".MQTT_KEEPALIVE - DINT_TO_TIME(2073600000 - TIME_TO_DINT("mqttData".lastOutActivity));
END_IF;
IF TIME_TO_DINT("mqttData".lastInActivity) <> 0 THEN
"mqttData".lastInActivity := "mqttGlobals".MQTT_KEEPALIVE - DINT_TO_TIME(2073600000 - TIME_TO_DINT("mqttData".lastInActivity));
END_IF;
END_IF;
IF ("mqttData"._state = #MQTT_STATE_CONNECTING OR "mqttData"._state = #MQTT_STATE_CONNECTED OR "mqttData"._state = #MQTT_STATE_DISCONNECTING) AND #tcpState <> #TCP_STATE_CONNECTED THEN
IF (("mqttData".runTime - "mqttData".lastInActivity) > "mqttGlobals".MQTT_KEEPALIVE) OR (("mqttData".runTime - "mqttData".lastOutActivity) > "mqttGlobals".MQTT_KEEPALIVE) THEN
// Connection Timeout!
"mqttData"._state := #MQTT_STATE_DISCONNECTED;
END_IF;
END_IF;
(*
******************************
TCP/IP Sending and Receiving
******************************
*)
IF NOT (#tcpState = #TCP_STATE_CONNECTED) THEN
RETURN;
END_IF;
(* TCP SENDING *)
IF ("mqttData".reqSend AND NOT #snd_busy) THEN
"mqttData".reqSend := false;
#act_send := true;
END_IF;
// *** CP CODE ***
(*AG_SEND(ACT := #act_send,
ID := #connectionID,
LADDR := #cpLADDR,
SEND := "mqttData".tcpSendBuf,
LEN := "mqttData".sendSize,
DONE => #netcmd_success,
ERROR => #netcmd_error,
STATUS => #netcmd_status
); *)
#TSEND(REQ := #act_send AND NOT #netcmd_busy,
ID := W#16#100,
LEN := INT_TO_UDINT("mqttData".sendSize),
DONE => #netcmd_success,
BUSY => #netcmd_busy,
ERROR => #netcmd_error,
STATUS => #netcmd_status,
DATA := "mqttData".tcpSendBuf);
// after sending reset send buffer management
"mqttData".sendSize := 0;
"mqttData".tcp_sendBufferFull := false;
IF #netcmd_error AND NOT #netcmd_success THEN
#last_snd_err := #netcmd_status;
#snd_busy := false;
END_IF;
// *** CP CODE END ***
IF (#act_send) THEN
#act_send := false;
#snd_busy := true;
END_IF;
IF (#netcmd_success AND #snd_busy) THEN
#snd_busy := false;
END_IF;
(* TCP RECEIVING *)
// *** CP CODE ***
(*AG_RECV( ID := #connectionID,
LADDR := #cpLADDR,
RECV := #tcpRecByte,
NDR => #netcmd_datareceived,
ERROR => #netcmd_error,
STATUS => #netcmd_status,
LEN => #netcmd_datalength
); *)
#TRCV(ID := W#16#100,
LEN := INT_TO_UDINT(#netcmd_datalength),
ADHOC := 1,
NDR => #netcmd_datareceived,
BUSY => #netcmd_busy,
ERROR => #netcmd_error,
STATUS => #netcmd_status,
RCVD_LEN => #netcmd_recvdlength,
DATA := #tcpRecByte);
IF #netcmd_error THEN
#last_rec_err := #netcmd_status;
END_IF;
// *** CP CODE END ***
IF #netcmd_datareceived THEN
IF "mqttData".RecBufFull THEN
"RecBufFull" := true;
ELSE
"mqttData".tcpRecBuf["mqttData".pRec] := #tcpRecByte;
"mqttData".pRec := "mqttData".pRec + 1;
IF ("mqttData".pRec >= "mqttGlobals".TCP_RECVBUFFERSIZE) THEN
"mqttData".pRec := 0;
END_IF;
IF ("mqttData".pRec = "mqttData".pRead) THEN
"mqttData".RecBufFull := true;
END_IF;
END_IF;
END_IF;
#myPacketReader();
//debug
IF ("mqttData".pRec >= "mqttData".pRead) THEN
#recBufLeft := "mqttGlobals".TCP_RECVBUFFERSIZE - ("mqttData".pRec - "mqttData".pRead);
ELSE
#recBufLeft := "mqttGlobals".TCP_RECVBUFFERSIZE - ("mqttData".pRead - "mqttData".pRec);
END_IF;
(*
******************************
MQTT State Machine
******************************
*)
CASE ("mqttData"._state) OF
#MQTT_STATE_DISCONNECTED:
#lastState := "mqttData"._state;
// TODO: what is this for?
IF (("mqttData".runTime - t#10s) > #resetTime) AND NOT "mqttData".ethTCPConnected THEN
#resetTime := "mqttData".runTime;
END_IF;
;
#MQTT_STATE_CONNECTING: // this state is triggered by mqttConnect FC
IF ("mqttData"._state <> #lastState) THEN
#intState := #WAIT_FOR_RECEIVED_PACKET;
#lastState := "mqttData"._state;
END_IF;
CASE (#intState) OF
#WAIT_FOR_RECEIVED_PACKET:
IF (("mqttData".runTime - "mqttData".lastInActivity) >= "mqttGlobals".MQTT_SOCKET_TIMEOUT) THEN
// Timeout!
"mqttData"._state := #MQTT_STATE_DISCONNECTED;
ELSIF "mqttAvailable"() THEN
#myPacketReader.iBegin := true;
#intState := #READ_COMPLETE_PACKET;
END_IF;
;
#READ_COMPLETE_PACKET:
IF (#myPacketReader.xDone) THEN
#typeOfPacket := BYTE_TO_INT("mqttData".buffer[0] AND B#16#F0);
IF (#typeOfPacket = "mqttGlobals".MQTTCONNACK) THEN
"mqttData".lastInActivity := "mqttData".runTime;
"mqttData".pingOutstanding := false;
IF BYTE_TO_INT("mqttData".buffer[3]) = "mqttGlobals".MQTT_CONN_ACCEPTED THEN
"mqttData"._state := #MQTT_STATE_CONNECTED;
ELSE
// MQTT Connection Error!
"mqttData"._state := #MQTT_STATE_DISCONNECTED;
#callbackPacketType := #MQTT_CONNACK;
"mqttData".mqttErrorCode := BYTE_TO_INT("mqttData".buffer[3]);
#callback := true;
END_IF;
// ELSE maybe need equivalent/workaround to client->stop()
END_IF;
END_IF;
;
END_CASE;
;
#MQTT_STATE_CONNECTED:
IF ("mqttData"._state <> #lastState) THEN
#intState := #WAIT_FOR_RECEIVED_PACKET;
#lastState := "mqttData"._state;
END_IF;
// Check if Keepalive timeout occured.
IF (("mqttData".runTime - "mqttData".lastInActivity) > "mqttGlobals".MQTT_KEEPALIVE) OR (("mqttData".runTime - "mqttData".lastOutActivity) > "mqttGlobals".MQTT_KEEPALIVE) THEN
IF ("mqttData".pingOutstanding) THEN
// Ping Timeout!
"mqttData"._state := #MQTT_STATE_DISCONNECTED;
ELSE
"mqttData".buffer[0] := INT_TO_BYTE("mqttGlobals".MQTTPINGREQ);
"mqttData".buffer[1] := 0;
"mqttSendTCP"(offset := 0,
size := 2);
"mqttData".lastOutActivity := "mqttData".runTime;
"mqttData".lastInActivity := "mqttData".lastOutActivity;
"mqttData".pingOutstanding := true;
END_IF;
END_IF;
CASE (#intState) OF
#WAIT_FOR_RECEIVED_PACKET:
IF "mqttAvailable"() THEN
#myPacketReader.iBegin := true;
#msgId := 0;
#intState := #READ_COMPLETE_PACKET;
END_IF;
;
#READ_COMPLETE_PACKET:
IF (#myPacketReader.xDone) THEN
// check if received message is > 0 bytes for variable part
IF (#myPacketReader.result > 0) THEN
"mqttData".lastInActivity := "mqttData".runTime;
#typeOfPacket := BYTE_TO_INT("mqttData".buffer[0] AND B#16#F0);
CASE (#typeOfPacket) OF
#MQTT_PUBLISH:
// received a PUBLISH, 3.3 PUBLISH – Publish message
// refer to MQTT Docs. section 3.3 PUBLISH – Publish message
#tl := WORD_TO_INT(SHL(IN := BYTE_TO_WORD("mqttData".buffer[#myPacketReader.lengthLength + 1]), N := 8)) + BYTE_TO_INT("mqttData".buffer[#myPacketReader.lengthLength + 2]);
FOR #i := 0 TO #tl - 1 DO
#pubTopicChar[#i + 2] := BYTE_TO_CHAR("mqttData".buffer[#myPacketReader.lengthLength + 3 + #i]);
END_FOR;
#pubTopicChar[1] := INT_TO_CHAR(#tl);
#paylPos := #myPacketReader.lengthLength + 3 + #tl;
#paylSize := #myPacketReader.result - #paylPos;
FOR #i := 0 TO #paylSize - 1 DO
#payload[#i] := "mqttData".buffer[#paylPos + #i];
END_FOR;
#payloadSize := #paylSize;
#callback := true;
// Check if the Publish messag has QoS = 1, if yes then send PUBACK response
IF BYTE_TO_INT("mqttData".buffer[0] AND B#16#01) = 1 THEN
"mqttPUBACK"(packetIdMSB := "mqttData".buffer[#paylPos - 2],
packetIdLSB := "mqttData".buffer[#paylPos - 1]);
END_IF;
;
#MQTT_PINGRESP:
// received a PINGRESP, part of MQTT 3.1.2.10 Keep Alive
// (refer MQTT Docs. section 3.1.2.10 Keep Alive, 3.12 PINGREQ – PING request, 3.13 PINGRESP – PING response)
"mqttData".pingOutstanding := false;
;
#MQTT_PUBACK:
// received a PUBACK package, part of MQTT QoS 1 handshake
// (refer MQTT Docs. section 4.3.2 QoS 1: AT least once delivery)
#callbackPacketType := "mqttGlobals".MQTTPUBACK;
// get the packet ID of the PubAck package and store it in mqttData.recPublishPacketID
#structTmpPacketId.byteMSB := "mqttData".buffer[3];
#structTmpPacketId.byteLSB := "mqttData".buffer[2];
"mqttData".recPublishPacketID := #tmpPacketID;
#callback := true;
;
#MQTT_PUBREC:
// received a PUBREC package, part of MQTT QoS 2 handshake
// (refer MQTT Docs. section 4.3.3 QoS 2: Exactly once delivery)
// get the packet ID of the PubAck package and store it in mqttData.recPublishPacketID
#structTmpPacketId.byteMSB := "mqttData".buffer[3];
#structTmpPacketId.byteLSB := "mqttData".buffer[2];
// send out a PUBREL packet
"mqttData".buffer[0] := INT_TO_BYTE("mqttGlobals".MQTTPUBREL);
"mqttData".buffer[0] := "mqttData".buffer[0] OR SHL(IN := INT_TO_BYTE("mqttGlobals".MQTTQOS1), N := 1); // set qos flag to 2
"mqttData".buffer[1] := 16#02;
"mqttSendTCP"(offset := 0,
size := 4);
"mqttData".lastOutActivity := "mqttData".runTime;
;
#MQTT_PUBCOMP:
// received a PUBCOMP package, part of MQTT QoS 2 handshake
// (see MQTT Docs. section 4.3.3 QoS 2: Exactly once delivery)
// notify about successfull QoS 2 handshake
#callbackPacketType := "mqttGlobals".MQTTPUBCOMP;
// get the packet ID of the PubAck package and store it in mqttData.recPublishPacketID
#structTmpPacketId.byteMSB := "mqttData".buffer[3];
#structTmpPacketId.byteLSB := "mqttData".buffer[2];
"mqttData".recPublishPacketID := #tmpPacketID;
#callback := true;
;
END_CASE; // typeOfPacket
END_IF; // myPacketReader.result > 0
#intState := #WAIT_FOR_RECEIVED_PACKET;
END_IF; // myPacketReader.xDone
;
END_CASE; //intState
END_CASE; // mqttData._state
END_FUNCTION_BLOCK