Skip to content

Commit

Permalink
Merge branch 'master' into TC-SC-4.3-python-test
Browse files Browse the repository at this point in the history
  • Loading branch information
raul-marquez-csa authored Nov 14, 2024
2 parents 78a768a + 73ff58f commit ef874d0
Show file tree
Hide file tree
Showing 210 changed files with 5,761 additions and 2,570 deletions.
10 changes: 0 additions & 10 deletions config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ menu "CHIP Core"
exchange (conversation) with a peer, e.g. a cloud service, a mobile application, or
another device.

config MAX_BINDINGS
int "Max Bindings"
range 0 65535
default 8
help
The maximum number of simultaneously active CHIP Binding objects.

A Binding object is used to configure how the local device communicates with
a remote entity, be it a cloud service, a mobile application, or another device.

config MAX_FABRICS
int "Max Fabrics"
range 5 255
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni")
import("${chip_root}/config/standalone/args.gni")

silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain")
import("${chip_root}/src/platform/silabs/wifi_args.gni")
import("${chip_root}/src/platform/silabs/wifi/args.gni")
chip_enable_wifi = true
chip_enable_ota_requestor = true
app_data_model =
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${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/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/air-quality-server"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,6 @@
*/
#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 0

/**
* CHIP_CONFIG_MAX_BINDINGS
*
* Maximum number of simultaneously active bindings per ChipExchangeManager
* 1 (Time Sync) + 2 (Two 1-way subscriptions) + 1 (Software Update) = 4
* in the worst case. Keeping another 4 as buffer.
*/
#define CHIP_CONFIG_MAX_BINDINGS 6

/**
* CHIP_CONFIG_EVENT_LOGGING_WDM_OFFLOAD
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,6 @@
*/
// #define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1

/**
* CHIP_CONFIG_MAX_BINDINGS
*
* Maximum number of simultaneously active bindings per ChipExchangeManager
* 1 (Time Sync) + 2 (Two 1-way subscriptions) + 1 (Software Update) = 4
* in the worst case. Keeping another 4 as buffer.
*/
#define CHIP_CONFIG_MAX_BINDINGS 6

/**
* CHIP_CONFIG_EVENT_LOGGING_WDM_OFFLOAD
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,6 @@
*/
// #define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1

/**
* CHIP_CONFIG_MAX_BINDINGS
*
* Maximum number of simultaneously active bindings per ChipExchangeManager
* 1 (Time Sync) + 2 (Two 1-way subscriptions) + 1 (Software Update) = 4
* in the worst case. Keeping another 4 as buffer.
*/
#define CHIP_CONFIG_MAX_BINDINGS 6

/**
* CHIP_CONFIG_EVENT_LOGGING_WDM_OFFLOAD
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,6 @@
*/
// #define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1

/**
* CHIP_CONFIG_MAX_BINDINGS
*
* Maximum number of simultaneously active bindings per ChipExchangeManager
* 1 (Time Sync) + 2 (Two 1-way subscriptions) + 1 (Software Update) = 4
* in the worst case. Keeping another 4 as buffer.
*/
#define CHIP_CONFIG_MAX_BINDINGS 6

/**
* CHIP_CONFIG_EVENT_LOGGING_WDM_OFFLOAD
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ set(SRC_DIRS_LIST
"${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/util"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/application-basic-server"
Expand Down
1 change: 1 addition & 0 deletions examples/bridge-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ idf_component_register(PRIV_INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated"
"${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/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
Expand Down
1 change: 1 addition & 0 deletions examples/chef/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes"
"${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/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/chef/silabs/build_for_wifi_args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ import("//build_overrides/chip.gni")

silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain")
chip_enable_openthread = false
import("${chip_root}/src/platform/silabs/wifi_args.gni")
import("${chip_root}/src/platform/silabs/wifi/args.gni")

chip_enable_ota_requestor = true
2 changes: 1 addition & 1 deletion examples/dishwasher-app/silabs/build_for_wifi_args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import("${chip_root}/config/standalone/args.gni")

silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain")
chip_enable_openthread = false
import("${chip_root}/src/platform/silabs/wifi_args.gni")
import("${chip_root}/src/platform/silabs/wifi/args.gni")

sl_enable_test_event_trigger = true
chip_enable_ota_requestor = true
Expand Down
1 change: 1 addition & 0 deletions examples/energy-management-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension"
"${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/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import("${chip_root}/config/standalone/args.gni")

silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain")
chip_enable_openthread = false
import("${chip_root}/src/platform/silabs/wifi_args.gni")
import("${chip_root}/src/platform/silabs/wifi/args.gni")

sl_enable_test_event_trigger = true
chip_enable_ota_requestor = false
Expand Down
18 changes: 18 additions & 0 deletions examples/fabric-admin/device_manager/CommissionerControl.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* 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 "CommissionerControl.h"
#include "DeviceManager.h"

Expand Down
28 changes: 28 additions & 0 deletions examples/fabric-sync/admin/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,44 @@
import("//build_overrides/chip.gni")
import("${chip_root}/src/app/chip_data_model.gni")

config("config") {
include_dirs = [
".",
"${chip_root}/examples/fabric-sync",
"${chip_root}/examples/platform/linux",
"${chip_root}/src/lib",
]
}

source_set("fabric-admin-lib") {
public_configs = [ ":config" ]

sources = [
"BridgeSubscription.cpp",
"BridgeSubscription.h",
"CommissionerControl.cpp",
"CommissionerControl.h",
"DeviceManager.cpp",
"DeviceManager.h",
"DeviceSubscription.cpp",
"DeviceSubscription.h",
"DeviceSubscriptionManager.cpp",
"DeviceSubscriptionManager.h",
"DeviceSynchronization.cpp",
"DeviceSynchronization.h",
"FabricAdmin.cpp",
"FabricAdmin.h",
"FabricSyncGetter.cpp",
"FabricSyncGetter.h",
"PairingManager.cpp",
"PairingManager.h",
"UniqueIdGetter.cpp",
"UniqueIdGetter.h",
]

deps = [
"${chip_root}/examples/fabric-sync/bridge:fabric-bridge-lib",
"${chip_root}/examples/platform/linux:app-main",
"${chip_root}/src/lib",
]
}
163 changes: 163 additions & 0 deletions examples/fabric-sync/admin/BridgeSubscription.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/*
* 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 "BridgeSubscription.h"
#include "DeviceManager.h"

using namespace ::chip;
using namespace ::chip::app;
using chip::app::ReadClient;

namespace admin {

namespace {

constexpr uint16_t kSubscribeMinInterval = 0;
constexpr uint16_t kSubscribeMaxInterval = 60;

void OnDeviceConnectedWrapper(void * context, Messaging::ExchangeManager & exchangeMgr, const SessionHandle & sessionHandle)
{
reinterpret_cast<BridgeSubscription *>(context)->OnDeviceConnected(exchangeMgr, sessionHandle);
}

void OnDeviceConnectionFailureWrapper(void * context, const ScopedNodeId & peerId, CHIP_ERROR error)
{
reinterpret_cast<BridgeSubscription *>(context)->OnDeviceConnectionFailure(peerId, error);
}

} // namespace

BridgeSubscription::BridgeSubscription() :
mOnDeviceConnectedCallback(OnDeviceConnectedWrapper, this),
mOnDeviceConnectionFailureCallback(OnDeviceConnectionFailureWrapper, this)
{}

CHIP_ERROR BridgeSubscription::StartSubscription(Controller::DeviceController & controller, NodeId nodeId, EndpointId endpointId)
{
assertChipStackLockedByCurrentThread();

VerifyOrDie(!subscriptionStarted); // Ensure it's not called multiple times.

// Mark as started
subscriptionStarted = true;

mEndpointId = endpointId;

CHIP_ERROR err = controller.GetConnectedDevice(nodeId, &mOnDeviceConnectedCallback, &mOnDeviceConnectionFailureCallback);
if (err != CHIP_NO_ERROR)
{
ChipLogError(NotSpecified, "Failed to connect to remote fabric sync bridge %" CHIP_ERROR_FORMAT, err.Format());
}
return err;
}

void BridgeSubscription::OnAttributeData(const ConcreteDataAttributePath & path, TLV::TLVReader * data, const StatusIB & status)
{
if (!status.IsSuccess())
{
ChipLogError(NotSpecified, "Response Failure: %" CHIP_ERROR_FORMAT, status.ToChipError().Format());
return;
}

if (data == nullptr)
{
ChipLogError(NotSpecified, "Response Failure: No Data");
return;
}

DeviceManager::Instance().HandleAttributeData(path, *data);
}

void BridgeSubscription::OnEventData(const app::EventHeader & eventHeader, TLV::TLVReader * data, const app::StatusIB * status)
{
if (status != nullptr)
{
CHIP_ERROR error = status->ToChipError();
if (CHIP_NO_ERROR != error)
{
ChipLogError(NotSpecified, "Response Failure: %" CHIP_ERROR_FORMAT, error.Format());
return;
}
}

if (data == nullptr)
{
ChipLogError(NotSpecified, "Response Failure: No Data");
return;
}

DeviceManager::Instance().HandleEventData(eventHeader, *data);
}

void BridgeSubscription::OnError(CHIP_ERROR error)
{
ChipLogProgress(NotSpecified, "Error on remote fabric sync bridge subscription: %" CHIP_ERROR_FORMAT, error.Format());
}

void BridgeSubscription::OnDone(ReadClient * apReadClient)
{
mClient.reset();
ChipLogProgress(NotSpecified, "The remote fabric sync bridge subscription is terminated");

// Reset the subscription state to allow retry
subscriptionStarted = false;

// TODO:(#36092) Fabric-Admin should attempt to re-subscribe when the subscription to the remote bridge is terminated.
}

void BridgeSubscription::OnDeviceConnected(Messaging::ExchangeManager & exchangeMgr, const SessionHandle & sessionHandle)
{
mClient = std::make_unique<ReadClient>(app::InteractionModelEngine::GetInstance(), &exchangeMgr /* echangeMgr */,
*this /* callback */, ReadClient::InteractionType::Subscribe);
VerifyOrDie(mClient);

