Sunday, June 21, 2015

MQTT protocol overview - Part II

Agnostic Payload for Flexible Delivery: The payload can be in any format, binary, text, picture data. 
Message retaining for last value caching: Client can ask MQTT broker to retain the last message it sent 
The message almost looks like below 

CONNECT id=thing1
PUBLISH thing1/battery {“value” : “95”} RETAIN 
PUBLISH thing1/battery {“value” : “94”} RETAIN
PUBLISH thing1/battery {“value” : “93”} RETAIN
DISCONNECT 

CONNECT ID=thing2
SUBSCRIBE thing1/battery 
<- :="" battery="" nbsp="" publish="" span="" thing1="" value="">

MQTT has client ID and cleanSession for Session State

CONNECT ID=thing1, cleanSession=FALSE
SUBSCRIBE chat/myRoom QoS=2
DISCONNECT 

CONNECT ID=thing2
PUBLISH chat/myRoom “Hello Thing1” QoS=1
PUBLISH chat/myRoom “Are you there?” QoS=2

CONNECT ID=thing1, cleanSession=FALSE
chat/myRoom “Hellow thing1” PUBLISH
chat/myRoom “Are you there?” PUBLISH
PUBLISH chat/myRoom “Am there now!” QoS=1

MQTT has last will and testament for presence

CONNECT ID=thing2
SUBSCRIBE thing1/status

CONNECT ID=thing1 LWT=thing1/status “Bye”
PINGREQ -> 
<- nbsp="" pingres="" span="">
(client now has network problem)
(keep alive seconds pass)
<- bye="" nbsp="" publish="" span="" status="" thing1="">

References:

No comments:

Post a Comment