Skip to content

Commit

Permalink
Merge branch 'master' into match_presets_sdk_code_to_test_plan
Browse files Browse the repository at this point in the history
  • Loading branch information
nivi-apple authored Aug 8, 2024
2 parents 618237d + 95ff33b commit c13ddcb
Show file tree
Hide file tree
Showing 14 changed files with 358 additions and 412 deletions.
2 changes: 1 addition & 1 deletion examples/fabric-admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fabrics.
For Linux host example:

```
./scripts/examples/gn_build_example.sh examples/fabric-admin out/debug/standalone chip_config_network_layer_ble=false 'import("//with_pw_rpc.gni")'
./scripts/examples/gn_build_example.sh examples/fabric-admin out/debug/standalone 'import("//with_pw_rpc.gni")'
```

For Raspberry Pi 4 example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "fabric_bridge_service/fabric_bridge_service.pb.h"
#include "fabric_bridge_service/fabric_bridge_service.rpc.pb.h"

/// Ensures that device data is synchronized to the remove fabric bridge.
/// Ensures that device data is synchronized to the remote fabric bridge.
///
/// Includes a state machine that:
/// - initiates a "read basic information data" command to fetch basic information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ class BridgedDevice
BridgedDevice(chip::NodeId nodeId);
virtual ~BridgedDevice() = default;

[[nodiscard]] bool IsReachable() const { return mReachable; }
void SetReachable(bool reachable);

void LogActiveChangeEvent(uint32_t promisedActiveDurationMs);

bool IsReachable();
bool IsIcd();
void SetReachable(bool reachable);
[[nodiscard]] bool IsIcd() const { return mIsIcd; }
void SetIcd(bool icd) { mIsIcd = icd; }

inline void SetEndpointId(chip::EndpointId id) { mEndpointId = id; };
inline chip::EndpointId GetEndpointId() { return mEndpointId; };
Expand All @@ -63,11 +65,12 @@ class BridgedDevice
void SetUniqueId(const std::string & value) { mAttributes.uniqueId = value; }

protected:
bool mReachable;
bool mIsIcd = false;
chip::NodeId mNodeId;
chip::EndpointId mEndpointId;
chip::EndpointId mParentEndpointId;
bool mReachable = false;
bool mIsIcd = false;

chip::NodeId mNodeId = 0;
chip::EndpointId mEndpointId = 0;
chip::EndpointId mParentEndpointId = 0;

BridgedAttributes mAttributes;
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "BridgedDevice.h"

#include <cstdio>
#include <string>

#include <app/EventLogging.h>
#include <platform/CHIPDeviceLayer.h>
Expand All @@ -32,7 +31,7 @@ struct ActiveChangeEventWorkData
uint32_t mPromisedActiveDuration;
};

static void ActiveChangeEventWork(intptr_t arg)
void ActiveChangeEventWork(intptr_t arg)
{
ActiveChangeEventWorkData * data = reinterpret_cast<ActiveChangeEventWorkData *>(arg);

Expand Down Expand Up @@ -68,16 +67,6 @@ void BridgedDevice::LogActiveChangeEvent(uint32_t promisedActiveDurationMs)
chip::DeviceLayer::PlatformMgr().ScheduleWork(ActiveChangeEventWork, reinterpret_cast<intptr_t>(workdata));
}

bool BridgedDevice::IsReachable()
{
return mReachable;
}

bool BridgedDevice::IsIcd()
{
return mIsIcd;
}

void BridgedDevice::SetReachable(bool reachable)
{
mReachable = reachable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <app/AttributeAccessInterfaceRegistry.h>

static constexpr unsigned kBridgedDeviceBasicInformationClusterRevision = 4;
static constexpr unsigned kBridgedDeviceBasicInformationFeatureMap = 0;

using namespace ::chip;
using namespace ::chip::app;
Expand All @@ -49,9 +48,12 @@ CHIP_ERROR BridgedDeviceBasicInformationImpl::Read(const ConcreteReadAttributePa
case BasicInformation::Attributes::ClusterRevision::Id:
encoder.Encode(kBridgedDeviceBasicInformationClusterRevision);
break;
case BasicInformation::Attributes::FeatureMap::Id:
encoder.Encode(kBridgedDeviceBasicInformationFeatureMap);
break;
case BasicInformation::Attributes::FeatureMap::Id: {
BitMask<Clusters::BridgedDeviceBasicInformation::Feature> features;
features.Set(Clusters::BridgedDeviceBasicInformation::Feature::kBridgedICDSupport, dev->IsIcd());
encoder.Encode(features);
}
break;
case BasicInformation::Attributes::UniqueID::Id:
encoder.Encode(CharSpan::fromCharString(dev->GetBridgedAttributes().uniqueId.c_str()));
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,31 @@ constexpr CommandId administratorCommissioningCommands[] = {
kInvalidCommandId,
};

// clang-format off
// Declare Cluster List for Bridged Node endpoint
DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedNodeClusters)
DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr),
DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr),
DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr),
DECLARE_DYNAMIC_CLUSTER(EcosystemInformation::Id, ecosystemInformationBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr),
DECLARE_DYNAMIC_CLUSTER(AdministratorCommissioning::Id, AdministratorCommissioningAttrs, ZAP_CLUSTER_MASK(SERVER),
administratorCommissioningCommands, nullptr)
DECLARE_DYNAMIC_CLUSTER_LIST_END;

DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(icdBridgedNodeClusters)
DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr),
DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, ZAP_CLUSTER_MASK(SERVER),
bridgedDeviceBasicInformationCommands, nullptr),
DECLARE_DYNAMIC_CLUSTER(EcosystemInformation::Id, ecosystemInformationBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr),
DECLARE_DYNAMIC_CLUSTER(AdministratorCommissioning::Id, AdministratorCommissioningAttrs, ZAP_CLUSTER_MASK(SERVER),
administratorCommissioningCommands, nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END;
administratorCommissioningCommands, nullptr)
DECLARE_DYNAMIC_CLUSTER_LIST_END;
// clang-format on

// Declare Bridged Node endpoint
DECLARE_DYNAMIC_ENDPOINT(sBridgedNodeEndpoint, bridgedNodeClusters);
DECLARE_DYNAMIC_ENDPOINT(sIcdBridgedNodeEndpoint, icdBridgedNodeClusters);

// TODO: this is a single version array, however we may have many
// different clusters that are independent.
DataVersion sBridgedNodeDataVersions[ArraySize(bridgedNodeClusters)];

const EmberAfDeviceType sBridgedDeviceTypes[] = { { DEVICE_TYPE_BRIDGED_NODE, DEVICE_VERSION_DEFAULT } };
Expand All @@ -171,9 +185,12 @@ void BridgedDeviceManager::Init()
std::optional<unsigned> BridgedDeviceManager::AddDeviceEndpoint(std::unique_ptr<BridgedDevice> dev,
chip::EndpointId parentEndpointId)
{
EmberAfEndpointType * ep = &sBridgedNodeEndpoint;
EmberAfEndpointType * ep = dev->IsIcd() ? &sIcdBridgedNodeEndpoint : &sBridgedNodeEndpoint;

const chip::Span<const EmberAfDeviceType> & deviceTypeList = Span<const EmberAfDeviceType>(sBridgedDeviceTypes);
const chip::Span<chip::DataVersion> & dataVersionStorage = Span<DataVersion>(sBridgedNodeDataVersions);

// TODO: this shares data version among different clusters, which seems incorrect
const chip::Span<chip::DataVersion> & dataVersionStorage = Span<DataVersion>(sBridgedNodeDataVersions);

if (dev->GetBridgedAttributes().uniqueId.empty())
{
Expand Down
1 change: 1 addition & 0 deletions examples/fabric-bridge-app/linux/RpcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ pw::Status FabricBridge::AddSynchronizedDevice(const chip_rpc_SynchronizedDevice
}

device->SetBridgedAttributes(attributes);
device->SetIcd(request.has_is_icd && request.is_icd);

auto result = BridgeDeviceMgr().AddDeviceEndpoint(std::move(device), 1 /* parentEndpointId */);
if (!result.has_value())
Expand Down
21 changes: 9 additions & 12 deletions examples/rvc-app/rvc-common/include/rvc-service-area-delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,24 @@ class RvcServiceAreaDelegate : public Delegate
bool IsSetSelectedAreasAllowed(MutableCharSpan statusText) override;

bool IsValidSelectAreasSet(const ServiceArea::Commands::SelectAreas::DecodableType & req,
ServiceArea::SelectAreasStatus & locationStatus, MutableCharSpan statusText) override;
ServiceArea::SelectAreasStatus & areaStatus, MutableCharSpan statusText) override;

bool HandleSkipCurrentArea(uint32_t skippedArea, MutableCharSpan skipStatusText) override;

//*************************************************************************
// Supported Locations accessors
// Supported Areas accessors

bool IsSupportedAreasChangeAllowed() override;

uint32_t GetNumberOfSupportedAreas() override;

bool GetSupportedLocationByIndex(uint32_t listIndex, ServiceArea::AreaStructureWrapper & supportedLocation) override;
bool GetSupportedAreaByIndex(uint32_t listIndex, AreaStructureWrapper & supportedArea) override;

bool GetSupportedLocationById(uint32_t aAreaId, uint32_t & listIndex,
ServiceArea::AreaStructureWrapper & supportedLocation) override;
bool GetSupportedAreaById(uint32_t aAreaId, uint32_t & listIndex, AreaStructureWrapper & supportedArea) override;

bool AddSupportedLocation(const ServiceArea::AreaStructureWrapper & newArea, uint32_t & listIndex) override;
bool AddSupportedArea(const AreaStructureWrapper & newArea, uint32_t & listIndex) override;

bool ModifySupportedLocation(uint32_t listIndex, const ServiceArea::AreaStructureWrapper & modifiedLocation) override;
bool ModifySupportedArea(uint32_t listIndex, const AreaStructureWrapper & modifiedArea) override;

bool ClearSupportedAreas() override;

Expand All @@ -87,15 +86,13 @@ class RvcServiceAreaDelegate : public Delegate
bool ClearSupportedMaps() override;

//*************************************************************************
// Selected Locations accessors
// Selected Areas accessors

uint32_t GetNumberOfSelectedAreas() override;

bool GetSelectedLocationByIndex(uint32_t listIndex, uint32_t & selectedLocation) override;
bool GetSelectedAreaByIndex(uint32_t listIndex, uint32_t & selectedArea) override;

// IsSelectedLocation() no override

bool AddSelectedLocation(uint32_t aAreaId, uint32_t & listIndex) override;
bool AddSelectedArea(uint32_t aAreaId, uint32_t & listIndex) override;

bool ClearSelectedAreas() override;

Expand Down
Loading

0 comments on commit c13ddcb

Please sign in to comment.