Skip to content

Commit

Permalink
Merge branch 'master' into granbery/electrical_measurement
Browse files Browse the repository at this point in the history
  • Loading branch information
hasty authored Jan 31, 2024
2 parents 5ac33e5 + cd3e498 commit 94d96e4
Show file tree
Hide file tree
Showing 123 changed files with 3,947 additions and 440 deletions.
1 change: 1 addition & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ GPL
GPLv
Gradle
gradlew
graphviz
Groupcast
GroupId
GroupKeyManagement
Expand Down
17 changes: 14 additions & 3 deletions examples/all-clusters-app/all-clusters-common/src/rvc-modes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
#include <app-common/zap-generated/attributes/Accessors.h>
#include <rvc-modes.h>
#include <rvc-operational-state-delegate-impl.h>

using namespace chip::app::Clusters;
using namespace chip::app::Clusters::RvcRunMode;
Expand All @@ -40,14 +41,24 @@ void RvcRunModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands:
{
uint8_t currentMode = mInstance->GetCurrentMode();

// Our business logic states that we can only switch into the mapping state from the idle state.
if (NewMode == RvcRunMode::ModeMapping && currentMode != RvcRunMode::ModeIdle)
// Our business logic states that we can only switch into a running mode from the idle state.
if (NewMode != RvcRunMode::ModeIdle && currentMode != RvcRunMode::ModeIdle)
{
response.status = to_underlying(ModeBase::StatusCode::kInvalidInMode);
response.statusText.SetValue(chip::CharSpan::fromCharString("Change to the mapping mode is only allowed from idle"));
response.statusText.SetValue(chip::CharSpan::fromCharString("Change to a running mode is only allowed from idle"));
return;
}

auto rvcOpStateInstance = RvcOperationalState::GetRvcOperationalStateInstance();
if (NewMode == RvcRunMode::ModeIdle)
{
rvcOpStateInstance->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kStopped));
}
else
{
rvcOpStateInstance->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kRunning));
}

response.status = to_underlying(ModeBase::StatusCode::kSuccess);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/mode-support"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
Expand Down
30 changes: 30 additions & 0 deletions examples/chip-tool/commands/clusters/ModelCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "ModelCommand.h"

#include <app/InteractionModelEngine.h>
#include <app/icd/client/DefaultICDClientStorage.h>
#include <inttypes.h>

using namespace ::chip;
Expand All @@ -35,6 +36,7 @@ CHIP_ERROR ModelCommand::RunCommand()
}

ChipLogProgress(chipTool, "Sending command to node 0x%" PRIx64, mDestinationId);
CheckPeerICDType();

CommissioneeDeviceProxy * commissioneeDeviceProxy = nullptr;
if (CHIP_NO_ERROR == CurrentCommissioner().GetDeviceBeingCommissioned(mDestinationId, &commissioneeDeviceProxy))
Expand Down Expand Up @@ -73,3 +75,31 @@ void ModelCommand::Shutdown()

CHIPCommand::Shutdown();
}

void ModelCommand::CheckPeerICDType()
{
if (mIsPeerLIT.HasValue())
{
ChipLogProgress(chipTool, "Peer ICD type is set to %s", mIsPeerLIT.Value() == 1 ? "LIT-ICD" : "non LIT-ICD");
return;
}

app::ICDClientInfo info;
auto destinationPeerId = chip::ScopedNodeId(mDestinationId, CurrentCommissioner().GetFabricIndex());
auto iter = CHIPCommand::sICDClientStorage.IterateICDClientInfo();
if (iter == nullptr)
{
return;
}
app::DefaultICDClientStorage::ICDClientInfoIteratorWrapper clientInfoIteratorWrapper(iter);

while (iter->Next(info))
{
if (ScopedNodeId(info.peer_node.GetNodeId(), info.peer_node.GetFabricIndex()) == destinationPeerId)
{
ChipLogProgress(chipTool, "Peer is a registered LIT ICD.");
mIsPeerLIT.SetValue(true);
return;
}
}
}
9 changes: 9 additions & 0 deletions examples/chip-tool/commands/clusters/ModelCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class ModelCommand : public CHIPCommand
"Endpoint the command is targeted at.");
}
}
AddArgument(
"lit-icd-peer", 0, 1, &mIsPeerLIT,
"Whether to treat the peer as a LIT ICD. false: Always no, true: Always yes, (not set): Yes if the peer is registered "
"to this controller.");
AddArgument("timeout", 0, UINT16_MAX, &mTimeout);
}

