Skip to content

Commit

Permalink
Add missing support for returning credential data in GetCredentialSt…
Browse files Browse the repository at this point in the history
…atusResponse. (#35732)

* Add missing support for returning credential data in GetCredentialStatusResponse.

* Regenerate generated code.
  • Loading branch information
bzbarsky-apple authored Sep 24, 2024
1 parent d3b645e commit b6a1304
Show file tree
Hide file tree
Showing 21 changed files with 103 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3464,6 +3464,7 @@ cluster DoorLock = 257 {
nullable fabric_idx creatorFabricIndex = 2;
nullable fabric_idx lastModifiedFabricIndex = 3;
nullable int16u nextCredentialIndex = 4;
optional nullable octet_string credentialData = 5;
}

request struct ClearCredentialRequest {
Expand Down
1 change: 1 addition & 0 deletions examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2301,6 +2301,7 @@ cluster DoorLock = 257 {
nullable fabric_idx creatorFabricIndex = 2;
nullable fabric_idx lastModifiedFabricIndex = 3;
nullable int16u nextCredentialIndex = 4;
optional nullable octet_string credentialData = 5;
}

request struct ClearCredentialRequest {
Expand Down
1 change: 1 addition & 0 deletions examples/lock-app/lock-common/lock-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2728,6 +2728,7 @@ cluster DoorLock = 257 {
nullable fabric_idx creatorFabricIndex = 2;
nullable fabric_idx lastModifiedFabricIndex = 3;
nullable int16u nextCredentialIndex = 4;
optional nullable octet_string credentialData = 5;
}

request struct ClearCredentialRequest {
Expand Down
1 change: 1 addition & 0 deletions examples/lock-app/nxp/zap/lock-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2304,6 +2304,7 @@ cluster DoorLock = 257 {
nullable fabric_idx creatorFabricIndex = 2;
nullable fabric_idx lastModifiedFabricIndex = 3;
nullable int16u nextCredentialIndex = 4;
optional nullable octet_string credentialData = 5;
}

request struct ClearCredentialRequest {
Expand Down
1 change: 1 addition & 0 deletions examples/lock-app/qpg/zap/lock.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2401,6 +2401,7 @@ cluster DoorLock = 257 {
nullable fabric_idx creatorFabricIndex = 2;
nullable fabric_idx lastModifiedFabricIndex = 3;
nullable int16u nextCredentialIndex = 4;
optional nullable octet_string credentialData = 5;
}

request struct ClearCredentialRequest {
Expand Down
2 changes: 2 additions & 0 deletions examples/placeholder/linux/apps/app1/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -4098,6 +4098,7 @@ cluster DoorLock = 257 {
nullable fabric_idx creatorFabricIndex = 2;
nullable fabric_idx lastModifiedFabricIndex = 3;
nullable int16u nextCredentialIndex = 4;
optional nullable octet_string credentialData = 5;
}

request struct ClearCredentialRequest {
Expand Down Expand Up @@ -4749,6 +4750,7 @@ cluster DoorLock = 257 {
nullable fabric_idx creatorFabricIndex = 2;
nullable fabric_idx lastModifiedFabricIndex = 3;
nullable int16u nextCredentialIndex = 4;
optional nullable octet_string credentialData = 5;
}

request struct ClearCredentialRequest {
Expand Down
2 changes: 2 additions & 0 deletions examples/placeholder/linux/apps/app2/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -4055,6 +4055,7 @@ cluster DoorLock = 257 {
nullable fabric_idx creatorFabricIndex = 2;
nullable fabric_idx lastModifiedFabricIndex = 3;
nullable int16u nextCredentialIndex = 4;
optional nullable octet_string credentialData = 5;
}

request struct ClearCredentialRequest {
Expand Down Expand Up @@ -4706,6 +4707,7 @@ cluster DoorLock = 257 {
nullable fabric_idx creatorFabricIndex = 2;
nullable fabric_idx lastModifiedFabricIndex = 3;
nullable int16u nextCredentialIndex = 4;
optional nullable octet_string credentialData = 5;
}

request struct ClearCredentialRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2939,6 +2939,7 @@ cluster DoorLock = 257 {
nullable fabric_idx creatorFabricIndex = 2;
nullable fabric_idx lastModifiedFabricIndex = 3;
nullable int16u nextCredentialIndex = 4;
optional nullable octet_string credentialData = 5;
}

request struct ClearCredentialRequest {
Expand Down
23 changes: 23 additions & 0 deletions src/app/clusters/door-lock-server/door-lock-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,21 @@ void DoorLockServer::getCredentialStatusCommandHandler(chip::app::CommandHandler
credentialExists);
}

namespace {
bool IsAliroCredentialType(CredentialTypeEnum credentialType)
{
switch (credentialType)
{
case CredentialTypeEnum::kAliroCredentialIssuerKey:
case CredentialTypeEnum::kAliroEvictableEndpointKey:
case CredentialTypeEnum::kAliroNonEvictableEndpointKey:
return true;
default:
return false;
}
}
} // anonymous namespace

void DoorLockServer::sendGetCredentialResponse(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath,
CredentialTypeEnum credentialType, uint16_t credentialIndex,
Expand All @@ -921,10 +936,18 @@ void DoorLockServer::sendGetCredentialResponse(chip::app::CommandHandler * comma
{
response.lastModifiedFabricIndex.SetNonNull(credentialInfo->lastModifiedBy);
}
if (IsAliroCredentialType(credentialType))
{
response.credentialData.Emplace(credentialInfo->credentialData);
}
}
else
{
response.userIndex.SetNull();
if (IsAliroCredentialType(credentialType))
{
response.credentialData.Emplace(NullNullable);
}
}
uint16_t nextCredentialIndex = 0;
if (findOccupiedCredentialSlot(commandPath.mEndpointId, credentialType, static_cast<uint16_t>(credentialIndex + 1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ limitations under the License.
<arg name="CreatorFabricIndex" type="fabric_idx" isNullable="true" />
<arg name="LastModifiedFabricIndex" type="fabric_idx" isNullable="true" />
<arg name="NextCredentialIndex" type="int16u" isNullable="true" />
<arg name="CredentialData" type="octet_string" isNullable="true" optional="true" />
</command>
<!-- Conformance feature USR - for now optional -->
<command source="client" code="38" name="ClearCredential" mustUseTimedInvoke="true" optional="true">
Expand Down
1 change: 1 addition & 0 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -6263,6 +6263,7 @@ cluster DoorLock = 257 {
nullable fabric_idx creatorFabricIndex = 2;
nullable fabric_idx lastModifiedFabricIndex = 3;
nullable int16u nextCredentialIndex = 4;
optional nullable octet_string credentialData = 5;
}

request struct ClearCredentialRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35125,6 +35125,8 @@ public void onResponse(StructType invokeStructValue) {
@Nullable Integer lastModifiedFabricIndex = null;
final long nextCredentialIndexFieldID = 4L;
@Nullable Integer nextCredentialIndex = null;
final long credentialDataFieldID = 5L;
@Nullable Optional<byte[]> credentialData = null;
for (StructElement element: invokeStructValue.value()) {
if (element.contextTagNum() == credentialExistsFieldID) {
if (element.value(BaseTLVType.class).type() == TLVType.Boolean) {
Expand All @@ -35151,9 +35153,14 @@ public void onResponse(StructType invokeStructValue) {
UIntType castingValue = element.value(UIntType.class);
nextCredentialIndex = castingValue.value(Integer.class);
}
} else if (element.contextTagNum() == credentialDataFieldID) {
if (element.value(BaseTLVType.class).type() == TLVType.ByteArray) {
ByteArrayType castingValue = element.value(ByteArrayType.class);
credentialData = Optional.of(castingValue.value(byte[].class));
}
}
}
callback.onSuccess(credentialExists, userIndex, creatorFabricIndex, lastModifiedFabricIndex, nextCredentialIndex);
callback.onSuccess(credentialExists, userIndex, creatorFabricIndex, lastModifiedFabricIndex, nextCredentialIndex, credentialData);
}}, commandId, commandArgs, timedInvokeTimeoutMs);
}

Expand Down Expand Up @@ -35254,7 +35261,7 @@ public interface SetCredentialResponseCallback extends BaseClusterCallback {
}

public interface GetCredentialStatusResponseCallback extends BaseClusterCallback {
void onSuccess(Boolean credentialExists, @Nullable Integer userIndex, @Nullable Integer creatorFabricIndex, @Nullable Integer lastModifiedFabricIndex, @Nullable Integer nextCredentialIndex);
void onSuccess(Boolean credentialExists, @Nullable Integer userIndex, @Nullable Integer creatorFabricIndex, @Nullable Integer lastModifiedFabricIndex, @Nullable Integer nextCredentialIndex, @Nullable Optional<byte[]> credentialData);
}

public interface LockStateAttributeCallback extends BaseAttributeCallback {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12382,7 +12382,7 @@ public void setCallbackDelegate(ClusterCommandCallback callback) {
}

@Override
public void onSuccess(Boolean credentialExists, @Nullable Integer userIndex, @Nullable Integer creatorFabricIndex, @Nullable Integer lastModifiedFabricIndex, @Nullable Integer nextCredentialIndex) {
public void onSuccess(Boolean credentialExists, @Nullable Integer userIndex, @Nullable Integer creatorFabricIndex, @Nullable Integer lastModifiedFabricIndex, @Nullable Integer nextCredentialIndex, @Nullable Optional<byte[]> credentialData) {
Map<CommandResponseInfo, Object> responseValues = new LinkedHashMap<>();

CommandResponseInfo credentialExistsResponseValue = new CommandResponseInfo("credentialExists", "Boolean");
Expand All @@ -12395,6 +12395,8 @@ public void onSuccess(Boolean credentialExists, @Nullable Integer userIndex, @Nu
responseValues.put(lastModifiedFabricIndexResponseValue, lastModifiedFabricIndex);
CommandResponseInfo nextCredentialIndexResponseValue = new CommandResponseInfo("nextCredentialIndex", "Integer");
responseValues.put(nextCredentialIndexResponseValue, nextCredentialIndex);
CommandResponseInfo credentialDataResponseValue = new CommandResponseInfo("credentialData", "Optional<byte[]>");
responseValues.put(credentialDataResponseValue, credentialData);
callback.onSuccess(responseValues);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp
val creatorFabricIndex: UByte?,
val lastModifiedFabricIndex: UByte?,
val nextCredentialIndex: UShort?,
val credentialData: ByteArray?,
)

class LockStateAttribute(val value: UByte?)
Expand Down Expand Up @@ -1320,6 +1321,9 @@ class DoorLockCluster(private val controller: MatterController, private val endp
val TAG_NEXT_CREDENTIAL_INDEX: Int = 4
var nextCredentialIndex_decoded: UShort? = null

val TAG_CREDENTIAL_DATA: Int = 5
var credentialData_decoded: ByteArray? = null

while (!tlvReader.isEndOfContainer()) {
val tag = tlvReader.peekElement().tag

Expand Down Expand Up @@ -1385,6 +1389,25 @@ class DoorLockCluster(private val controller: MatterController, private val endp
null
}
}
}

if (tag == ContextSpecificTag(TAG_CREDENTIAL_DATA)) {
credentialData_decoded =
if (tlvReader.isNull()) {
tlvReader.getNull(tag)
null
} else {
if (!tlvReader.isNull()) {
if (tlvReader.isNextTag(tag)) {
tlvReader.getByteArray(tag)
} else {
null
}
} else {
tlvReader.getNull(tag)
null
}
}
} else {
tlvReader.skipElement()
}
Expand All @@ -1402,6 +1425,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp
creatorFabricIndex_decoded,
lastModifiedFabricIndex_decoded,
nextCredentialIndex_decoded,
credentialData_decoded,
)
}

Expand Down
2 changes: 2 additions & 0 deletions src/controller/python/chip/clusters/Objects.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/darwin/Framework/CHIP/templates/availability.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9803,6 +9803,10 @@
- GlobalEchoResponse
- StringEchoRequest
- StringEchoResponse
command fields:
DoorLock:
GetCredentialStatusResponse:
- credentialData
structs:
AccessControl:
# Targeting 1.4
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b6a1304

Please sign in to comment.