监测仪数据外发结构概述
监测仪会在有网络连接的前提下定时向预设的网络接口以 HTTP
协议的格式发送 POST
请求,用以向网站传递设备信息以及实时气体浓度数据。
目前设备外发数据的接口有以下五种:
- token 请求接口:
- http://[hostname:port]/[apipath]/getToken用以发送用户名密码验证信息并获取返回的验证 token 。该 token
将被用于以下另四种 api 接口的身份验证。
 
- 设备信息上传接口:
- http://[hostname:port]/[apipath]/deviceInfo用于上传监测仪的设备名称、序列号、经纬度位置信息以及所属用户。
 
- 摄像机信息上传接口:
- http://[hostname:port]/[apipath]/cameraSource用于上传摄像机的 camera id、摄像机画面的远程获取 url
和所属设备。
 
- 传感器信息上传接口:
- http://[hostname:port]/[apipath]/sensorInfoUpdate用于传递设备上气体浓度传感器的名称、代号、类别、上下限阈值和所属设备。
 
- 实时气体浓度数据上传接口:
- http://[hostname:port]/[apipath]/realtimeDataUpload用于上传设备中所有气体传感器的实时浓度数据。该接口一般会同时上传所有气体浓度数据,因此发送的数据结构是数组形式。
 
各接口 POST
请求的具体负载格式
token 请求接口
| 12
 3
 4
 5
 6
 7
 
 | headers = {"Content-Type": "application/json"
 }
 body = {
 "name": "admin",
 "password": "password"
 }
 
 | 
token 请求接口的返回值 json 需要遵循以下格式,不然设备无法正确获取
token: | 12
 3
 4
 5
 
 | {"message": "Authenticated.",
 "success": true,
 "token": token
 }
 
 | 
设备信息上传接口
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 
 | headers = {"Content-Type": "application/json",
 "token": token
 
 }
 body ={
 "deviceid": "HY001",
 "serialnumber": "B221236CDE341",
 
 "coordinate": {
 "latitude": 31.1304933,
 "longitude": 120.6100298,
 "altitude": 0.0
 },
 "user": "admin"
 }
 
 | 
摄像机信息上传接口
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 
 | headers = {"Content-Type": "application/json",
 "token": token
 
 }
 body = {
 "cameraid": "HY001CAM",
 
 "url": "http://222.92.212.253:61120/tjai/HY001/index.m3u8",
 
 "device": "HY001",
 }
 
 
 | 
传感器信息上传接口
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 
 | headers = {"Content-Type": "application/json",
 "token": token
 
 }
 body = {
 "name": "H2SSensor",
 "code": "HY001H2S",
 "type": "3",
 
 "upperthreshold": 2000,
 "bottomthreshold": 500,
 "device": "HY001"
 }
 
 | 
实时气体浓度数据上传接口
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 
 | headers = {"Content-Type": "application/json",
 "token": token
 
 }
 body = {
 "updatetime": new Date(),
 "device": "HY001",
 
 "sensordata": [
 {
 
 "sensorinfo": "HY001O201",
 
 "concentration": 2050,
 "unit": "%Vol",
 },
 {
 "sensorinfo": "HY001LEL01",
 "concentration": 7190,
 "unit": "%LEL",
 },
 {
 "sensorinfo": "HY001H2S01",
 "concentration": 360,
 "unit": "ppm",
 },
 {
 "sensorinfo": "HY001CO01",
 "concentration": 840,
 "unit": "ppm",
 }
 ]
 }
 
 |