Skip to content

Commit

Permalink
Remove RemovedOn attribute from ECOINFO cluster (project-chip#34988)
Browse files Browse the repository at this point in the history
* Remove RemovedOn attribute from ECOINFO cluster

* Restyled by autopep8

* Remove artifact that were only initially used to debug script locally

* Move attr IDs after RemovedOn removal

* Empty-Commit

---------

Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
tehampson and restyled-commits authored Aug 27, 2024
1 parent 4c753be commit 7d6da7c
Show file tree
Hide file tree
Showing 31 changed files with 147 additions and 727 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ DECLARE_DYNAMIC_ATTRIBUTE_LIST_END();

// Declare Ecosystem Information cluster attributes
DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(ecosystemInformationBasicAttrs)
DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::RemovedOn::Id, EPOCH_US, kNodeLabelSize, ATTRIBUTE_MASK_NULLABLE),
DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::DeviceDirectory::Id, ARRAY, kDescriptorAttributeArraySize, 0),
DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::LocationDirectory::Id, ARRAY, kDescriptorAttributeArraySize, 0),
DECLARE_DYNAMIC_ATTRIBUTE_LIST_END();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,21 +287,10 @@ CHIP_ERROR EcosystemInformationServer::AddLocationInfo(EndpointId aEndpoint, con
return CHIP_NO_ERROR;
}

CHIP_ERROR EcosystemInformationServer::RemoveDevice(EndpointId aEndpoint, uint64_t aEpochUs)
{
auto it = mDevicesMap.find(aEndpoint);
VerifyOrReturnError((it != mDevicesMap.end()), CHIP_ERROR_INVALID_ARGUMENT);
auto & deviceInfo = it->second;
deviceInfo.mRemovedOn.SetValue(aEpochUs);
return CHIP_NO_ERROR;
}