AttributePathParams readPaths[1];
readPaths[0] = AttributePathParams(mEndpointId, Clusters::Descriptor::Id, Clusters::Descriptor::Attributes::PartsList::Id);

EventPathParams eventPaths[1];
eventPaths[0] = EventPathParams(mEndpointId, Clusters::CommissionerControl::Id,
Clusters::CommissionerControl::Events::CommissioningRequestResult::Id);
eventPaths[0].mIsUrgentEvent = true;

ReadPrepareParams readParams(sessionHandle);

readParams.mpAttributePathParamsList = readPaths;
readParams.mAttributePathParamsListSize = 1;
readParams.mpEventPathParamsList = eventPaths;
readParams.mEventPathParamsListSize = 1;
readParams.mMinIntervalFloorSeconds = kSubscribeMinInterval;
readParams.mMaxIntervalCeilingSeconds = kSubscribeMaxInterval;
readParams.mKeepSubscriptions = true;

CHIP_ERROR err = mClient->SendRequest(readParams);

if (err != CHIP_NO_ERROR)
{
ChipLogError(NotSpecified, "Failed to issue subscription to the Descriptor Cluster of the remote bridged device.");
OnDone(nullptr);
return;
}
}

void BridgeSubscription::OnDeviceConnectionFailure(const ScopedNodeId & peerId, CHIP_ERROR error)
{
ChipLogError(NotSpecified, "BridgeSubscription failed to connect to " ChipLogFormatX64, ChipLogValueX64(peerId.GetNodeId()));
OnDone(nullptr);
}

} // namespace admin
Loading

0 comments on commit ef874d0

Please sign in to comment.