-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Matter.framework API for configuring MRP parameters. (#32548)
* Add a Matter.framework API for configuring MRP parameters. Also fixes a typo in the ReliableMessageMgr API Matter.framework uses. * Address review comment.
- Loading branch information
1 parent
deca2a0
commit bf7241d
Showing
13 changed files
with
334 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
examples/darwin-framework-tool/commands/configuration/Commands.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#import <Matter/Matter.h> | ||
|
||
#include "ResetMRPParametersCommand.h" | ||
#include "SetMRPParametersCommand.h" | ||
|
||
void registerCommandsConfiguration(Commands & commands) | ||
{ | ||
const char * clusterName = "Configuration"; | ||
|
||
commands_list clusterCommands = { | ||
make_unique<SetMRPParametersCommand>(), | ||
make_unique<ResetMRPParametersCommand>(), | ||
}; | ||
|
||
commands.RegisterCommandSet(clusterName, clusterCommands, "Commands for configuring various state of the Matter framework."); | ||
} |
35 changes: 35 additions & 0 deletions
35
examples/darwin-framework-tool/commands/configuration/ResetMRPParametersCommand.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#import <Matter/Matter.h> | ||
|
||
#include "../common/CHIPCommandBridge.h" | ||
|
||
class ResetMRPParametersCommand : public CHIPCommandBridge | ||
{ | ||
public: | ||
ResetMRPParametersCommand() : CHIPCommandBridge("reset-mrp-parameters", "Reset MRP parameters to default values.") {} | ||
|
||
protected: | ||
/////////// CHIPCommandBridge Interface ///////// | ||
CHIP_ERROR RunCommand() override; | ||
|
||
// Our command is synchronous, so no need to wait. | ||
chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::kZero; } | ||
}; |
24 changes: 24 additions & 0 deletions
24
examples/darwin-framework-tool/commands/configuration/ResetMRPParametersCommand.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "ResetMRPParametersCommand.h" | ||
|
||
CHIP_ERROR ResetMRPParametersCommand::RunCommand() | ||
{ | ||
MTRSetMessageReliabilityParameters(nil, nil, nil, nil); | ||
return CHIP_NO_ERROR; | ||
} |
52 changes: 52 additions & 0 deletions
52
examples/darwin-framework-tool/commands/configuration/SetMRPParametersCommand.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#import <Matter/Matter.h> | ||
|
||
#include "../common/CHIPCommandBridge.h" | ||
|
||
class SetMRPParametersCommand : public CHIPCommandBridge | ||
{ | ||
public: | ||
SetMRPParametersCommand() : | ||
CHIPCommandBridge("set-mrp-parameters", "Set various MRP parameters. At least one value must be provided.") | ||
{ | ||
AddArgument("idle-interval", 0, UINT32_MAX, &mIdleRetransmitMs, | ||
"Our MRP idle interval (SII) in milliseconds. Defaults to current value if not set."); | ||
AddArgument("active-interval", 0, UINT32_MAX, &mActiveRetransmitMs, | ||
"Our MRP active interval (SAI) in milliseconds. Defaults to current value if not set."); | ||
AddArgument("active-threshold", 0, UINT32_MAX, &mActiveThresholdMs, | ||
"Our MRP active threshold: how long we stay in active mode before transitioning to idle mode. Defaults to " | ||
"current value if not set."); | ||
AddArgument("additional-retransmit-delay", 0, UINT32_MAX, &mAdditionalRetransmitDelayMs, | ||
"Additional delay between retransmits that we do. Defaults to current value if not set."); | ||
} | ||
|
||
protected: | ||
/////////// CHIPCommandBridge Interface ///////// | ||
CHIP_ERROR RunCommand() override; | ||
|
||
// Our command is synchronous, so no need to wait. | ||
chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::kZero; } | ||
|
||
chip::Optional<uint32_t> mIdleRetransmitMs; | ||
chip::Optional<uint32_t> mActiveRetransmitMs; | ||
chip::Optional<uint32_t> mActiveThresholdMs; | ||
chip::Optional<uint64_t> mAdditionalRetransmitDelayMs; | ||
}; |
48 changes: 48 additions & 0 deletions
48
examples/darwin-framework-tool/commands/configuration/SetMRPParametersCommand.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "SetMRPParametersCommand.h" | ||
|
||
using namespace chip; | ||
|
||
namespace { | ||
|
||
template <typename T> | ||
NSNumber * _Nullable AsNumber(const Optional<T> & value) | ||
{ | ||
if (!value.HasValue()) { | ||
return nil; | ||
} | ||
|
||
return @(value.Value()); | ||
} | ||
|
||
} // anonymous namespace | ||
|
||
CHIP_ERROR SetMRPParametersCommand::RunCommand() | ||
{ | ||
if (!mIdleRetransmitMs.HasValue() && !mActiveRetransmitMs.HasValue() && !mActiveThresholdMs.HasValue() && !mAdditionalRetransmitDelayMs.HasValue()) { | ||
ChipLogError(chipTool, "set-mrp-parameters needs to have at least one argument provided"); | ||
return CHIP_ERROR_INVALID_ARGUMENT; | ||
} | ||
|
||
MTRSetMessageReliabilityParameters(AsNumber(mIdleRetransmitMs), | ||
AsNumber(mActiveRetransmitMs), | ||
AsNumber(mActiveThresholdMs), | ||
AsNumber(mAdditionalRetransmitDelayMs)); | ||
return CHIP_NO_ERROR; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.