diff --git a/common/transport/coap/src/main/java/org/thingsboard/server/transport/coap/adaptors/CoapAdaptorUtils.java b/common/transport/coap/src/main/java/org/thingsboard/server/transport/coap/adaptors/CoapAdaptorUtils.java index 15838564e8..7f6b886f36 100644 --- a/common/transport/coap/src/main/java/org/thingsboard/server/transport/coap/adaptors/CoapAdaptorUtils.java +++ b/common/transport/coap/src/main/java/org/thingsboard/server/transport/coap/adaptors/CoapAdaptorUtils.java @@ -31,12 +31,18 @@ public class CoapAdaptorUtils { List queryElements = inbound.getOptions().getUriQuery(); TransportProtos.GetAttributeRequestMsg.Builder result = TransportProtos.GetAttributeRequestMsg.newBuilder(); if (queryElements != null && queryElements.size() > 0) { + boolean allClient = "true".equalsIgnoreCase(getQueryValue(queryElements, "allClientKeys")); + boolean allShared = "true".equalsIgnoreCase(getQueryValue(queryElements, "allSharedKeys")); Set clientKeys = toKeys(queryElements, "clientKeys"); Set sharedKeys = toKeys(queryElements, "sharedKeys"); - if (clientKeys != null) { + if (allClient) { + result.setAllClientAttributes(true); + } else if (clientKeys != null) { result.addAllClientAttributeNames(clientKeys); } - if (sharedKeys != null) { + if (allShared) { + result.setAllSharedAttributes(true); + } else if (sharedKeys != null) { result.addAllSharedAttributeNames(sharedKeys); } } @@ -44,6 +50,16 @@ public class CoapAdaptorUtils { return result.build(); } + private static String getQueryValue(List queryElements, String name) { + for (String queryElement : queryElements) { + String[] queryItem = queryElement.split("="); + if (queryItem.length == 2 && queryItem[0].equals(name)) { + return queryItem[1]; + } + } + return null; + } + private static Set toKeys(List queryElements, String attributeName) throws AdaptorException { String keys = null; for (String queryElement : queryElements) {