forked from FieldFox/Codesys-Mqtt-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmqtt.c
121 lines (106 loc) · 2.68 KB
/
mqtt.c
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
#include "C:\Users\wim\Source\spikes\mqtt\mqtt.h"
/* The implemenation templates */
BOOL BUFFERinit(BUFFERtyp* inst, BOOL bRetain)
{
int j, k, l; /* Loop counters */
for (j = 0; j < 1501; j++)
{
(*((inst->DATA) + j)) = 0;
}
inst->IPOS = 0UL;
return bRetain;
}
BOOL _BUFFER_CONCAT(BUFFERtyp *PTparam, BUFFERtyp *PTCONTACTparam)
{
}
BOOL _BUFFER_PUSH(BUFFERtyp *PTparam, BYTE INparam)
{
}
BOOL _BUFFER_PUSH_STRING(BUFFERtyp *PTparam, char* INparam, BOOL INCLUDE_LENGTHparam)
{
}
BOOL _BUFFER_SET(BUFFERtyp *PTparam, BYTE INparam, WORD POSparam)
{
}
BOOL FIXEDHEADERinit(FIXEDHEADERtyp* inst, BOOL bRetain)
{
int j, k, l; /* Loop counters */
inst->BMESSAGETYPE = 0;
inst->XDUP_FLAG = FALSE;
inst->XQOS = 0;
inst->XRETAIN = FALSE;
return bRetain;
}
BOOL CREATE_MESSAGE(BUFFERtyp *PTparam, FIXEDHEADERtyp FIXEDHEADERparam, BUFFERtyp VARIABLEHEADERparam, BUFFERtyp PAYLOADparam)
{
}
BOOL ENCODE_REMAINING_LENGTH(BUFFERtyp *PTparam, DWORD LENGTHparam)
{
}
BOOL CONNECTFLAGSinit(CONNECTFLAGStyp* inst, BOOL bRetain)
{
int j, k, l; /* Loop counters */
inst->XUSERNAME = FALSE;
inst->XPASSWORD = FALSE;
inst->XWILLRETAIN = FALSE;
inst->XWILLQOS1 = FALSE;
inst->XWILLQOS2 = FALSE;
inst->XWILLFLAG = FALSE;
inst->XCLEANSESSION = FALSE;
return bRetain;
}
void MQTT_CLIENT(MQTT_CLIENTtyp* inst)
{
}
BOOL MQTT_CLIENTinit(MQTT_CLIENTtyp* inst, BOOL bRetain)
{
int j, k, l; /* Loop counters */
/* Initializing Function Block components */
inst->VERSION = 3;
inst->RESERVED = 0;
inst->CONNECT = 1;
inst->CONNACK = 2;
inst->PUBLISH = 3;
inst->PUBACK = 4;
inst->PUBREC = 5;
inst->PUBREL = 6;
inst->PUBCOMP = 7;
inst->SUBSCRIBE = 8;
inst->SUBACK = 9;
inst->UNSUBSCRIBE = 10;
inst->UNSUBACK = 11;
inst->PINGREQ = 12;
inst->PINGRESP = 13;
inst->DISCONNECT = 14;
inst->RESERVED2 = 15;
inst->CONNECTED = 30;
inst->NOT_CONNECTED = 40;
inst->TIMEOUT = 50;
inst->WAIT_RESPONSE = 60;
inst->CONNECTION_TIMEOUT = 10000UL;
BUFFERinitmac(&inst->SENDBUFFER, bRetain);
BUFFERinitmac(&inst->RECEIVEBUFFER, bRetain);
FIXEDHEADERinitmac(&inst->FIXEDHEADER, bRetain);
BUFFERinitmac(&inst->VARIABLEHEADER, bRetain);
BUFFERinitmac(&inst->PAYLOAD, bRetain);
CONNECTFLAGSinitmac(&inst->CONNECTFLAGS, bRetain);
TCP_CLIENTinitmac(&inst->TCPCLIENT, bRetain);
inst->XTCPCONNECTED = FALSE;
inst->XSTARTSEND = FALSE;
inst->DIRECEIVECOUNT = 0L;
TONinitmac(&inst->CONNECTIONTIMER, bRetain);
inst->XTIMEOUT = FALSE;
inst->INCOMINGMESSAGETYPE = 0;
inst->ESTATE = 0;
inst->XSTARTTIMER = FALSE;
(*pstrcpy)(inst->STOPIC, "");
(*pstrcpy)(inst->SPAYLOAD, "");
inst->XCONNECTED = FALSE;
if (bRetain)
return bRetain;
/* Initalize the retain variables only if bRetain is FALSE */
return bRetain;
}
void PLC_PRG(void)
{
}