基于Html5的智能家居手机客户端设计(一)——找到openhab的rest

  今天开始我的毕业设计,基于HTML5的智能家居手机客户端设计。挑剔了好久,终于找到我可以使用国外开源项目智能家居核心,通过restful(我也不是很懂,毕竟我只是电子信息学院爱好网络)。

  REST描述了一个架构样式的网络系统,比如 web 应用程序。在目前主流的三种Web服务交互方案中,REST相比于SOAP(Simple Object Access protocol,简单对象访问协议)以及XML-RPC更加简单明了,无论是对URL的处理还是对Payload的编码,REST都倾向于用更加简单轻量的方法设计和实现。值得注意的是REST并没有一个明确的标准,而更像是一种设计的风格。

  首先我选定openhab作为服务器端,虽然它自带手机客户端,但是由于我比较喜欢它,我还是想给它做一个手机客户端,由于使用HTML技术我也可以使用phonegap用一套代码制作各个平台使用的手机客户端。

  首先看看openhab输出的xml格式:http://192.168.0.19:8080/rest

  得到:

  

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<openhab>
<link type="items">http://192.168.0.19:8080/rest/items</link>
<link type="sitemaps">http://192.168.0.19:8080/rest/sitemaps</link>
</openhab>

可以看出它包含一个sitemap的选项可以查找到所有站点地图;通过items可以找到所有item(由于篇幅原因,item有所精简)

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<items>
<item>
<type>GroupItem</type>
<name>All</name>
<state>Undefined</state>
<link>http://192.168.0.19:8080/rest/items/All</link>
</item>
<item>
<type>GroupItem</type>
<name>gGF</name>
<state>Undefined</state>
<link>http://192.168.0.19:8080/rest/items/gGF</link>
</item>
<item>
<type>GroupItem</type>
<name>FF_Corridor</name>
<state>OFF</state>
<link>http://192.168.0.19:8080/rest/items/FF_Corridor</link>
</item>
<item>
<type>GroupItem</type>
<name>Lights</name>
<state>ON</state>
<link>http://192.168.0.19:8080/rest/items/Lights</link>
</item>
<item>
<type>GroupItem</type>
<name>Heating</name>
<state>ON</state>
<link>http://192.168.0.19:8080/rest/items/Heating</link>
</item>
<item>
<type>GroupItem</type>
<name>Temperature</name>
<state>20.12500000</state>
<link>http://192.168.0.19:8080/rest/items/Temperature</link>
</item>
<item>
<type>GroupItem</type>
<name>Windows</name>
<state>OPEN</state>
<link>http://192.168.0.19:8080/rest/items/Windows</link>
</item>
<item>
<type>DimmerItem</type>
<name>Light_GF_Living_Table</name>
<state>0</state>
<link>
http://192.168.0.19:8080/rest/items/Light_GF_Living_Table
</link>
</item>
<item>
<type>SwitchItem</type>
<name>Light_GF_Toilet_Ceiling</name>
<state>OFF</state>
<link>
http://192.168.0.19:8080/rest/items/Light_GF_Toilet_Ceiling
</link>
</item>
</items>

由此可以看出,openhab的REST输出是一个xml文件,所以我们只需要解析xml就好了。

 —————————————本文由本人在博客园首发,在开源智能家居论坛有帖,转发请保留此链接———————————————

转载于:https://www.cnblogs.com/iqinfei/p/4471282.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值