支持設備端上報標簽到云端,以及刪除設備標簽。
上報標簽
說明
設備標簽相關接口參見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) + "]");
}
});
文檔內容是否對您有幫助?