Skip to content

Commit

Permalink
Preliminary support for the Android controller
Browse files Browse the repository at this point in the history
  • Loading branch information
mkardous-silabs committed Jun 17, 2024
1 parent ed59d46 commit 3c0a630
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/controller/java/AndroidDeviceControllerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,12 @@ CHIP_ERROR AndroidDeviceControllerWrapper::ApplyICDRegistrationInfo(chip::Contro
VerifyOrReturnError(err == CHIP_NO_ERROR, err);
jbyteArray jSymmetricKey = static_cast<jbyteArray>(env->CallObjectMethod(icdRegistrationInfo, getSymmetricKeyMethod));

jmethodID getClientTypeMethod;
err = chip::JniReferences::GetInstance().FindMethod(env, icdRegistrationInfo, "getClientType", "()Ljava/lang/Short",
&getClientTypeMethod);
VerifyOrReturnError(err == CHIP_NO_ERROR, err);
jobject jClientType = env->CallObjectMethod(icdRegistrationInfo, getClientTypeMethod);

chip::NodeId checkInNodeId = chip::kUndefinedNodeId;
if (jCheckInNodeId != nullptr)
{
Expand Down Expand Up @@ -556,6 +562,12 @@ CHIP_ERROR AndroidDeviceControllerWrapper::ApplyICDRegistrationInfo(chip::Contro
}
params.SetICDSymmetricKey(chip::ByteSpan(mICDSymmetricKey));

chip::app::Clusters::IcdManagement::ClientTypeEnum clientType = chip::app::Clusters::IcdManagement::ClientTypeEnum::kPermanent;
if (jClientType != nullptr)
{
clientType = static_cast<chip::app::Clusters::IcdManagement::ClientTypeEnum>(jClientType)
}

return err;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ public class ICDRegistrationInfo {
@Nullable private final Long checkInNodeId;
@Nullable private final Long monitoredSubject;
@Nullable private final byte[] symmetricKey;
@Nullable private final Short clientType;

private ICDRegistrationInfo(Builder builder) {
this.checkInNodeId = builder.checkInNodeId;
this.monitoredSubject = builder.monitoredSubject;
this.symmetricKey = builder.symmetricKey;
this.clientType = builder.clientType;
}

/** Returns the check in node ID. */
Expand All @@ -46,6 +48,10 @@ public byte[] getSymmetricKey() {
return symmetricKey;
}

public Short getClientType() {
reutnr clientType;
}

public static Builder newBuilder() {
return new Builder();
}
Expand All @@ -55,6 +61,7 @@ public static class Builder {
@Nullable private Long checkInNodeId = null;
@Nullable private Long monitoredSubject = null;
@Nullable private byte[] symmetricKey = null;
@Nullable private Short clientType = null;

private Builder() {}

Expand All @@ -81,6 +88,11 @@ public Builder setSymmetricKey(byte[] symmetricKey) {
return this;
}

public Builder setClientType(Short clientType) {
this.clientType = clientType;
return this;
}

public ICDRegistrationInfo build() {
return new ICDRegistrationInfo(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ void ScriptDevicePairingDelegate::OnICDRegistrationComplete(ScopedNodeId nodeId,
clientInfo.peer_node = nodeId;
clientInfo.monitored_subject = sCommissioningParameters.GetICDMonitoredSubject().Value();
clientInfo.start_icd_counter = icdCounter;
clientInfo.client_type = sCommissioningParameters.GetICDClientType().Value();

CHIP_ERROR err = sICDClientStorage.SetKey(clientInfo, ByteSpan(sICDSymmetricKey));
if (err == CHIP_NO_ERROR)
Expand Down

0 comments on commit 3c0a630

Please sign in to comment.