{"id":1416,"date":"2018-04-25T19:46:44","date_gmt":"2018-04-25T11:46:44","guid":{"rendered":"https:\/\/emt.bjtu.edu.cn\/cn\/?p=1416"},"modified":"2022-05-04T10:17:09","modified_gmt":"2022-05-04T02:17:09","slug":"%e5%85%b3%e4%ba%8emqtt%e4%bb%8b%e7%bb%8d%e9%9d%9e%e5%b8%b8%e6%b8%85%e6%99%b0%e7%ae%80%e6%b4%81%e7%9a%84%e6%96%87%e7%ab%a0","status":"publish","type":"post","link":"https:\/\/emt.bjtu.edu.cn\/cn\/%e5%85%b3%e4%ba%8emqtt%e4%bb%8b%e7%bb%8d%e9%9d%9e%e5%b8%b8%e6%b8%85%e6%99%b0%e7%ae%80%e6%b4%81%e7%9a%84%e6%96%87%e7%ab%a0\/","title":{"rendered":"\u5173\u4e8eMQTT\u4ecb\u7ecd\u975e\u5e38\u6e05\u6670\u7b80\u6d01\u7684\u6587\u7ae0"},"content":{"rendered":"\n<p>\n\t<strong>A Brief, but Practical Introduction to the MQTT Protocol and its Application to IoT<\/strong>\n<\/p>\n\n\n\n<p><a href=\"https:\/\/zoetrope.io\/tech-blog\/brief-practical-introduction-mqtt-protocol-and-its-application-iot\">https:\/\/zoetrope.io\/tech-blog\/brief-practical-introduction-mqtt-protocol-and-its-application-iot<\/a><\/p>\n\n\n\n<p>\n\tMQTT is a standardised publish\/subscribe messaging protocol. It was designed in 1999 for use on satellites and as such is very light-weight with low bandwidth requirements making it ideal for M2M or IoT applications. As such, it has become one of the most common protocols for those situations.\n<\/p>\n\n\n\n<p>\n\tWhat follows is a brief introduction to the protocol and some examples of its use. It is not intended to be a comprehensive reference on MQTT, but it should give enough information to get developers up and running. If you\u2019re looking for a more complete discussion of the protocol, HiveMQ have published a series of articles available here.<br \/>\n\tPublish \/ Subscribe\n<\/p>\n\n\n\n<p>\n\tThe publish \/ subscribe (often called pub-sub) pattern lies at the heart of MQTT. It\u2019s based around a message broker, with other nodes arranged around the broker in a star topology. This is a very different model to the standard client\/server approach, and at first it might seem a little strange, but the decoupling it provides is a huge advantage in many situations.\n<\/p>\n\n\n\n<p>\n\tClients can publish or subscribe to particular topics which are somewhat like message subjects. They are used by the broker to decide who will receive a message. Topics in MQTT have a particular syntax. They are arranged in a hierarchy using the slash character (\/) as a separator, much like the path in a URL. So a temperature sensor in your kitchen might publish to a topic like \u2018sensors\/temperature\/home\/kitchen\u2019.\n<\/p>\n\n\n\n<p>\n\tLet\u2019s look at an example: Imagine a weather service which has a network of internet connected temperature sensors all over the world. All of these sensors maintain a connection to a broker and every ten minutes, they report the current temperature. They publish to a particular topic based on their location in the following format:\n<\/p>\n\n\n\n<p>\n\tsensors\/temperature\/{country}\/{city}\/{street name}\n<\/p>\n\n\n\n<p>\n\tSo a sensor on Baker Street in London would publish to \u2018sensors\/temperature\/uk\/london\/baker_street\u2019 with a message containing the current temperature.\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/emt.bjtu.edu.cn\/cn\/%e5%85%b3%e4%ba%8emqtt%e4%bb%8b%e7%bb%8d%e9%9d%9e%e5%b8%b8%e6%b8%85%e6%99%b0%e7%ae%80%e6%b4%81%e7%9a%84%e6%96%87%e7%ab%a0\/mqtt_introduction\/\" rel=\"attachment wp-att-1417\"><img loading=\"lazy\" decoding=\"async\" width=\"1671\" height=\"1014\" src=\"https:\/\/emt.bjtu.edu.cn\/cn\/wp-content\/uploads\/2018\/04\/MQTT_introduction.png\" alt=\"\" class=\"wp-image-1417\" srcset=\"https:\/\/emt.bjtu.edu.cn\/cn\/wp-content\/uploads\/2018\/04\/MQTT_introduction.png 1671w, https:\/\/emt.bjtu.edu.cn\/cn\/wp-content\/uploads\/2018\/04\/MQTT_introduction-600x364.png 600w, https:\/\/emt.bjtu.edu.cn\/cn\/wp-content\/uploads\/2018\/04\/MQTT_introduction-300x182.png 300w, https:\/\/emt.bjtu.edu.cn\/cn\/wp-content\/uploads\/2018\/04\/MQTT_introduction-768x466.png 768w, https:\/\/emt.bjtu.edu.cn\/cn\/wp-content\/uploads\/2018\/04\/MQTT_introduction-1024x621.png 1024w\" sizes=\"auto, (max-width: 1671px) 100vw, 1671px\" \/><\/a><\/figure>\n\n\n\n<p>\n\t<span style=\"font-family:arial,helvetica,sans-serif;\"><\/span>\n<\/p>\n\n\n\n<p>\n\tEND.\n<\/p>\n\n\n\n<p>\n\t&nbsp;\n<\/p>\n\n\n\n<p>\n\t&nbsp;\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A Brief, but Practical Introduction to the MQTT Protoco&hellip;&nbsp;<a href=\"https:\/\/emt.bjtu.edu.cn\/cn\/%e5%85%b3%e4%ba%8emqtt%e4%bb%8b%e7%bb%8d%e9%9d%9e%e5%b8%b8%e6%b8%85%e6%99%b0%e7%ae%80%e6%b4%81%e7%9a%84%e6%96%87%e7%ab%a0\/\" rel=\"bookmark\">\u9605\u8bfb\u66f4\u591a &raquo;<span class=\"screen-reader-text\">\u5173\u4e8eMQTT\u4ecb\u7ecd\u975e\u5e38\u6e05\u6670\u7b80\u6d01\u7684\u6587\u7ae0<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":3347,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"[\"title\",\"meta\",\"content\",\"tags\",\"comments\",\"post-navigation\"]","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-1416","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/emt.bjtu.edu.cn\/cn\/wp-json\/wp\/v2\/posts\/1416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/emt.bjtu.edu.cn\/cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/emt.bjtu.edu.cn\/cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/emt.bjtu.edu.cn\/cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/emt.bjtu.edu.cn\/cn\/wp-json\/wp\/v2\/comments?post=1416"}],"version-history":[{"count":5,"href":"https:\/\/emt.bjtu.edu.cn\/cn\/wp-json\/wp\/v2\/posts\/1416\/revisions"}],"predecessor-version":[{"id":3348,"href":"https:\/\/emt.bjtu.edu.cn\/cn\/wp-json\/wp\/v2\/posts\/1416\/revisions\/3348"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/emt.bjtu.edu.cn\/cn\/wp-json\/wp\/v2\/media\/3347"}],"wp:attachment":[{"href":"https:\/\/emt.bjtu.edu.cn\/cn\/wp-json\/wp\/v2\/media?parent=1416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/emt.bjtu.edu.cn\/cn\/wp-json\/wp\/v2\/categories?post=1416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/emt.bjtu.edu.cn\/cn\/wp-json\/wp\/v2\/tags?post=1416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}