Device tags
Updated at:
You can report device tags to the cloud and delete them.
Note For more information about the device tag APIs, see IDeviceLabel.
Report tags
// A tag is a key-value pair. Replace attrKey and 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) {
// The tag is updated successfully.
}
@Override
public void onFailure(ARequest aRequest, AError aError) {
// Failed to update the tag.
}
});
Delete tags
// Specify the key of the tag to delete. Replace attrKey.
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) {
// The tag is deleted successfully.
}
@Override
public void onFailure(ARequest aRequest, AError aError) {
// Failed to delete the tag.
}
});
Is this page helpful?