5 CHECKING OPERATIONS
5.4 Checking the Operation of Subscribe (Receiving of MQTT Data)
48
5
Program
■Receiving of message data
M34 turns on for setting the information used for M+ENET_MQTT_Receive (Receiving of MQTT data).
M36 (Execution command) turns on for storing the receive data into the specified file register.
After the data is successfully received, M32 (Normal completion) turns on. The receive data is stored in the file register set
with i_uReceiveTopicNameDataAddr (Receive topic name data start address) and i_uReceiveMessageDataAddr (Receive
message data start address).
■Acquisition of only the required strings from receive data
• Settings for required member information
M40 (Execution command) turns on for setting the member information to be acquired.
• Acquisition of JSON string
When M40 (Execution command) turns on, the function block acquires the Value strings that exactly match the values of
uType (Value type), s32Key (Key name), and uDepth (depth of layer) in the set member list (pb_st30Member) from JSON
strings stored at the JSON start address, and it stores the values into the s64Value (Value) values in the member list
(pb_st30Member).
M34
K1100 D21
D22MOV
MOV
K1300
Set the receive topic name data start address to K1100.
Set the receive message data start address to K1300.
o_bErr :B
o_bOK :B
o_bENO :B
DUT: i_stModule
B: i_bEN
o_uErrId :UW
o_uConnectionStatus :UW
o_uNumOfDiscardedPackets :UW
M31
M36
M32
M33
UW: i_uConnectionNo
UW: i_uReceiveTopicNameDataAddr
UW: i_uReceiveMessageDataAddr
o_uSubscribeId :UW
o_uReceiveTopicSize :UW
o_uReceiveMessageSize :UW
M_FX5ENET_MQTT_Receive_00A_1
(M+FX5ENET_MQTT_Receive_00A)
FX5ENET_1
D22
D21
D0
D23
D26
D28
D27
D25
D24
MQTT Receive FB
Receive message data start address: K1300
Receive topic name data start address: K1100
Connection number: K1
M40
1
2
3
4
M_StrProcessing_JSONDeserialize_F_00A_1.pb_st30Member[0].uType := K3; //Set the Value type to K3 (character string).
M_StrProcessing_JSONDeserialize_F_00A_1.pb_st30Member[0].s32Key := 'Sample'; //Set the Key name to "Sample".
M_StrProcessing_JSONDeserialize_F_00A_1.pb_st30Member[0].uDepth := K1; //Set the depth of layer to K1.
M_StrProcessing_JSONDeserialize_F_00A_1.pb_st30Member[1].uType := K0; //Set the Value type to K0 (end of the member structure array).
o_bErr :B
o_bOK :B
o_bENO :B
UD: i_udJsonAddr
B: i_bEN
o_uErrId :UW
o_uValueNum :UW
M41
M40
M42
M43
M_StrProcessing_JSONDeserialize_F_00A_1
(M+StrProcessing_JSONDeserialize_00A)
D22
D30
D31
StrProcessing_JSONDeserialize FB
pb_st30Member
JSON start address: K1300