全部产品
云市场

标签

更新时间:2019-10-10 09:48:50

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

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

上报标签

  1. // 标签是 key,value的形式 可以替换 attrKey 和 attrValue
  2. RequestModel<List<Map<String, String>>> requestModel = new RequestModel<List<Map<String, String>>>();
  3. requestModel.id = "123";
  4. requestModel.method = "thing.deviceinfo.update";
  5. requestModel.version = "1.0";
  6. List<Map<String, String>> paramsList = new ArrayList<Map<String, String>>();
  7. Map<String, String> listItemMap = new HashMap<String, String>();
  8. listItemMap.put("attrKey", "Temperature");
  9. listItemMap.put("attrValue", "56.8");
  10. paramsList.add(listItemMap);
  11. requestModel.params = paramsList;
  12. LinkKit.getInstance().getDeviceLabel().labelUpdate(requestModel, new IConnectSendListener() {
  13. @Override
  14. public void onResponse(ARequest aRequest, AResponse aResponse) {
  15. Log.d(TAG, "onResponse() called with: aRequest = [" + aRequest + "], aResponse = [" + (aResponse == null ? "" : aResponse.data) + "]");
  16. }
  17. @Override
  18. public void onFailure(ARequest aRequest, AError aError) {
  19. Log.d(TAG, "onFailure() called with: aRequest = [" + aRequest + "], aError = [" + getError(aError) + "]");
  20. }
  21. });

删除标签

  1. // 标签是 key,value的形式 可以替换 attrKey 和 attrValue
  2. RequestModel<List<Map<String, String>>> requestModel = new RequestModel<List<Map<String, String>>>();
  3. requestModel.id = "123";
  4. requestModel.method = "thing.deviceinfo.delete";
  5. requestModel.version = "1.0";
  6. List<Map<String, String>> paramsList = new ArrayList<Map<String, String>>();
  7. Map<String, String> listItemMap = new HashMap<String, String>();
  8. listItemMap.put("attrKey", "Temperature");
  9. paramsList.add(listItemMap);
  10. requestModel.params = paramsList;
  11. LinkKit.getInstance().getDeviceLabel().labelDelete(requestModel, new IConnectSendListener() {
  12. @Override
  13. public void onResponse(ARequest aRequest, AResponse aResponse) {
  14. ALog.d(TAG, "onResponse() called with: aRequest = [" + aRequest + "], aResponse = [" + (aResponse == null ? "" : aResponse.data) + "]");
  15. }
  16. @Override
  17. public void onFailure(ARequest aRequest, AError aError) {
  18. ALog.d(TAG, "onFailure() called with: aRequest = [" + aRequest + "], aError = [" + getError(aError) + "]");
  19. }
  20. });