You can submit device tags to IoT Platform and delete device tags.
Submit tags
Note For information about tag-related API operations, see IDeviceLabel.
// A tag consists of a key-value pair. You can specify the attrKey and attrValue parameters as required.
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) + "]");
}
});
Delete tags
// A tag consists of a key-value pair. You can specify the attrKey and attrValue parameters as required.
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) + "]");
}
});