|
平台基于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
|
|