-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return node hierarchy from wildcard, and include TLV (#15495)
- Loading branch information
Showing
10 changed files
with
305 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/controller/java/src/chip/devicecontroller/model/AttributeState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2022 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package chip.devicecontroller.model; | ||
|
||
/** Represents the reported value of an attribute in object form AND TLV. */ | ||
public final class AttributeState { | ||
private Object valueObject; | ||
private byte[] tlv; | ||
|
||
public AttributeState(Object valueObject, byte[] tlv) { | ||
this.valueObject = valueObject; | ||
this.tlv = tlv; | ||
} | ||
|
||
public Object getValue() { | ||
return valueObject; | ||
} | ||
|
||
/** | ||
* Return a byte array containing the TLV for an attribute, wrapped within an anonymous TLV tag. | ||
*/ | ||
public byte[] getTlv() { | ||
return tlv; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/controller/java/src/chip/devicecontroller/model/ClusterState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2022 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package chip.devicecontroller.model; | ||
|
||
import androidx.annotation.Nullable; | ||
import java.util.Map; | ||
|
||
/** Class for tracking CHIP cluster state in a hierarchical manner. */ | ||
public final class ClusterState { | ||
private Map<Long, AttributeState> attributes; | ||
|
||
public ClusterState(Map<Long, AttributeState> attributes) { | ||
this.attributes = attributes; | ||
} | ||
|
||
public Map<Long, AttributeState> getAttributeStates() { | ||
return attributes; | ||
} | ||
|
||
/** | ||
* Convenience utility for getting an {@code ClusterState}. | ||
* | ||
* @return the {@code ClusterState} for the specified id, or null if not found. | ||
*/ | ||
@Nullable | ||
public AttributeState getAttributeState(long attributeId) { | ||
return attributes.get(attributeId); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder builder = new StringBuilder(); | ||
attributes.forEach( | ||
(attributeId, attributeState) -> { | ||
builder.append("Attribute "); | ||
builder.append(attributeId); | ||
builder.append(": "); | ||
builder.append( | ||
attributeState.getValue() == null ? "null" : attributeState.getValue().toString()); | ||
builder.append("\n"); | ||
}); | ||
return builder.toString(); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/controller/java/src/chip/devicecontroller/model/EndpointState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2022 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package chip.devicecontroller.model; | ||
|
||
import androidx.annotation.Nullable; | ||
import java.util.Map; | ||
|
||
/** Class for tracking CHIP endpoint state in a hierarchical manner. */ | ||
public final class EndpointState { | ||
private Map<Long, ClusterState> clusters; | ||
|
||
public EndpointState(Map<Long, ClusterState> clusters) { | ||
this.clusters = clusters; | ||
} | ||
|
||
public Map<Long, ClusterState> getClusterStates() { | ||
return clusters; | ||
} | ||
|
||
/** | ||
* Convenience utility for getting an {@code ClusterState}. | ||
* | ||
* @return the {@code ClusterState} for the specified id, or null if not found. | ||
*/ | ||
@Nullable | ||
public ClusterState getClusterState(long clusterId) { | ||
return clusters.get(clusterId); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder builder = new StringBuilder(); | ||
clusters.forEach( | ||
(clusterId, clusterState) -> { | ||
builder.append("Cluster "); | ||
builder.append(clusterId); | ||
builder.append(": {\n"); | ||
builder.append(clusterState.toString()); | ||
builder.append("}\n"); | ||
}); | ||
return builder.toString(); | ||
} | ||
} |
Oops, something went wrong.