标签

更新时间:2018-10-23 21:24:51

支持设备端上报标签到云端,或者云端下达指令删除设备标签。

说明 设备标签相关接口参见设备 IDeviceLabel

数据上行-上报标签

// 标签是 key,value的形式 可以替换 attrKey 和 attrValue
String update_label = "{" + "  \"id\": \"123\"," + "  \"version\": \"1.0\"," +
            "  \"params\": [" + "    {" + "      \"attrKey\": \"Temperature\"," +
            "      \"attrValue\": \"36.8\"" + "    }" + "  ]," +
            "  \"method\": \"thing.deviceinfo.update\"" + "}";
RequestModel<List<Map>> requestModel = JSONObject.parseObject(update_label, new TypeReference<RequestModel<List<Map>>>() {
}.getType());
LinkKit.getInstance().getDeviceLabel().labelUpdate(requestModel, new IConnectSendListener() {
    @Override
    public void onResponse(ARequest aRequest, AResponse aResponse) {
        // 更新标签成功
    }

    @Override
    public void onFailure(ARequest aRequest, AError aError) {
        // 更新标签失败
    }
});

数据下行-删除标签

// 标签是 key,value的形式 可以替换 attrKey 和 attrValue
String deleteLabel = "{" + "  \"id\": \"123\"," + "  \"version\": \"1.0\"," +
            "  \"params\": [" + "    {" + "      \"attrKey\": \"Temperature\"" +
            "    }" + "  ]," + "  \"method\": \"thing.deviceinfo.delete\"" + "}";
RequestModel<List<Map>> requestModel = JSONObject.parseObject(deleteLabel, new TypeReference<RequestModel<List<Map>>>() {
}.getType());
LinkKit.getInstance().getDeviceLabel().labelDelete(requestModel, new IConnectSendListener() {
    @Override
    public void onResponse(ARequest aRequest, AResponse aResponse) {
        // 删除标签成功
    }

    @Override
    public void onFailure(ARequest aRequest, AError aError) {
        // 删除标签失败
    }
});

results matching ""

    No results matching ""