Expand All @@ -66,11 +70,16 @@ class ModelCommand : public CHIPCommand
void Shutdown() override;

protected:
bool IsPeerLIT() { return mIsPeerLIT.ValueOr(false); }

chip::Optional<uint16_t> mTimeout;

private:
chip::NodeId mDestinationId;
std::vector<chip::EndpointId> mEndPointId;
chip::Optional<bool> mIsPeerLIT;

void CheckPeerICDType();

static void OnDeviceConnectedFn(void * context, chip::Messaging::ExchangeManager & exchangeMgr,
const chip::SessionHandle & sessionHandle);
Expand Down
3 changes: 3 additions & 0 deletions examples/chip-tool/commands/clusters/ReportCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ class SubscribeAttribute : public SubscribeCommand

CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector<chip::EndpointId> endpointIds) override
{
SubscribeCommand::SetPeerLIT(IsPeerLIT());
return SubscribeCommand::SubscribeAttribute(device, endpointIds, mClusterIds, mAttributeIds);
}

Expand Down Expand Up @@ -407,6 +408,7 @@ class SubscribeEvent : public SubscribeCommand

CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector<chip::EndpointId> endpointIds) override
{
SubscribeCommand::SetPeerLIT(IsPeerLIT());
return SubscribeCommand::SubscribeEvent(device, endpointIds, mClusterIds, mEventIds);
}

Expand Down Expand Up @@ -538,6 +540,7 @@ class SubscribeAll : public SubscribeCommand

CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector<chip::EndpointId> endpointIds) override
{
SubscribeCommand::SetPeerLIT(IsPeerLIT());
return SubscribeCommand::SubscribeAll(device, endpointIds, mClusterIds, mAttributeIds, mEventIds);
}

Expand Down
8 changes: 6 additions & 2 deletions examples/chip-tool/commands/icd/ICDCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "ICDCommand.h"

#include <app/icd/client/DefaultICDClientStorage.h>
#include <crypto/DefaultSessionKeystore.h>
#include <crypto/RawKeySessionKeystore.h>

Expand All @@ -29,6 +30,11 @@ CHIP_ERROR ICDListCommand::RunCommand()
auto iter = CHIPCommand::sICDClientStorage.IterateICDClientInfo();
char icdAesKeyHex[Crypto::kAES_CCM128_Key_Length * 2 + 1];
char icdHmacKeyHex[Crypto::kHMAC_CCM128_Key_Length * 2 + 1];
if (iter == nullptr)
{
return CHIP_ERROR_NO_MEMORY;
}
app::DefaultICDClientStorage::ICDClientInfoIteratorWrapper clientInfoIteratorWrapper(iter);
fprintf(stderr, " +-----------------------------------------------------------------------------+\n");
fprintf(stderr, " | %-75s |\n", "Known ICDs:");
fprintf(stderr, " +-----------------------------------------------------------------------------+\n");
Expand All @@ -54,8 +60,6 @@ CHIP_ERROR ICDListCommand::RunCommand()
}

fprintf(stderr, " +-----------------------------------------------------------------------------+\n");

iter->Release();
SetCommandExitStatus(CHIP_NO_ERROR);
return CHIP_NO_ERROR;
}
Expand Down
9 changes: 9 additions & 0 deletions examples/darwin-framework-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ declare_args() {
}

