设备标签

支持设备端上报标签到云端,以及删除设备标签。

上报标签

说明

设备标签相关接口参见IDeviceLabel

//标签是key,value的形式,可以替换attrKey和attrValue
RequestModel<List<Map<String, String>>> requestModel = new RequestModel<List<Map<String, String>>>();
requestModel.id = "123";
requestModel.method = "thing.deviceinfo.update";
requestModel.version = "1.0";
List<Map<String, String>> paramsList = new ArrayList<Map<String, String>>();
Map<String, String> listItemMap = new HashMap<String, String>();
listItemMap.put("attrKey", "Temperature");
listItemMap.put("attrValue", "56.8");
paramsList.add(listItemMap);
requestModel.params = paramsList;
LinkKit.getInstance().getDeviceLabel().labelUpdate(requestModel, new IConnectSendListener() {
    @Override
    public void onResponse(ARequest aRequest, AResponse aResponse) {
        Log.d(TAG, "onResponse() called with: aRequest = [" + aRequest + "], aResponse = [" + (aResponse == null ? "" : aResponse.data) + "]");
    }
    @Override
    public void onFailure(ARequest aRequest, AError aError) {
        Log.d(TAG, "onFailure() called with: aRequest = [" + aRequest + "], aError = [" + getError(aError) + "]");
    }
});
        

删除标签

//标签是key,value的形式,可以替换attrKey和attrValue
RequestModel<List<Map<String, String>>> requestModel = new RequestModel<List<Map<String, String>>>();
requestModel.id = "123";
requestModel.method = "thing.deviceinfo.delete";
requestModel.version = "1.0";
List<Map<String, String>> paramsList = new ArrayList<Map<String, String>>();
Map<String, String> listItemMap = new HashMap<String, String>();
listItemMap.put("attrKey", "Temperature");
paramsList.add(listItemMap);
requestModel.params = paramsList;
LinkKit.getInstance().getDeviceLabel().labelDelete(requestModel, new IConnectSendListener() {
    @Override
    public void onResponse(ARequest aRequest, AResponse aResponse) {
        ALog.d(TAG, "onResponse() called with: aRequest = [" + aRequest + "], aResponse = [" + (aResponse == null ? "" : aResponse.data) + "]");
    }
    @Override
    public void onFailure(ARequest aRequest, AError aError) {
        ALog.d(TAG, "onFailure() called with: aRequest = [" + aRequest + "], aError = [" + getError(aError) + "]");
    }
});