设备
[TOC]
-
创建设备
请求URL
https://iot.cocall.net/api/device
请求方式
- POST
JSON 格式
-H 'Content-Type: application/json' \
-H 'X-Authorization : Bearer' \ 租户管理员的JWT 令牌
{
"name": "测试api创建设备1",
"type": "数据分析传感器设备配置",
"customerId": {//客户
"entityType": "CUSTOMER",
"id": "e9c02870-7d00-11ed-8390-0f469c2dc9ee"
}
}
返回参数
{
"id": {
"entityType": "DEVICE",
"id": "7ae33f10-512f-11ee-96a8-370bbcf38443"
},
"createdTime": 1694497486209,
"additionalInfo": null,
"tenantId": {
"entityType": "TENANT",
"id": "b3898830-7c7b-11ed-8390-0f469c2dc9ee"
},
"customerId": {
"entityType": "CUSTOMER",
"id": "e9c02870-7d00-11ed-8390-0f469c2dc9ee"
},
"name": "测试api创建设备1",
"type": "数据分析传感器设备配置",
"label": null,
"deviceProfileId": {
"entityType": "DEVICE_PROFILE",
"id": "71fda560-93b7-11ed-99fc-21fcefd60962"
},
"deviceData": {
"configuration": {
"type": "DEFAULT"
},
"transportConfiguration": {
"type": "DEFAULT"
}
},
"firmwareId": null,
"softwareId": null,
"externalId": null
}
-
删除设备
请求URL
https://iot.cocall.net/api/device/设备id
请求方式
- DELETE
JSON 格式
-H 'Content-Type: application/json' \
-H 'X-Authorization : Bearer' \ 租户管理员的JWT 令牌
-
将设备分配给客户
请求URL
https://iot.cocall.net//api/customer/{customerID}/device/{deviceID}
请求方式
- post
JSON 格式
-H 'Content-Type: application/json' \
-H 'X-Authorization : Bearer' \ 租户管理员的JWT 令牌
返回参数
{
"id": {
"entityType": "DEVICE",
"id": "089d7e30-47a1-11ee-a6f2-9b0e91a77621"
},
"createdTime": 1693446745491,
"additionalInfo": {
"gateway": false,
"overwriteActivityTime": false,
"description": ""
},
"tenantId": {
"entityType": "TENANT",
"id": "b3898830-7c7b-11ed-8390-0f469c2dc9ee"
},
"customerId": {
"entityType": "CUSTOMER",
"id": "e9c02870-7d00-11ed-8390-0f469c2dc9ee"
},
"name": "测试智能门磁设备1",
"type": "数据分析传感器设备配置",
"label": "",
"deviceProfileId": {
"entityType": "DEVICE_PROFILE",
"id": "71fda560-93b7-11ed-99fc-21fcefd60962"
},
"deviceData": {
"configuration": {
"type": "DEFAULT"
},
"transportConfiguration": {
"type": "DEFAULT"
}
},
"firmwareId": null,
"softwareId": null,
"externalId": null
}
-
取消设备分配的客户
请求URL
https://iot.cocall.net//api/customer/device/{deviceID}
请求方式
- DELETE
JSON 格式
-H 'Content-Type: application/json' \
-H 'X-Authorization : Bearer' \ 租户管理员的JWT 令牌
返回参数
{
"id": {
"entityType": "DEVICE",
"id": "089d7e30-47a1-11ee-a6f2-9b0e91a77621"
},
"createdTime": 1693446745491,
"additionalInfo": {
"gateway": false,
"overwriteActivityTime": false,
"description": ""
},
"tenantId": {
"entityType": "TENANT",
"id": "b3898830-7c7b-11ed-8390-0f469c2dc9ee"
},
"customerId": {
"entityType": "CUSTOMER",
"id": "13814000-1dd2-11b2-8080-808080808080"
},
"name": "测试智能门磁设备1",
"type": "数据分析传感器设备配置",
"label": "",
"deviceProfileId": {
"entityType": "DEVICE_PROFILE",
"id": "71fda560-93b7-11ed-99fc-21fcefd60962"
},
"deviceData": {
"configuration": {
"type": "DEFAULT"
},
"transportConfiguration": {
"type": "DEFAULT"
}
},
"firmwareId": null,
"softwareId": null,
"externalId": null
}
-
获取设备访问凭证
请求URL
https://iot.cocall.net/api/device/设备id/credentials
请求方式
- get
JSON 格式
-H 'Content-Type: application/json' \
-H 'X-Authorization : Bearer' \ 租户管理员的JWT 令牌
返回参数
{
"id": {
"id": "089e8fa0-47a1-11ee-a6f2-9b0e91a77621"
},
"createdTime": 1693446745498,
"deviceId": {
"entityType": "DEVICE",
"id": "089d7e30-47a1-11ee-a6f2-9b0e91a77621"
},
"credentialsType": "ACCESS_TOKEN",
"credentialsId": "PB1oedds0ROpr2FlntxM",//设备访问凭证
"credentialsValue": null
}
-
批量导入设备
请求URL
https://iot.cocall.net/api/device/bulk_import
请求方式
- post
JSON 格式
file: 这是CSV文件的内容,以字符串形式表示。
批量导入以下两个设备:
名称为 DeviceA,类型为 Type1,访问令牌为 TokenA
名称为 DeviceB,类型为 Type2,访问令牌为 TokenB
name,type,access_token
DeviceA,Type1,TokenA
DeviceB,Type2,TokenB
mapping:定义如何从CSV文件中解析数据。//不能设置客户
columns: 列的列表,表示CSV文件中的每一列。
key: CSV列的名称。
type: 定义列的类型,如ACCESS_TOKEN、NAME、TYPE等。
delimiter: 用于分隔CSV文件中的列的字符,常见的是逗号,。
header: 布尔值,表示CSV文件的第一行是否是标题行。
update: 布尔值,表示是否应更新现有的设备记录。
-H 'Content-Type: application/json' \
-H 'X-Authorization : Bearer' \ 租户管理员的JWT 令牌
{
"file": "name,type,access_token\nDeviceA,Type1,TokenA\nDeviceB,Type2,TokenB",
"mapping": {
"columns": [
{
"key": "name",
"type": "NAME"
},
{
"key": "type",
"type": "TYPE"
},
{
"key": "access_token",
"type": "ACCESS_TOKEN"
}
],
"delimiter": ",",
"header": true,
"update": true
}
}
返回参数
{
"created": 2,
"updated": 0,
"errors": 0,
"errorsList": []
}
-
通过设备名称来获取设备信息
请求URL
https://iot.cocall.net/api/tenant/devices?deviceName={设备名称}
请求方式
- get
JSON 格式
-H 'Content-Type: application/json' \
-H 'X-Authorization : Bearer' \ 租户管理员的JWT 令牌
返回参数
{
"id": {
"entityType": "DEVICE",
"id": "92adc330-510d-11ee-96a8-370bbcf38443"
},
"createdTime": 1694482923235,
"additionalInfo": {},
"tenantId": {
"entityType": "TENANT",
"id": "b3898830-7c7b-11ed-8390-0f469c2dc9ee"
},
"customerId": {
"entityType": "CUSTOMER",
"id": "13814000-1dd2-11b2-8080-808080808080"
},
"name": "DeviceA",
"type": "Type1",
"label": null,
"deviceProfileId": {
"entityType": "DEVICE_PROFILE",
"id": "92aadd00-510d-11ee-96a8-370bbcf38443"
},
"deviceData": {
"configuration": {
"type": "DEFAULT"
},
"transportConfiguration": {
"type": "DEFAULT"
}
},
"firmwareId": null,
"softwareId": null,
"externalId": null
}
-
获取租户的设备信息(查询租户的设备)
请求URL
https://iot.cocall.net/api/tenant/deviceInfos?pageSize=10&page=0&type=数据分析传感器设备配置 &textSearch=测试人体红外传感器设备1 &sortProperty=name&sortOrder=ASC
请求方式
- get
JSON 格式
-H 'Content-Type: application/json' \
-H 'X-Authorization : Bearer' \ 租户管理员的JWT 令牌
//查询字符串
pageSize: 这指定了每页要返回的项目数量。
值: 10
page: 这指定了页码,通常从0开始。
值: 0
type: 这是用来过滤某种类型的设备的。根据URL解码,您是在查找类型为“数据分析传感器设备配置”的设备。
值: 数据分析传感器设备配置
textSearch: 这是一个过滤条件,API会返回那些名字或其他相关属性包含这个字符串的设备。根据URL解码,您是在搜索包含“测试”的设备。
值: 测试
sortProperty: 这指定了返回的设备应该基于哪个属性进行排序。
值: (例如: "name", "label", "deviceProfileName", "label", "label")
sortOrder: 这指定了排序的顺序,可以是ASC (升序) 或 DESC (降序)。
值: ASC
返回参数
{
"data": [
{
"id": {
"entityType": "DEVICE",
"id": "880786a0-47a3-11ee-a6f2-9b0e91a77621"
},
"createdTime": 1693447818250,
"additionalInfo": {
"gateway": false,
"overwriteActivityTime": false,
"description": ""
},
"tenantId": {
"entityType": "TENANT",
"id": "b3898830-7c7b-11ed-8390-0f469c2dc9ee"
},
"customerId": {
"entityType": "CUSTOMER",
"id": "13814000-1dd2-11b2-8080-808080808080"
},
"name": "测试人体红外传感器设备1",
"type": "数据分析传感器设备配置",
"label": "",
"deviceProfileId": {
"entityType": "DEVICE_PROFILE",
"id": "71fda560-93b7-11ed-99fc-21fcefd60962"
},
"deviceData": {
"configuration": {
"type": "DEFAULT"
},
"transportConfiguration": {
"type": "DEFAULT"
}
},
"firmwareId": null,
"softwareId": null,
"externalId": null,
"customerTitle": null,
"customerIsPublic": false,
"deviceProfileName": "数据分析传感器设备配置",
"active": false
}
],
"totalPages": 1,
"totalElements": 1,
"hasNext": false
}
-
通过设备凭证来发送遥测数据
请求URL
https://iot.cocall.net/api/v1/$ACCESS_TOKEN/telemetry
请求方式
- post
JSON 格式
{"key1":"value1", "key2":"value2"}
或者
[{"key1":"value1"}, {"key2":"value2"}]