enable_provisional_features = config_enable_yaml_tests

# Disable generating compiler database by default
generate_compilation_database = false
}

sdk = "macosx"
Expand Down Expand Up @@ -107,6 +110,12 @@ action("build-darwin-framework") {
args += [ "--no-clang" ]
}

if (generate_compilation_database) {
args += [ "--compdb" ]
} else {
args += [ "--no-compdb" ]
}

if (config_enable_yaml_tests) {
args += [ "--enable-encoding-sentinel-enum-values" ]
} else {
Expand Down
2 changes: 1 addition & 1 deletion examples/light-switch-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ idf_component_register(PRIV_INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/basic-information"
Expand Down
2 changes: 1 addition & 1 deletion examples/lit-icd-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ executable("lit-icd-app") {
deps = [
"${chip_root}/examples/lit-icd-app/lit-icd-common",
"${chip_root}/examples/platform/linux:app-main",
"${chip_root}/src/app/icd:manager",
"${chip_root}/src/app/icd/server:manager",
"${chip_root}/src/lib",
"${chip_root}/third_party/jsoncpp",
]
Expand Down
4 changes: 2 additions & 2 deletions examples/lock-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ idf_component_register(INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/basic-information"
Expand Down Expand Up @@ -163,7 +163,7 @@ idf_component_register(PRIV_INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/basic-information"
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/silabs/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#include "SilabsDeviceDataProvider.h"
#if CHIP_CONFIG_ENABLE_ICD_SERVER == 1
#include <app/icd/ICDNotifier.h> // nogncheck
#include <app/icd/server/ICDNotifier.h> // nogncheck
#endif
#include <app/server/OnboardingCodesUtil.h>
#include <app/util/attribute-storage.h>
Expand Down
3 changes: 1 addition & 2 deletions examples/shell/shell_common/cmd_otcli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static char sTxBuffer[SHELL_OTCLI_TX_BUFFER_SIZE];
static constexpr uint16_t sTxLength = SHELL_OTCLI_TX_BUFFER_SIZE;
#endif // !CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI)
#endif
static constexpr uint16_t kMaxLineLength = 384;
#else
#include <sys/types.h>
#include <sys/wait.h>
Expand Down Expand Up @@ -81,8 +82,6 @@ CHIP_ERROR cmd_otcli_dispatch(int argc, char ** argv)
{
CHIP_ERROR error = CHIP_NO_ERROR;

// From OT CLI internal lib, kMaxLineLength = 128
#define kMaxLineLength 128
char buff[kMaxLineLength] = { 0 };
char * buff_ptr = buff;
int i = 0;
Expand Down
3 changes: 3 additions & 0 deletions examples/tv-casting-app/APIs.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ Next, you're ready to:
1. [Read](#read-operations) endpoint attributes like playback state.
1. [Subscribe](#subscriptions) to playback events.

In order to illustrate these steps, refer to the figure below
![workflow of casting video player](./diagram/workflow_of_casting_video_player.png)

## Build and Setup

The Casting Client is expected to consume the Matter TV Casting library built
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions scripts/build/build_darwin_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ def build_darwin_framework(args):
if args.enable_encoding_sentinel_enum_values:
cflags += ["-DCHIP_CONFIG_IM_ENABLE_ENCODING_SENTINEL_ENUM_VALUES=1"]

if args.compdb:
cflags += ["-gen-cdb-fragment-path ", abs_path + '/compdb']

command += ["OTHER_CFLAGS=" + ' '.join(cflags), "OTHER_LDFLAGS=" + ' '.join(ldflags)]
command_result = run_command(command)
print("Build Framework Result: {}".format(command_result))
Expand Down Expand Up @@ -172,6 +175,7 @@ def build_darwin_framework(args):
parser.add_argument('--ble', action=argparse.BooleanOptionalAction)
parser.add_argument('--clang', action=argparse.BooleanOptionalAction)
parser.add_argument('--enable-encoding-sentinel-enum-values', action=argparse.BooleanOptionalAction)
parser.add_argument('--compdb', action=argparse.BooleanOptionalAction)

args = parser.parse_args()
build_darwin_framework(args)
45 changes: 45 additions & 0 deletions scripts/helpers/generate_darwin_compdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
#
# Copyright (c) 2020-2023 Project CHIP Authors
#
# 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.
#

JQ=$(which jq)
if [ $? -ne 0 ]; then
echo "'jq' not detected in PATH. Install using: brew install jq"
exit 1
fi

set -e
set -x

source "$(dirname "$0")/../../scripts/activate.sh"
CHIP_ROOT="$(dirname "$0")/../.."
OUTPUT_DIR=$2

# Build the framework
scripts/examples/gn_build_example.sh "$@" generate_compilation_database=true

# Clean up any stale DB files
find "$OUTPUT_DIR" -iname compile_commands\*.json | xargs rm

# Construct json from fragments generated by xcodebuild
COMPDB_FRAGMENTS_DIR=$(find "$OUTPUT_DIR" -type d -name compdb)
sed -e '1s/^/[\'$'\n''/' -e '$s/,$/\'$'\n'']/' "$COMPDB_FRAGMENTS_DIR"/*.json >"$OUTPUT_DIR"/compile_commands_darwin_framework.json

# Get ninja to build comdb for the rest
ninja -C "$OUTPUT_DIR" -t compdb >"$OUTPUT_DIR"/compile_commands_rest.json

# Combine the generated compdb into one
find "$OUTPUT_DIR" -iname compile_commands\*.json | xargs jq -s 'map(.[])' >"$OUTPUT_DIR"/compile_commands.json
17 changes: 12 additions & 5 deletions src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ source_set("pre-encoded-value") {
]
}

source_set("subscription-manager") {
sources = [ "SubscriptionManager.h" ]

public_deps = [ "${chip_root}/src/lib/core" ]
}

source_set("message-def") {
sources = [
"MessageDef/ArrayBuilder.cpp",
Expand Down Expand Up @@ -247,8 +253,9 @@ static_library("interaction-model") {
":app_config",
":message-def",
":paths",
"${chip_root}/src/app/icd:icd_config",
"${chip_root}/src/app/icd:observer",
":subscription-manager",
"${chip_root}/src/app/icd/server:icd-server-config",
"${chip_root}/src/app/icd/server:observer",
"${chip_root}/src/lib/address_resolve",
"${chip_root}/src/lib/support",
"${chip_root}/src/protocols/interaction_model",
Expand Down Expand Up @@ -326,7 +333,7 @@ static_library("app") {
":interaction-model",
":pre-encoded-value",
":revision_info",
"${chip_root}/src/app/icd:icd_config",
"${chip_root}/src/app/icd/server:icd-server-config",
"${chip_root}/src/lib/address_resolve",
"${chip_root}/src/lib/support",
"${chip_root}/src/messaging",
Expand All @@ -346,8 +353,8 @@ static_library("app") {

if (chip_enable_icd_server) {
public_deps += [
"${chip_root}/src/app/icd:manager",
"${chip_root}/src/app/icd:notifier",
"${chip_root}/src/app/icd/server:manager",
"${chip_root}/src/app/icd/server:notifier",
]
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/FailSafeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
* Provides the implementation of the FailSafeContext object.
*/
#include "FailSafeContext.h"
#include <app/icd/ICDConfig.h>
#include <app/icd/server/ICDServerConfig.h>
#if CHIP_CONFIG_ENABLE_ICD_SERVER
#include <app/icd/ICDNotifier.h> // nogncheck
#include <app/icd/server/ICDNotifier.h> // nogncheck
#endif
#include <lib/support/SafeInt.h>
#include <platform/CHIPDeviceConfig.h>
Expand Down
Loading

0 comments on commit 94d96e4

Please sign in to comment.