<p>本文从宏观上介绍IoT的通信架构,让大家都日渐频繁的物联网设备工作原理有一个初步的理解,主要分为了直连、网关、云三种模式。</p>
<p>1. 直连模式(direct integration pattern)<img alt="" height="349" src="https://images2017.cnblogs.com/blog/633834/201709/633834-20170920170034…; width="587" /></p>
<img alt="1" data-align="center" data-entity-type="file" data-entity-uuid="1cae7bc9-95e3-44f1-8410-8fcc281c5937" height="405" src="/sites/default/files/inline-images/w1.png" width="679" />
<p> </p>
<p>通常我们使用的小米手环等物联网设备,和手机就是直连模式,但其使用的是蓝牙,并不能提供<strong>通用</strong>的接口来访问;解决这一问题的方法是使用已经成熟多年的Web技术,所以也有人提出了Web of Things的概念。</p>
<p>如果设备支持HTTP和TCP/IP,并且能够直接连接互联网,比如使用Wi-Fi,那么可以使用这种直连模式。通常设备需要较为强大的处理能力,并且有持续的电源,比如智能家居等。要通过Web直接控制设备,其自身需要实现类似下图的功能,从硬件控制、RESTFUL API的设计到HTTP服务器的实现。<img alt="" height="458" src="https://images2017.cnblogs.com/blog/633834/201709/633834-20170920170100…; width="689" /></p>
<img alt="2" data-align="center" data-entity-type="file" data-entity-uuid="f04b193a-c95d-407e-9b08-1fc6764ffc85" height="467" src="/sites/default/files/inline-images/w2.png" width="702" />
<p> </p>
<p>2. 网关模式 (gateway integration pattern)<img alt="" height="378" src="https://images2017.cnblogs.com/blog/633834/201709/633834-20170920170303…; width="655" /> </p>
<img alt="3" data-align="center" data-entity-type="file" data-entity-uuid="a8724707-3b8e-4ec0-a0c3-b74172ae797d" height="405" src="/sites/default/files/inline-images/w3.png" width="701" />
<p>如果设备的资源受限,或者不能直接接入互联网(比如仅仅支持蓝牙、ZigBee),它们可以通过接入功能强大的网关(gateway)来实现通过Web访问;网关将其他类型的协议转换成统一的对外接口(如将设备的CoAP转换为HTTP提供给用户),同时还可以提供安全认证、集成、临时数据存储、对设备的语义描述等功能。开源的网关项目有Open Hab [2],此外很多大厂商也有自己的网关来支持自己的设备。</p>
<p>3. 云模式 (cloud integration pattern)<img alt="" height="449" src="https://images2017.cnblogs.com/blog/633834/201709/633834-20170920170317…; width="604" /> </p>
<img alt="4" data-align="center" data-entity-type="file" data-entity-uuid="387cbf68-ac2f-4332-b5ac-2f261b5961b8" height="423" src="/sites/default/files/inline-images/w4.png" width="568" />
<p>云模式可以看做网关模式的扩展,只不过网关在云端,提供协议的转换、数据处理等云服务,最大的特点在于可以通过外网访问各种设备。目前已经出现了各种提供物联网云服务的平台,如AWS、阿里、微软等巨头,还有专门的平台如Xively、机智云等,百家争鸣,但是他们大都采用类似下图的结构,通过MQTT协议来管理各种设备,云端有虚拟设备来保存设备状态,存储管理设备产生的数据,使用秘密的API KEY通过REST API来发送管理指令等。</p>
<p align="center"><img alt="" height="342" src="https://images2017.cnblogs.com/blog/633834/201709/633834-20170920170351…; width="550" /> </p>
<img alt="5" data-align="center" data-entity-type="file" data-entity-uuid="ed4bdc5f-1b36-427d-84c0-b4be428f9fa6" height="396" src="/sites/default/files/inline-images/w5.png" width="636" />
<p align="left">4.总结</p>
<p align="left">通过云的模式往往使指令传输很慢,所以一个物联网设备可能同时允许上述几种操作模式。使用Web来控制设备,还可以轻松的使用IFTTT这样的第三方自动化平台,来设计条件自动化的执行一些功能,并于常用App如Twitter互动。最后,盗几张书中对协议介绍的图,来方便理解物联网中涉及的各种协议,如蓝牙、MQTT、ZigBee、Apple Homekit等。 <img alt="" height="393" src="https://images2017.cnblogs.com/blog/633834/201709/633834-20170920170442…; width="293" /></p>
<img alt="6" data-align="center" data-entity-type="file" data-entity-uuid="73ed0f57-b37b-4f22-99a8-a0da6d425a73" src="/sites/default/files/inline-images/w6.png" />
<p align="left"> </p>
<img alt="7" data-align="center" data-entity-type="file" data-entity-uuid="60dadbe8-9835-40ef-ada9-453898d60431" height="347" src="/sites/default/files/inline-images/w7.png" width="627" />
<p> </p>
<img alt="8" data-align="center" data-entity-type="file" data-entity-uuid="c2e86fbe-d34f-4a7f-b37f-b36414683a33" src="/sites/default/files/inline-images/w8.png" />
<p><strong>附录:</strong></p>
<p>[1] Building the Web of Things: With examples in Node.js and Raspberry Pi</p>
<p><a href="https://www.manning.com/books/building-the-web-of-things?a_bid=16f48f14…;
<p>[2] <a href="http://www.openhab.org/">http://www.openhab.org/</a></p>
<p>[3].国外各种平台汇总,有上百种</p>
<p>https://www.postscapes.com/internet-of-things-platforms/</p>
<p>[4] 一部分平台的稍微详细的总结介绍</p>
<p>http://www.cnblogs.com/ibrahim/p/iot-platform-outline.html</p>
<p>[5] 很多IoT的开源项目,其中AllJoyn提供了联通框架,或许值得额外关注</p>
<p><a href="https://www.linux.com/news/21-open-source-projects-IoT">https://www.lin…;
<p>[6] http://www.cnblogs.com/ibrahim/p/iot-platform-outline.html</p>
<p>本文转载自:<a href="https://www.cnblogs.com/ascii0x03/p/7562498.html">ASCII0x03的博客</a></p>
<p>声明:本文为转载文章,转载此文目的在于传递更多信息,版权归原作者所有,如涉及侵权,请联系小编进行处理。</p>