支持設備端上報標簽到云端,以及刪除設備標簽。

說明 設備標簽相關接口參見設備 IDeviceLabel。

上報標簽

// 標簽是 key,value的形式,可以替換attrKey和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) {
        // 更新標簽成功
    }

    @Override
    public void onFailure(ARequest aRequest, AError aError) {
        // 更新標簽失敗
    }
});
            

刪除標簽

// 標簽是 key,value的形式,可以替換attrKey和attrValue
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) {
        // 刪除標簽成功
    }

    @Override
    public void onFailure(ARequest aRequest, AError aError) {
        // 刪除標簽失敗
    }
});