Skip to content

Commit 203f03a

Browse files
authored
Update CommissionerControlCluster xml definition to align with spec (project-chip#35272)
* Update CommissionerControlCluster xml defination to align with spec * Clean up commissioner-control-server
1 parent d256926 commit 203f03a

File tree

19 files changed

+17
-164
lines changed

19 files changed

+17
-164
lines changed

examples/fabric-bridge-app/fabric-bridge-common/fabric-bridge-app.matter

-2
Original file line numberDiff line numberDiff line change
@@ -1730,8 +1730,6 @@ provisional cluster CommissionerControl = 1873 {
17301730
request struct CommissionNodeRequest {
17311731
int64u requestId = 0;
17321732
int16u responseTimeoutSeconds = 1;
1733-
optional octet_string ipAddress = 2;
1734-
optional int16u port = 3;
17351733
}
17361734

17371735
response struct ReverseOpenCommissioningWindow = 2 {

examples/fabric-bridge-app/linux/CommissionerControl.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ CHIP_ERROR CommissionerControlDelegate::GetCommissioningWindowParams(Commissioni
166166
return CHIP_NO_ERROR;
167167
}
168168

169-
CHIP_ERROR CommissionerControlDelegate::HandleCommissionNode(const CommissioningWindowParams & params,
170-
const Optional<ByteSpan> & ipAddress, const Optional<uint16_t> & port)
169+
CHIP_ERROR CommissionerControlDelegate::HandleCommissionNode(const CommissioningWindowParams & params)
171170
{
172171
CHIP_ERROR err = CHIP_NO_ERROR;
173172

examples/fabric-bridge-app/linux/include/CommissionerControl.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ class CommissionerControlDelegate : public Delegate
3232
CHIP_ERROR HandleCommissioningApprovalRequest(const CommissioningApprovalRequest & request) override;
3333
CHIP_ERROR ValidateCommissionNodeCommand(NodeId clientNodeId, uint64_t requestId) override;
3434
CHIP_ERROR GetCommissioningWindowParams(CommissioningWindowParams & outParams) override;
35-
CHIP_ERROR HandleCommissionNode(const CommissioningWindowParams & params, const Optional<ByteSpan> & ipAddress,
36-
const Optional<uint16_t> & port) override;
35+
CHIP_ERROR HandleCommissionNode(const CommissioningWindowParams & params) override;
3736

3837
~CommissionerControlDelegate() = default;
3938

src/app/clusters/commissioner-control-server/commissioner-control-server.cpp

+8-12
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ void AddReverseOpenCommissioningWindowResponse(CommandHandler * commandObj, cons
6464

6565
void RunDeferredCommissionNode(intptr_t commandArg)
6666
{
67-
auto * info = reinterpret_cast<Clusters::CommissionerControl::CommissionNodeInfo *>(commandArg);
67+
auto * params = reinterpret_cast<Clusters::CommissionerControl::CommissioningWindowParams *>(commandArg);
6868

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

7272
if (delegate != nullptr)
7373
{
74-
CHIP_ERROR err = delegate->HandleCommissionNode(info->params, info->ipAddress.GetIPAddress(), info->port);
74+
CHIP_ERROR err = delegate->HandleCommissionNode(*params);
7575
if (err != CHIP_NO_ERROR)
7676
{
7777
ChipLogError(Zcl, "HandleCommissionNode error: %" CHIP_ERROR_FORMAT, err.Format());
@@ -82,7 +82,7 @@ void RunDeferredCommissionNode(intptr_t commandArg)
8282
ChipLogError(Zcl, "No delegate available for HandleCommissionNode");
8383
}
8484

85-
delete info;
85+
delete params;
8686
}
8787

8888
} // namespace
@@ -234,31 +234,27 @@ bool emberAfCommissionerControlClusterCommissionNodeCallback(
234234

235235
auto requestId = commandData.requestId;
236236

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

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

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

244-
// Set IP address and port in the CommissionNodeInfo struct
245-
commissionNodeInfo->port = commandData.port;
246-
err = commissionNodeInfo->ipAddress.SetIPAddress(commandData.ipAddress);
247-
SuccessOrExit(err);
248-
249244
// Validate the commission node command.
250245
err = delegate->ValidateCommissionNodeCommand(sourceNodeId, requestId);
251246
SuccessOrExit(err);
252247

253248
// Populate the parameters for the commissioning window
254-
err = delegate->GetCommissioningWindowParams(commissionNodeInfo->params);
249+
err = delegate->GetCommissioningWindowParams(*commissioningWindowParams);
255250
SuccessOrExit(err);
256251

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

260255
// Schedule the deferred reverse commission node task
261-
DeviceLayer::PlatformMgr().ScheduleWork(RunDeferredCommissionNode, reinterpret_cast<intptr_t>(commissionNodeInfo.release()));
256+
DeviceLayer::PlatformMgr().ScheduleWork(RunDeferredCommissionNode,
257+
reinterpret_cast<intptr_t>(commissioningWindowParams.release()));
262258

263259
exit:
264260
if (err != CHIP_NO_ERROR)

src/app/clusters/commissioner-control-server/commissioner-control-server.h

+1-41
Original file line numberDiff line numberDiff line change
@@ -46,43 +46,6 @@ struct CommissioningWindowParams
4646
ByteSpan salt;
4747
};
4848

49-
class ProtectedIPAddress
50-
{
51-
public:
52-
const Optional<ByteSpan> GetIPAddress() { return ipAddress; }
53-
54-
CHIP_ERROR SetIPAddress(const Optional<ByteSpan> & address)
55-
{
56-
if (!address.HasValue())
57-
{
58-
ipAddress.ClearValue();
59-
return CHIP_NO_ERROR;
60-
}
61-
62-
const ByteSpan & addressSpan = address.Value();
63-
size_t addressLength = addressSpan.size();
64-
if (addressLength != 4 && addressLength != 16)
65-
{
66-
return CHIP_ERROR_INVALID_ARGUMENT;
67-
}
68-
69-
memcpy(ipAddressBuffer, addressSpan.data(), addressLength);
70-
ipAddress.SetValue(ByteSpan(ipAddressBuffer, addressLength));
71-
return CHIP_NO_ERROR;
72-
}
73-
74-
private:
75-
Optional<ByteSpan> ipAddress;
76-
uint8_t ipAddressBuffer[kIpAddressBufferSize];
77-
};
78-
79-
struct CommissionNodeInfo
80-
{
81-
CommissioningWindowParams params;
82-
ProtectedIPAddress ipAddress;
83-
Optional<uint16_t> port;
84-
};
85-
8649
class Delegate
8750
{
8851
public:
@@ -130,12 +93,9 @@ class Delegate
13093
* Commission a node specified by the previously approved request.
13194
*
13295
* @param params The parameters for the commissioning window.
133-
* @param ipAddress Optional IP address for the commissioning window.
134-
* @param port Optional port for the commissioning window.
13596
* @return CHIP_ERROR indicating the success or failure of the operation.
13697
*/
137-
virtual CHIP_ERROR HandleCommissionNode(const CommissioningWindowParams & params, const Optional<ByteSpan> & ipAddress,
138-
const Optional<uint16_t> & port) = 0;
98+
virtual CHIP_ERROR HandleCommissionNode(const CommissioningWindowParams & params) = 0;
13999

140100
virtual ~Delegate() = default;
141101
};

src/app/zap-templates/zcl/data-model/chip/commissioner-control-cluster.xml

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

src/controller/data_model/controller-clusters.matter

-2
Original file line numberDiff line numberDiff line change
@@ -9450,8 +9450,6 @@ provisional cluster CommissionerControl = 1873 {
94509450
request struct CommissionNodeRequest {
94519451
int64u requestId = 0;
94529452
int16u responseTimeoutSeconds = 1;
9453-
optional octet_string ipAddress = 2;
9454-
optional int16u port = 3;
94559453
}
94569454

94579455
response struct ReverseOpenCommissioningWindow = 2 {

src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java

+3-11
Original file line numberDiff line numberDiff line change
@@ -61087,11 +61087,11 @@ public void onResponse(StructType invokeStructValue) {
6108761087
}}, commandId, commandArgs, timedInvokeTimeoutMs);
6108861088
}
6108961089

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

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

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

61106-
final long ipAddressFieldID = 2L;
61107-
BaseTLVType ipAddresstlvValue = ipAddress.<BaseTLVType>map((nonOptionalipAddress) -> new ByteArrayType(nonOptionalipAddress)).orElse(new EmptyType());
61108-
elements.add(new StructElement(ipAddressFieldID, ipAddresstlvValue));
61109-
61110-
final long portFieldID = 3L;
61111-
BaseTLVType porttlvValue = port.<BaseTLVType>map((nonOptionalport) -> new UIntType(nonOptionalport)).orElse(new EmptyType());
61112-
elements.add(new StructElement(portFieldID, porttlvValue));
61113-
6111461106
StructType commandArgs = new StructType(elements);
6111561107
invoke(new InvokeCallbackImpl(callback) {
6111661108
@Override

src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17424,7 +17424,7 @@ public static RequestCommissioningApprovalCommandField value(int id) throws NoSu
1742417424
}
1742517425
throw new NoSuchFieldError();
1742617426
}
17427-
}public enum CommissionNodeCommandField {RequestId(0),ResponseTimeoutSeconds(1),IpAddress(2),Port(3),;
17427+
}public enum CommissionNodeCommandField {RequestId(0),ResponseTimeoutSeconds(1),;
1742817428
private final int id;
1742917429
CommissionNodeCommandField(int id) {
1743017430
this.id = id;

src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java

-12
Original file line numberDiff line numberDiff line change
@@ -29046,12 +29046,6 @@ public Map<String, Map<String, InteractionInfo>> getCommandMap() {
2904629046

2904729047
CommandParameterInfo commissionerControlcommissionNoderesponseTimeoutSecondsCommandParameterInfo = new CommandParameterInfo("responseTimeoutSeconds", Integer.class, Integer.class);
2904829048
commissionerControlcommissionNodeCommandParams.put("responseTimeoutSeconds",commissionerControlcommissionNoderesponseTimeoutSecondsCommandParameterInfo);
29049-
29050-
CommandParameterInfo commissionerControlcommissionNodeipAddressCommandParameterInfo = new CommandParameterInfo("ipAddress", Optional.class, byte[].class);
29051-
commissionerControlcommissionNodeCommandParams.put("ipAddress",commissionerControlcommissionNodeipAddressCommandParameterInfo);
29052-
29053-
CommandParameterInfo commissionerControlcommissionNodeportCommandParameterInfo = new CommandParameterInfo("port", Optional.class, Integer.class);
29054-
commissionerControlcommissionNodeCommandParams.put("port",commissionerControlcommissionNodeportCommandParameterInfo);
2905529049
InteractionInfo commissionerControlcommissionNodeInteractionInfo = new InteractionInfo(
2905629050
(cluster, callback, commandArguments) -> {
2905729051
((ChipClusters.CommissionerControlCluster) cluster)
@@ -29062,12 +29056,6 @@ public Map<String, Map<String, InteractionInfo>> getCommandMap() {
2906229056
, (Integer)
2906329057
commandArguments.get("responseTimeoutSeconds")
2906429058

29065-
, (Optional<byte[]>)
29066-
commandArguments.get("ipAddress")
29067-
29068-
, (Optional<Integer>)
29069-
commandArguments.get("port")
29070-
2907129059
);
2907229060
},
2907329061
() -> new DelegatedCommissionerControlClusterReverseOpenCommissioningWindowCallback(),

src/controller/java/generated/java/matter/controller/cluster/clusters/CommissionerControlCluster.kt

-8
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ class CommissionerControlCluster(
130130
suspend fun commissionNode(
131131
requestId: ULong,
132132
responseTimeoutSeconds: UShort,
133-
ipAddress: ByteArray?,
134-
port: UShort?,
135133
timedInvokeTimeout: Duration? = null,
136134
): ReverseOpenCommissioningWindow {
137135
val commandId: UInt = 1u
@@ -144,12 +142,6 @@ class CommissionerControlCluster(
144142

145143
val TAG_RESPONSE_TIMEOUT_SECONDS_REQ: Int = 1
146144
tlvWriter.put(ContextSpecificTag(TAG_RESPONSE_TIMEOUT_SECONDS_REQ), responseTimeoutSeconds)
147-
148-
val TAG_IP_ADDRESS_REQ: Int = 2
149-
ipAddress?.let { tlvWriter.put(ContextSpecificTag(TAG_IP_ADDRESS_REQ), ipAddress) }
150-
151-
val TAG_PORT_REQ: Int = 3
152-
port?.let { tlvWriter.put(ContextSpecificTag(TAG_PORT_REQ), port) }
153145
tlvWriter.endStructure()
154146

155147
val request: InvokeRequest =

src/controller/python/chip/clusters/CHIPClusters.py

-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/controller/python/chip/clusters/Objects.py

-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h

-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm

+1-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp

-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zzz_generated/app-common/app-common/zap-generated/cluster-objects.h

-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)