Get Gateway


获取子设备对应的网关信息。

请求格式

POST https://{apigw-address}/connect-service/v2.1/device-topos?action=getGateway

请求参数(URI)

名称 位置(Path/Query) 必需/可选 数据类型 描述
orgId Query 必需 String 资产所属的组织 ID。 如何获取 orgId 信息>>

请求参数(Body)

名称 必需/可选 数据类型 描述
subDevice 必需 DeviceIdentifier 结构体 识别子设备的标志信息,其结构参见 DeviceIdentifier 结构体

DeviceIdentifier 结构体

注解

以下非必须字段中,必须提供 assetIdproductKey + deviceKey 的组合,用于指定设备。

名称 数据类型 描述
assetId String 资产 ID。如何获取 assetId 信息>>
productKey String Product Key。
deviceKey String Device Key。

响应参数

名称 数据类型 描述
data Device 结构体 网关设备信息,其结构参见 Device 结构体

Device 结构体

名称 数据类型 描述
orgId String 资产所属的组织 ID。
assetId String 资产 ID。
modelId String 资产所属模型 ID。
modelIdPath String 模型 ID 的路径。
productKey String Product Key。
productName StringI18n 产品名称。
productType String 产品类型。
dataFormat String 数据格式。Custom 表示支持用户自定义数据格式,Json 表示只支持 EnOS 设备协议格式。
deviceKey String Device Key。
deviceName StringI18n 设备名称。
deviceSecret String 设备的连接秘钥。
deviceDesc String 设备描述。
timezone String 设备所在时区。
deviceAttributes Map(Key 为 String,Value 为 String) 设备的属性。
deviceTags Map(Key 为 String,Value 为 String) 设备的标志。
mirrorSource String 镜像源设备的 device key。
createTime Long 设备的创建时间。
status String

设备的状态(online、offline、inactive、disable 或 mirror)。

注:EnOS Edge 仅支持 online 或 offline。
activeTime Long 设备的激活时间。
lastOnlineTime Long 设备最后一次上线时间。
lastOfflineTime Long 设备最后一次离线时间。
measurepointLastUpdate Long 设备测点最近一次更新的时间。
eventLastUpdate Long 设备事件最近一次更新的时间。
attributeLastUpdate Long 设备属性最近一次更新的时间。
featureLastUpdate Long 设备最近一次更新的时间,以上述三个时间( measurepointLastUpdateeventLastUpdateattributeLastUpdate )里最近的时间为准。
firmwareVersion String 固件版本号。

示例

请求示例

url: https://{apigw-address}/connect-service/v2.1/device-topos?action=getGateway&orgId=yourOrgId
method: POST
requestBody:
{
        "subDevice":{
                "assetId":"yourAssetId"
        }
}

返回示例

{
        "code": 0,
        "msg": "OK",
        "requestId": "49ef6c03-02a0-449b-ab1e-92812071de80",
        "data": {
                "orgId": "yourOrgId",
                "assetId": "J1Rqyaqz",
                "modelId": "AlterTest0617",
                "modelIdPath": "/AlterTest0617",
                "productKey": "yourProductKey",
                "productName": {
                        "defaultValue": "testtopo",
                        "i18nValue": {}
                },
                "productType": "Gateway",
                "dataFormat": "Json",
                "deviceKey": "yourDeviceKey",
                "deviceName": {
                        "defaultValue": "testtopo",
                        "i18nValue": {}
                },
                "deviceSecret": "yourDeviceSecret",
                "deviceDesc": null,
                "timezone": "+08:00",
                "deviceAttributes": {},
                "deviceTags": {},
                "mirrorSource": null,
                "firmwareVersion": null,
                "createTime": 1560759829419,
                "status": "inactive",
                "activeTime": 0,
                "lastOnlineTime": 0,
                "lastOfflineTime": 0,
                "measurepointLastUpate": null,
                "eventLastUpdate": null,
                "attributeLastUpdate": 1561447707379,
                "featureLastUpdate": 1561447707379
        }
}

Java SDK 调用示例

package com.envisioniot.enos.api.sample.connect_service.device.topo;

import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
import com.envisioniot.enos.connect_service.v2_1.device.topo.GetGatewayRequest;
import com.envisioniot.enos.connect_service.v2_1.device.topo.GetGatewayResponse;
import com.envisioniot.enos.connect_service.vo.DeviceIdentifier;


public class GetGateWay {
    public static void main(String[] args) {
        final String appKey = "yourAppKey";
        final String appSecret = "yourAppSecret";
        String serverUrl = "yourSeverUrl";

        String orgId = "yourOrgId";
        GetGatewayRequest request = new GetGatewayRequest();
        request.setOrgId(orgId);
        request.setSubDevice(new DeviceIdentifier("zGeKTDrw"));


        GetGatewayResponse response = Poseidon.config(PConfig.init().appKey(appKey).appSecret(appSecret).debug())
                .url(serverUrl)
                .getResponse(request, GetGatewayResponse.class);
    }}