CHIP_ERROR EcosystemInformationServer::ReadAttribute(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder)
{
switch (aPath.mAttributeId)
{
case Attributes::RemovedOn::Id:
return EncodeRemovedOnAttribute(aPath.mEndpointId, aEncoder);
case Attributes::DeviceDirectory::Id:
return EncodeDeviceDirectoryAttribute(aPath.mEndpointId, aEncoder);
case Attributes::LocationDirectory::Id:
Expand All @@ -320,28 +309,6 @@ CHIP_ERROR EcosystemInformationServer::ReadAttribute(const ConcreteReadAttribute
return CHIP_NO_ERROR;
}

CHIP_ERROR EcosystemInformationServer::EncodeRemovedOnAttribute(EndpointId aEndpoint, AttributeValueEncoder & aEncoder)
{
auto it = mDevicesMap.find(aEndpoint);
if (it == mDevicesMap.end())
{
// We are always going to be given a valid endpoint. If the endpoint
// doesn't exist in our map that indicate that the cluster was not
// added on this endpoint, hence UnsupportedCluster.
return CHIP_IM_GLOBAL_STATUS(UnsupportedCluster);
}

auto & deviceInfo = it->second;
if (!deviceInfo.mRemovedOn.HasValue())
{
aEncoder.EncodeNull();
return CHIP_NO_ERROR;
}

aEncoder.Encode(deviceInfo.mRemovedOn.Value());
return CHIP_NO_ERROR;
}

CHIP_ERROR EcosystemInformationServer::EncodeDeviceDirectoryAttribute(EndpointId aEndpoint, AttributeValueEncoder & aEncoder)
{

Expand All @@ -355,7 +322,7 @@ CHIP_ERROR EcosystemInformationServer::EncodeDeviceDirectoryAttribute(EndpointId
}

auto & deviceInfo = it->second;
if (deviceInfo.mDeviceDirectory.empty() || deviceInfo.mRemovedOn.HasValue())
if (deviceInfo.mDeviceDirectory.empty())
{
return aEncoder.EncodeEmptyList();
}
Expand All @@ -381,7 +348,7 @@ CHIP_ERROR EcosystemInformationServer::EncodeLocationStructAttribute(EndpointId
}

auto & deviceInfo = it->second;
if (deviceInfo.mLocationDirectory.empty() || deviceInfo.mRemovedOn.HasValue())
if (deviceInfo.mLocationDirectory.empty())
{
return aEncoder.EncodeEmptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,6 @@ class EcosystemInformationServer
*/
CHIP_ERROR AddLocationInfo(EndpointId aEndpoint, const std::string & aLocationId, FabricIndex aFabricIndex,
std::unique_ptr<EcosystemLocationStruct> aLocation);

/**
* @brief Removes device at the provided endpoint.
*
* @param aEndpoint Endpoint of the associated device that has been removed.
* @param aEpochUs Epoch time in micro seconds assoicated with when device was removed.
* @return #CHIP_NO_ERROR on success.
* @return Other CHIP_ERROR associated with issue.
*/
CHIP_ERROR RemoveDevice(EndpointId aEndpoint, uint64_t aEpochUs);
// TODO(#33223) Add removal and update counterparts to AddDeviceInfo and AddLocationInfo.

CHIP_ERROR ReadAttribute(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder);
Expand All @@ -214,12 +204,10 @@ class EcosystemInformationServer

struct DeviceInfo
{
Optional<uint64_t> mRemovedOn = NullOptional;
std::vector<std::unique_ptr<EcosystemDeviceStruct>> mDeviceDirectory;
std::map<EcosystemLocationKey, std::unique_ptr<EcosystemLocationStruct>> mLocationDirectory;
};

CHIP_ERROR EncodeRemovedOnAttribute(EndpointId aEndpoint, AttributeValueEncoder & aEncoder);
CHIP_ERROR EncodeDeviceDirectoryAttribute(EndpointId aEndpoint, AttributeValueEncoder & aEncoder);
CHIP_ERROR EncodeLocationStructAttribute(EndpointId aEndpoint, AttributeValueEncoder & aEncoder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,11 @@ limitations under the License.
<server init="false" tick="false">true</server>
<!-- cluster revision -->
<globalAttribute code="0xFFFD" side="either" value="1"/>
<attribute code="0x0000" side="server" define="REMOVED_ON" type="epoch_us" isNullable="true" optional="true">
<description>RemovedOn</description>
<access op="read" privilege="manage"/>
</attribute>
<attribute code="0x0001" side="server" define="DEVICE_DIRECTORY" type="array" entryType="EcosystemDeviceStruct" length="256" minLength="1">
<attribute code="0x0000" side="server" define="DEVICE_DIRECTORY" type="array" entryType="EcosystemDeviceStruct" length="256" minLength="1">
<description>DeviceDirectory</description>
<access op="read" privilege="manage"/>
</attribute>
<attribute code="0x0002" side="server" define="LOCATION_DIRECTORY" type="array" entryType="EcosystemLocationStruct" length="64" minLength="1">
<attribute code="0x0001" side="server" define="LOCATION_DIRECTORY" type="array" entryType="EcosystemLocationStruct" length="64" minLength="1">
<description>LocationDirectory</description>
<access op="read" privilege="manage"/>
</attribute>
Expand Down
5 changes: 2 additions & 3 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -9407,9 +9407,8 @@ provisional cluster EcosystemInformation = 1872 {
fabric_idx fabricIndex = 254;
}

readonly attribute access(read: manage) optional nullable epoch_us removedOn = 0;
readonly attribute access(read: manage) EcosystemDeviceStruct deviceDirectory[] = 1;
readonly attribute access(read: manage) EcosystemLocationStruct locationDirectory[] = 2;
readonly attribute access(read: manage) EcosystemDeviceStruct deviceDirectory[] = 0;
readonly attribute access(read: manage) EcosystemLocationStruct locationDirectory[] = 1;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60772,9 +60772,8 @@ public void onSuccess(byte[] tlv) {
public static class EcosystemInformationCluster extends BaseChipCluster {
public static final long CLUSTER_ID = 1872L;

private static final long REMOVED_ON_ATTRIBUTE_ID = 0L;
private static final long DEVICE_DIRECTORY_ATTRIBUTE_ID = 1L;
private static final long LOCATION_DIRECTORY_ATTRIBUTE_ID = 2L;
private static final long DEVICE_DIRECTORY_ATTRIBUTE_ID = 0L;
private static final long LOCATION_DIRECTORY_ATTRIBUTE_ID = 1L;
private static final long GENERATED_COMMAND_LIST_ATTRIBUTE_ID = 65528L;
private static final long ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID = 65529L;
private static final long EVENT_LIST_ATTRIBUTE_ID = 65530L;
Expand All @@ -60792,10 +60791,6 @@ public long initWithDevice(long devicePtr, int endpointId) {
return 0L;
}

public interface RemovedOnAttributeCallback extends BaseAttributeCallback {
void onSuccess(@Nullable Long value);
}

public interface DeviceDirectoryAttributeCallback extends BaseAttributeCallback {
void onSuccess(List<ChipStructs.EcosystemInformationClusterEcosystemDeviceStruct> value);
}
Expand All @@ -60820,32 +60815,6 @@ public interface AttributeListAttributeCallback extends BaseAttributeCallback {
void onSuccess(List<Long> value);
}

public void readRemovedOnAttribute(
RemovedOnAttributeCallback callback) {
ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, REMOVED_ON_ATTRIBUTE_ID);

readAttribute(new ReportCallbackImpl(callback, path) {
@Override
public void onSuccess(byte[] tlv) {
@Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
callback.onSuccess(value);
}
}, REMOVED_ON_ATTRIBUTE_ID, true);
}

public void subscribeRemovedOnAttribute(
RemovedOnAttributeCallback callback, int minInterval, int maxInterval) {
ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, REMOVED_ON_ATTRIBUTE_ID);

subscribeAttribute(new ReportCallbackImpl(callback, path) {
@Override
public void onSuccess(byte[] tlv) {
@Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
callback.onSuccess(value);
}
}, REMOVED_ON_ATTRIBUTE_ID, minInterval, maxInterval);
}

public void readDeviceDirectoryAttribute(
DeviceDirectoryAttributeCallback callback) {
readDeviceDirectoryAttributeWithFabricFilter(callback, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17238,9 +17238,8 @@ public long getID() {
}

public enum Attribute {
RemovedOn(0L),
DeviceDirectory(1L),
LocationDirectory(2L),
DeviceDirectory(0L),
LocationDirectory(1L),
GeneratedCommandList(65528L),
AcceptedCommandList(65529L),
EventList(65530L),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20222,27 +20222,6 @@ public void onError(Exception ex) {
}
}

public static class DelegatedEcosystemInformationClusterRemovedOnAttributeCallback implements ChipClusters.EcosystemInformationCluster.RemovedOnAttributeCallback, DelegatedClusterCallback {
private ClusterCommandCallback callback;
@Override
public void setCallbackDelegate(ClusterCommandCallback callback) {
this.callback = callback;
}

@Override
public void onSuccess(@Nullable Long value) {
Map<CommandResponseInfo, Object> responseValues = new LinkedHashMap<>();
CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long");
responseValues.put(commandResponseInfo, value);
callback.onSuccess(responseValues);
}

@Override
public void onError(Exception ex) {
callback.onFailure(ex);
}
}

public static class DelegatedEcosystemInformationClusterDeviceDirectoryAttributeCallback implements ChipClusters.EcosystemInformationCluster.DeviceDirectoryAttributeCallback, DelegatedClusterCallback {
private ClusterCommandCallback callback;
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18678,18 +18678,7 @@ private static Map<String, InteractionInfo> readContentAppObserverInteractionInf
return result;
}
private static Map<String, InteractionInfo> readEcosystemInformationInteractionInfo() {
Map<String, InteractionInfo> result = new LinkedHashMap<>();Map<String, CommandParameterInfo> readEcosystemInformationRemovedOnCommandParams = new LinkedHashMap<String, CommandParameterInfo>();
InteractionInfo readEcosystemInformationRemovedOnAttributeInteractionInfo = new InteractionInfo(
(cluster, callback, commandArguments) -> {
((ChipClusters.EcosystemInformationCluster) cluster).readRemovedOnAttribute(
(ChipClusters.EcosystemInformationCluster.RemovedOnAttributeCallback) callback
);
},
() -> new ClusterInfoMapping.DelegatedEcosystemInformationClusterRemovedOnAttributeCallback(),
readEcosystemInformationRemovedOnCommandParams
);
result.put("readRemovedOnAttribute", readEcosystemInformationRemovedOnAttributeInteractionInfo);
Map<String, CommandParameterInfo> readEcosystemInformationDeviceDirectoryCommandParams = new LinkedHashMap<String, CommandParameterInfo>();
Map<String, InteractionInfo> result = new LinkedHashMap<>();Map<String, CommandParameterInfo> readEcosystemInformationDeviceDirectoryCommandParams = new LinkedHashMap<String, CommandParameterInfo>();
InteractionInfo readEcosystemInformationDeviceDirectoryAttributeInteractionInfo = new InteractionInfo(
(cluster, callback, commandArguments) -> {
((ChipClusters.EcosystemInformationCluster) cluster).readDeviceDirectoryAttribute(
Expand Down
Loading

0 comments on commit 7d6da7c

Please sign in to comment.