四博智联产品售后

标题: IOT平台设计 [打印本页]

作者: ycf    时间: 2015-5-25 00:01
标题: IOT平台设计
平台基于TCP通讯,服务器IP: iot.doit.am 端口:8810
平台采用key,进行用户验证,key通过 http://iot.doit.am 获得。

1.数据上传:
  cmd=upload&device_name=arduino&data=126&uid=demo&key=c514c91e4ed341f263e458d44b3bb0a7 \r\n
应答:
cmd=upload&res=1
通过 http://iot.doit.am可以实时查看。

2.控制设备:
  a)先订阅自己的用户id
       cmd=subscribe&uid=demo \r\n
    应答:cmd=subscribe&res=1

b)通过 http://iot.doit.am发送控制命令。

c)设备得到命令:
cmd=publish&device_name=humidity&device_cmd=poweron

3.保持链接
  如果超过120秒没有收到任何数据包,服务器会断开链接,
建议每隔30秒发一次心跳包,格式如下:
  cmd=keep \r\n
服务器应答:
cmd=keep&res=1\r\n

4.控制指令发布
cmd=publish&uid=demo&device_name=humidity&device_cmd=poweron

5.获取传感器列表:
http://iot.doit.am/new_api/get_sensor.php?cmd=get_sensor&uid=demo&key=c514c91e4ed341f263e458d44b3bb0a7
应答如下json格式:
["arduino","pi3","zwd_arduino","zwd_ard"]
6.获取传感器数据:
获取所有:
http://iot.doit.am/new_api/get_data.php?cmd=get_data&uid=demo&key=c514c91e4ed341f263e458d44b3bb0a7&sensor=arduino&&new=1
获取指定长度:
http://iot.doit.am/new_api/get_data.php?cmd=get_data&uid=demo&key=c514c91e4ed341f263e458d44b3bb0a7&sensor=arduino&b=开始位置&len=指定长度&new=1

应答如下json格式:
[{"data":"139.3","upload_time":"2014-08-12 21:15:15"},{"data":"138.81","upload_time":"2014-08-12 21:15:10"},{"data":"138.32","upload_time":"2014-08-12 21:15:06"},{"data":"138.32","upload_time":"2014-08-12 21:15:02"},{"data":"138.32","upload_time":"2014-08-12 21:14:55"},{"data":"138.32","upload_time":"2014-08-12 21:14:50"},{"data":"138.81","upload_time":"2014-08-12 21:14:45"},{"data":"138.81","upload_time":"2014-08-12 21:14:40"},{"data":"138.81","upload_time":"2014-08-12 21:14:35"},{"data":"138.81","upload_time":"2014-08-12 21:14:32"},{"data":"138.32","upload_time":"2014-08-12 21:14:25"},{"data":"138.32","upload_time":"2014-08-12 21:14:20"}]

7.查看是否在线
http://iot.doit.am/new_api/online.php?uid=用户id
返回在线的数目
比如:http://iot.doit.am/new_api/online.php?uid=demo
应答1


作者: ycf    时间: 2015-7-9 09:47
也可以通过http上传:
http地址:
http://iot.doit.am/new_api/upload.php
参数:
cmd=upload&device_name=arduino&data=126&uid=demo&key=c514c91e4ed341f263e458d44b3bb0a7
方法:
GET
示例:
http://iot.doit.am/new_api/uploa ... 1f263e458d44b3bb0a7

也可以通过http进行控制:
http地址:
http://iot.doit.am/new_api/control.php
参数:
device_name=arduino&device_cmd=on
方法:
GET
示例:
http://iot.doit.am/new_api/contr ... o&device_cmd=on









欢迎光临 四博智联产品售后 (http://bbs.doit.am/) Powered by Discuz! X3.2