Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CommissionerControlCluster xml definition to align with spec #35272

Merged
merged 2 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1730,8 +1730,6 @@ provisional cluster CommissionerControl = 1873 {
request struct CommissionNodeRequest {
int64u requestId = 0;
int16u responseTimeoutSeconds = 1;
optional octet_string ipAddress = 2;
optional int16u port = 3;
}

response struct ReverseOpenCommissioningWindow = 2 {
Expand Down
3 changes: 1 addition & 2 deletions examples/fabric-bridge-app/linux/CommissionerControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ CHIP_ERROR CommissionerControlDelegate::GetCommissioningWindowParams(Commissioni
return CHIP_NO_ERROR;
}

CHIP_ERROR CommissionerControlDelegate::HandleCommissionNode(const CommissioningWindowParams & params,
const Optional<ByteSpan> & ipAddress, const Optional<uint16_t> & port)
CHIP_ERROR CommissionerControlDelegate::HandleCommissionNode(const CommissioningWindowParams & params)
{
CHIP_ERROR err = CHIP_NO_ERROR;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class CommissionerControlDelegate : public Delegate
CHIP_ERROR HandleCommissioningApprovalRequest(const CommissioningApprovalRequest & request) override;
CHIP_ERROR ValidateCommissionNodeCommand(NodeId clientNodeId, uint64_t requestId) override;
CHIP_ERROR GetCommissioningWindowParams(CommissioningWindowParams & outParams) override;
CHIP_ERROR HandleCommissionNode(const CommissioningWindowParams & params, const Optional<ByteSpan> & ipAddress,
const Optional<uint16_t> & port) override;
CHIP_ERROR HandleCommissionNode(const CommissioningWindowParams & params) override;

~CommissionerControlDelegate() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ void AddReverseOpenCommissioningWindowResponse(CommandHandler * commandObj, cons

void RunDeferredCommissionNode(intptr_t commandArg)
{
auto * info = reinterpret_cast<Clusters::CommissionerControl::CommissionNodeInfo *>(commandArg);
auto * params = reinterpret_cast<Clusters::CommissionerControl::CommissioningWindowParams *>(commandArg);

Clusters::CommissionerControl::Delegate * delegate =
Clusters::CommissionerControl::CommissionerControlServer::Instance().GetDelegate();

if (delegate != nullptr)
{
CHIP_ERROR err = delegate->HandleCommissionNode(info->params, info->ipAddress.GetIPAddress(), info->port);
CHIP_ERROR err = delegate->HandleCommissionNode(*params);
if (err != CHIP_NO_ERROR)
{
ChipLogError(Zcl, "HandleCommissionNode error: %" CHIP_ERROR_FORMAT, err.Format());
Expand All @@ -82,7 +82,7 @@ void RunDeferredCommissionNode(intptr_t commandArg)
ChipLogError(Zcl, "No delegate available for HandleCommissionNode");
}

delete info;
delete params;
}

} // namespace
Expand Down Expand Up @@ -234,31 +234,27 @@ bool emberAfCommissionerControlClusterCommissionNodeCallback(

auto requestId = commandData.requestId;

auto commissionNodeInfo = std::make_unique<Clusters::CommissionerControl::CommissionNodeInfo>();
auto commissioningWindowParams = std::make_unique<Clusters::CommissionerControl::CommissioningWindowParams>();

Clusters::CommissionerControl::Delegate * delegate =
Clusters::CommissionerControl::CommissionerControlServer::Instance().GetDelegate();

VerifyOrExit(delegate != nullptr, err = CHIP_ERROR_INCORRECT_STATE);

// Set IP address and port in the CommissionNodeInfo struct
commissionNodeInfo->port = commandData.port;
err = commissionNodeInfo->ipAddress.SetIPAddress(commandData.ipAddress);
SuccessOrExit(err);

// Validate the commission node command.
err = delegate->ValidateCommissionNodeCommand(sourceNodeId, requestId);
SuccessOrExit(err);

// Populate the parameters for the commissioning window
err = delegate->GetCommissioningWindowParams(commissionNodeInfo->params);
err = delegate->GetCommissioningWindowParams(*commissioningWindowParams);
SuccessOrExit(err);

// Add the response for the commissioning window.
AddReverseOpenCommissioningWindowResponse(commandObj, commandPath, commissionNodeInfo->params);
AddReverseOpenCommissioningWindowResponse(commandObj, commandPath, *commissioningWindowParams);

// Schedule the deferred reverse commission node task
DeviceLayer::PlatformMgr().ScheduleWork(RunDeferredCommissionNode, reinterpret_cast<intptr_t>(commissionNodeInfo.release()));
DeviceLayer::PlatformMgr().ScheduleWork(RunDeferredCommissionNode,
reinterpret_cast<intptr_t>(commissioningWindowParams.release()));

exit:
if (err != CHIP_NO_ERROR)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,43 +46,6 @@ struct CommissioningWindowParams
ByteSpan salt;
};

class ProtectedIPAddress
{
public:
const Optional<ByteSpan> GetIPAddress() { return ipAddress; }

CHIP_ERROR SetIPAddress(const Optional<ByteSpan> & address)
{
if (!address.HasValue())
{
ipAddress.ClearValue();
return CHIP_NO_ERROR;
}

const ByteSpan & addressSpan = address.Value();
size_t addressLength = addressSpan.size();
if (addressLength != 4 && addressLength != 16)
{
return CHIP_ERROR_INVALID_ARGUMENT;
}

memcpy(ipAddressBuffer, addressSpan.data(), addressLength);
ipAddress.SetValue(ByteSpan(ipAddressBuffer, addressLength));
return CHIP_NO_ERROR;
}

private:
Optional<ByteSpan> ipAddress;
uint8_t ipAddressBuffer[kIpAddressBufferSize];
};

struct CommissionNodeInfo
{
CommissioningWindowParams params;
ProtectedIPAddress ipAddress;
Optional<uint16_t> port;
};

class Delegate
{
public:
Expand Down Expand Up @@ -130,12 +93,9 @@ class Delegate
* Commission a node specified by the previously approved request.
*
* @param params The parameters for the commissioning window.
* @param ipAddress Optional IP address for the commissioning window.
* @param port Optional port for the commissioning window.
* @return CHIP_ERROR indicating the success or failure of the operation.
*/
virtual CHIP_ERROR HandleCommissionNode(const CommissioningWindowParams & params, const Optional<ByteSpan> & ipAddress,
const Optional<uint16_t> & port) = 0;
virtual CHIP_ERROR HandleCommissionNode(const CommissioningWindowParams & params) = 0;

virtual ~Delegate() = default;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ limitations under the License.
<command source="client" code="0x01" name="CommissionNode" response="ReverseOpenCommissioningWindow" optional="false">
<description>This command is sent by a client to request that the server begins commissioning a previously approved request.</description>
<arg id="0" name="RequestId" type="int64u"/>
<arg id="2" name="ResponseTimeoutSeconds" type="int16u" min="30" max="120" default="30"/>
<arg id="3" name="IpAddress" type="octet_string" optional="true" min="4" max="16"/>
<!-- Note: ipadr is not supported yet, use its base type (octet_string) here -->
<arg id="4" name="Port" type="int16u" optional="true"/>
<arg id="1" name="ResponseTimeoutSeconds" type="int16u" min="30" max="120" default="30"/>
<access op="invoke" privilege="manage"/>
</command>

Expand Down
2 changes: 0 additions & 2 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -9450,8 +9450,6 @@ provisional cluster CommissionerControl = 1873 {
request struct CommissionNodeRequest {
int64u requestId = 0;
int16u responseTimeoutSeconds = 1;
optional octet_string ipAddress = 2;
optional int16u port = 3;
}

response struct ReverseOpenCommissioningWindow = 2 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61087,11 +61087,11 @@ public void onResponse(StructType invokeStructValue) {
}}, commandId, commandArgs, timedInvokeTimeoutMs);
}

public void commissionNode(ReverseOpenCommissioningWindowCallback callback, Long requestId, Integer responseTimeoutSeconds, Optional<byte[]> ipAddress, Optional<Integer> port) {
commissionNode(callback, requestId, responseTimeoutSeconds, ipAddress, port, 0);
public void commissionNode(ReverseOpenCommissioningWindowCallback callback, Long requestId, Integer responseTimeoutSeconds) {
commissionNode(callback, requestId, responseTimeoutSeconds, 0);
}

public void commissionNode(ReverseOpenCommissioningWindowCallback callback, Long requestId, Integer responseTimeoutSeconds, Optional<byte[]> ipAddress, Optional<Integer> port, int timedInvokeTimeoutMs) {
public void commissionNode(ReverseOpenCommissioningWindowCallback callback, Long requestId, Integer responseTimeoutSeconds, int timedInvokeTimeoutMs) {
final long commandId = 1L;

ArrayList<StructElement> elements = new ArrayList<>();
Expand All @@ -61103,14 +61103,6 @@ public void commissionNode(ReverseOpenCommissioningWindowCallback callback, Long
BaseTLVType responseTimeoutSecondstlvValue = new UIntType(responseTimeoutSeconds);
elements.add(new StructElement(responseTimeoutSecondsFieldID, responseTimeoutSecondstlvValue));

final long ipAddressFieldID = 2L;
BaseTLVType ipAddresstlvValue = ipAddress.<BaseTLVType>map((nonOptionalipAddress) -> new ByteArrayType(nonOptionalipAddress)).orElse(new EmptyType());
elements.add(new StructElement(ipAddressFieldID, ipAddresstlvValue));

final long portFieldID = 3L;
BaseTLVType porttlvValue = port.<BaseTLVType>map((nonOptionalport) -> new UIntType(nonOptionalport)).orElse(new EmptyType());
elements.add(new StructElement(portFieldID, porttlvValue));

StructType commandArgs = new StructType(elements);
invoke(new InvokeCallbackImpl(callback) {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17424,7 +17424,7 @@ public static RequestCommissioningApprovalCommandField value(int id) throws NoSu
}
throw new NoSuchFieldError();
}
}public enum CommissionNodeCommandField {RequestId(0),ResponseTimeoutSeconds(1),IpAddress(2),Port(3),;
}public enum CommissionNodeCommandField {RequestId(0),ResponseTimeoutSeconds(1),;
private final int id;
CommissionNodeCommandField(int id) {
this.id = id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29046,12 +29046,6 @@ public Map<String, Map<String, InteractionInfo>> getCommandMap() {

CommandParameterInfo commissionerControlcommissionNoderesponseTimeoutSecondsCommandParameterInfo = new CommandParameterInfo("responseTimeoutSeconds", Integer.class, Integer.class);
commissionerControlcommissionNodeCommandParams.put("responseTimeoutSeconds",commissionerControlcommissionNoderesponseTimeoutSecondsCommandParameterInfo);

CommandParameterInfo commissionerControlcommissionNodeipAddressCommandParameterInfo = new CommandParameterInfo("ipAddress", Optional.class, byte[].class);
commissionerControlcommissionNodeCommandParams.put("ipAddress",commissionerControlcommissionNodeipAddressCommandParameterInfo);

CommandParameterInfo commissionerControlcommissionNodeportCommandParameterInfo = new CommandParameterInfo("port", Optional.class, Integer.class);
commissionerControlcommissionNodeCommandParams.put("port",commissionerControlcommissionNodeportCommandParameterInfo);
InteractionInfo commissionerControlcommissionNodeInteractionInfo = new InteractionInfo(
(cluster, callback, commandArguments) -> {
((ChipClusters.CommissionerControlCluster) cluster)
Expand All @@ -29062,12 +29056,6 @@ public Map<String, Map<String, InteractionInfo>> getCommandMap() {
, (Integer)
commandArguments.get("responseTimeoutSeconds")

, (Optional<byte[]>)
commandArguments.get("ipAddress")

, (Optional<Integer>)
commandArguments.get("port")

);
},
() -> new DelegatedCommissionerControlClusterReverseOpenCommissioningWindowCallback(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ class CommissionerControlCluster(
suspend fun commissionNode(
requestId: ULong,
responseTimeoutSeconds: UShort,
ipAddress: ByteArray?,
port: UShort?,
timedInvokeTimeout: Duration? = null,
): ReverseOpenCommissioningWindow {
val commandId: UInt = 1u
Expand All @@ -144,12 +142,6 @@ class CommissionerControlCluster(

val TAG_RESPONSE_TIMEOUT_SECONDS_REQ: Int = 1
tlvWriter.put(ContextSpecificTag(TAG_RESPONSE_TIMEOUT_SECONDS_REQ), responseTimeoutSeconds)

val TAG_IP_ADDRESS_REQ: Int = 2
ipAddress?.let { tlvWriter.put(ContextSpecificTag(TAG_IP_ADDRESS_REQ), ipAddress) }

val TAG_PORT_REQ: Int = 3
port?.let { tlvWriter.put(ContextSpecificTag(TAG_PORT_REQ), port) }
tlvWriter.endStructure()

val request: InvokeRequest =
Expand Down
2 changes: 0 additions & 2 deletions src/controller/python/chip/clusters/CHIPClusters.py

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

4 changes: 0 additions & 4 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.

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.

Loading
Loading