Skip to content

Commit 06ff59a

Browse files
authored
Merge branch 'master' into fix_airpurifier_write
2 parents bfb6d9b + e7e3316 commit 06ff59a

File tree

98 files changed

+1194
-334
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1194
-334
lines changed

credentials/generate-revocation-set.py

+28-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from click_option_group import RequiredMutuallyExclusiveOptionGroup, optgroup
3333
from cryptography import x509
3434
from cryptography.hazmat.primitives.asymmetric import ec
35+
from cryptography.x509.oid import NameOID
3536

3637
# Supported log levels, mapping string values required for argument
3738
# parsing into logging constants
@@ -64,6 +65,32 @@ def extract_single_integer_attribute(subject, oid):
6465
return None
6566

6667

68+
def extract_fallback_tag_from_common_name(cn, marker):
69+
val_len = 4
70+
start_idx = cn.find(marker)
71+
72+
if start_idx != -1:
73+
val_start_idx = start_idx + len(marker)
74+
val = cn[val_start_idx:val_start_idx + val_len]
75+
return int(val, 16) if len(val) == 4 else None
76+
77+
return None
78+
79+
80+
def parse_vid_pid_from_distinguished_name(distinguished_name):
81+
# VID/PID encoded using Matter specific RDNs
82+
vid = extract_single_integer_attribute(distinguished_name, OID_VENDOR_ID)
83+
pid = extract_single_integer_attribute(distinguished_name, OID_PRODUCT_ID)
84+
85+
# Fallback method to get the VID/PID, encoded in CN as "Mvid:FFFF Mpid:1234"
86+
if vid is None and pid is None:
87+
cn = distinguished_name.get_attributes_for_oid(NameOID.COMMON_NAME)[0].value
88+
vid = extract_fallback_tag_from_common_name(cn, 'Mvid:')
89+
pid = extract_fallback_tag_from_common_name(cn, 'Mpid:')
90+
91+
return vid, pid
92+
93+
6794
class DCLDClient:
6895
'''
6996
A client for interacting with DCLD using either the REST API or command line interface (CLI).
@@ -248,14 +275,11 @@ def main(use_main_net_dcld: str, use_test_net_dcld: str, use_main_net_http: bool
248275
is_paa = revocation_point["isPAA"]
249276

250277
# 3. && 4. Validate VID/PID
251-
# TODO: Need to support alternate representation of VID/PID (see spec "6.2.2.2. Encoding of Vendor ID and Product ID in subject and issuer fields")
252-
crl_vid = extract_single_integer_attribute(crl_signer_certificate.subject, OID_VENDOR_ID)
253-
crl_pid = extract_single_integer_attribute(crl_signer_certificate.subject, OID_PRODUCT_ID)
278+
crl_vid, crl_pid = parse_vid_pid_from_distinguished_name(crl_signer_certificate.subject)
254279

255280
if is_paa:
256281
if crl_vid is not None:
257282
if vid != crl_vid:
258-
# TODO: Need to log all situations where a continue is called
259283
logging.warning("VID is not CRL VID, continue...")
260284
continue
261285
else:

docs/guides/simulated_device_linux.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Now that the building is completed there is a `chip-app1` binary created. This
6161
binary can be executed on a linux os with test commands.
6262
6363
```
64-
./scripts/tests/yaml/runner.py [TEST NAME] app1
64+
./scripts/tests/chipyaml/runner.py [TEST NAME] app1
6565
```
6666
6767
## Interacting with the simulated app

docs/testing/yaml.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,12 @@ Compile chip-tool:
347347

348348
NOTE: use the target appropriate to your system
349349

350-
[chiptool.py](https://github.com/project-chip/connectedhomeip/blob/master/scripts/tests/yaml/chiptool.py)
350+
[chiptool.py](https://github.com/project-chip/connectedhomeip/blob/master/scripts/tests/chipyaml/chiptool.py)
351351
can be used to run tests against a commissioned DUT (commissioned by chip-tool).
352352
This will start an interactive instance of chip-tool automatically.
353353

354354
```
355-
./scripts/tests/yaml/chiptool.py tests Test_TC_OO_2_1 --server_path ./out/linux-x64-chip-tool/chip-tool
355+
./scripts/tests/chipyaml/chiptool.py tests Test_TC_OO_2_1 --server_path ./out/linux-x64-chip-tool/chip-tool
356356
357357
```
358358

@@ -361,14 +361,14 @@ NOTE: substitute the appropriate test name and chip-tool path as appropriate.
361361
A list of available tests can be generated using:
362362

363363
```
364-
./scripts/tests/yaml/chiptool.py list
364+
./scripts/tests/chipyaml/chiptool.py list
365365
```
366366

367367
Config variables can be passed to chiptool.py after the script by separating
368368
with --
369369

370370
```
371-
./scripts/tests/yaml/chiptool.py tests Test_TC_OO_2_1 --server_path ./out/linux-x64-chip-tool/chip-tool -- nodeId 0x12344321
371+
./scripts/tests/chipyaml/chiptool.py tests Test_TC_OO_2_1 --server_path ./out/linux-x64-chip-tool/chip-tool -- nodeId 0x12344321
372372
373373
```
374374

examples/all-clusters-app/all-clusters-common/all-clusters-app.matter

+1
Original file line numberDiff line numberDiff line change
@@ -2257,6 +2257,7 @@ cluster Switch = 59 {
22572257
kMomentarySwitchRelease = 0x4;
22582258
kMomentarySwitchLongPress = 0x8;
22592259
kMomentarySwitchMultiPress = 0x10;
2260+
kActionSwitch = 0x20;
22602261
}
22612262

22622263
info event SwitchLatched = 0 {

examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter

+1
Original file line numberDiff line numberDiff line change
@@ -1989,6 +1989,7 @@ cluster Switch = 59 {
19891989
kMomentarySwitchRelease = 0x4;
19901990
kMomentarySwitchLongPress = 0x8;
19911991
kMomentarySwitchMultiPress = 0x10;
1992+
kActionSwitch = 0x20;
19921993
}
19931994

19941995
info event SwitchLatched = 0 {

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

+1
Original file line numberDiff line numberDiff line change
@@ -1574,6 +1574,7 @@ cluster Switch = 59 {
15741574
kMomentarySwitchRelease = 0x4;
15751575
kMomentarySwitchLongPress = 0x8;
15761576
kMomentarySwitchMultiPress = 0x10;
1577+
kActionSwitch = 0x20;
15771578
}
15781579

15791580
info event SwitchLatched = 0 {

examples/chef/devices/rootnode_genericswitch_2dfff6e516.matter

+1
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,7 @@ cluster Switch = 59 {
954954
kMomentarySwitchRelease = 0x4;
955955
kMomentarySwitchLongPress = 0x8;
956956
kMomentarySwitchMultiPress = 0x10;
957+
kActionSwitch = 0x20;
957958
}
958959

959960
info event SwitchLatched = 0 {

examples/chef/devices/rootnode_genericswitch_9866e35d0b.matter

+1
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,7 @@ cluster Switch = 59 {
954954
kMomentarySwitchRelease = 0x4;
955955
kMomentarySwitchLongPress = 0x8;
956956
kMomentarySwitchMultiPress = 0x10;
957+
kActionSwitch = 0x20;
957958
}
958959

959960
info event SwitchLatched = 0 {

examples/chip-tool/commands/clusters/ModelCommand.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ CHIP_ERROR ModelCommand::RunCommand()
4444
return SendCommand(commissioneeDeviceProxy, mEndPointId);
4545
}
4646

47+
// Check whether the session needs to allow large payload support.
48+
TransportPayloadCapability transportPayloadCapability =
49+
AllowLargePayload() ? TransportPayloadCapability::kLargePayload : TransportPayloadCapability::kMRPPayload;
4750
return CurrentCommissioner().GetConnectedDevice(mDestinationId, &mOnDeviceConnectedCallback,
48-
&mOnDeviceConnectionFailureCallback);
51+
&mOnDeviceConnectionFailureCallback, transportPayloadCapability);
4952
}
5053

5154
void ModelCommand::OnDeviceConnectedFn(void * context, chip::Messaging::ExchangeManager & exchangeMgr,
@@ -134,3 +137,8 @@ bool ModelCommand::IsPeerLIT()
134137
CheckPeerICDType();
135138
return mIsPeerLIT.ValueOr(false);
136139
}
140+
141+
bool ModelCommand::AllowLargePayload()
142+
{
143+
return mAllowLargePayload.ValueOr(false);
144+
}

examples/chip-tool/commands/clusters/ModelCommand.h

+6
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ class ModelCommand : public CHIPCommand
5757
"Whether to treat the peer as a LIT ICD. false: Always no, true: Always yes, (not set): Yes if the peer is registered "
5858
"to this controller.");
5959
AddArgument("timeout", 0, UINT16_MAX, &mTimeout);
60+
AddArgument("allow-large-payload", 0, 1, &mAllowLargePayload,
61+
"If true, indicates that the session should allow large application payloads (which requires a TCP connection)."
62+
"Defaults to false, which uses a UDP+MRP session.");
6063
}
6164

6265
/////////// CHIPCommand Interface /////////
@@ -82,9 +85,12 @@ class ModelCommand : public CHIPCommand
8285
chip::NodeId mDestinationId;
8386
std::vector<chip::EndpointId> mEndPointId;
8487
chip::Optional<bool> mIsPeerLIT;
88+
chip::Optional<bool> mAllowLargePayload;
8589

8690
void CheckPeerICDType();
8791

92+
bool AllowLargePayload();
93+
8894
static void OnDeviceConnectedFn(void * context, chip::Messaging::ExchangeManager & exchangeMgr,
8995
const chip::SessionHandle & sessionHandle);
9096
static void OnDeviceConnectionFailureFn(void * context, const chip::ScopedNodeId & peerId, CHIP_ERROR error);

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525

2626
using namespace chip::app::Clusters::Actions;
2727

28-
Device::Device(chip::NodeId nodeId, const char * name)
28+
Device::Device(chip::NodeId nodeId)
2929
{
30-
chip::Platform::CopyString(mName, name);
3130
mReachable = false;
32-
mEndpointId = 0;
31+
mNodeId = nodeId;
32+
mEndpointId = chip::kInvalidEndpointId;
3333
}
3434

3535
bool Device::IsReachable()

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

+115-9
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,77 @@ using namespace chip::app::Clusters;
4646
namespace {
4747

4848
constexpr uint8_t kMaxRetries = 10;
49+
constexpr int kNodeLabelSize = 32;
50+
51+
// Current ZCL implementation of Struct uses a max-size array of 254 bytes
52+
constexpr int kDescriptorAttributeArraySize = 254;
53+
54+
// ENDPOINT DEFINITIONS:
55+
// =================================================================================
56+
//
57+
// Endpoint definitions will be reused across multiple endpoints for every instance of the
58+
// endpoint type.
59+
// There will be no intrinsic storage for the endpoint attributes declared here.
60+
// Instead, all attributes will be treated as EXTERNAL, and therefore all reads
61+
// or writes to the attributes must be handled within the emberAfExternalAttributeWriteCallback
62+
// and emberAfExternalAttributeReadCallback functions declared herein. This fits
63+
// the typical model of a bridge, since a bridge typically maintains its own
64+
// state database representing the devices connected to it.
65+
66+
// (taken from matter-devices.xml)
67+
#define DEVICE_TYPE_BRIDGED_NODE 0x0013
68+
69+
// Device Version for dynamic endpoints:
70+
#define DEVICE_VERSION_DEFAULT 1
71+
72+
// ---------------------------------------------------------------------------
73+
//
74+
// SYNCED DEVICE ENDPOINT: contains the following clusters:
75+
// - Descriptor
76+
// - Bridged Device Basic Information
77+
// - Administrator Commissioning
78+
79+
// Declare Descriptor cluster attributes
80+
DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(descriptorAttrs)
81+
DECLARE_DYNAMIC_ATTRIBUTE(Descriptor::Attributes::DeviceTypeList::Id, ARRAY, kDescriptorAttributeArraySize, 0), /* device list */
82+
DECLARE_DYNAMIC_ATTRIBUTE(Descriptor::Attributes::ServerList::Id, ARRAY, kDescriptorAttributeArraySize, 0), /* server list */
83+
DECLARE_DYNAMIC_ATTRIBUTE(Descriptor::Attributes::ClientList::Id, ARRAY, kDescriptorAttributeArraySize, 0), /* client list */
84+
DECLARE_DYNAMIC_ATTRIBUTE(Descriptor::Attributes::PartsList::Id, ARRAY, kDescriptorAttributeArraySize, 0), /* parts list */
85+
DECLARE_DYNAMIC_ATTRIBUTE_LIST_END();
86+
87+
// Declare Bridged Device Basic Information cluster attributes
88+
DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(bridgedDeviceBasicAttrs)
89+
DECLARE_DYNAMIC_ATTRIBUTE(BridgedDeviceBasicInformation::Attributes::NodeLabel::Id, CHAR_STRING, kNodeLabelSize, 0), /* NodeLabel */
90+
DECLARE_DYNAMIC_ATTRIBUTE(BridgedDeviceBasicInformation::Attributes::Reachable::Id, BOOLEAN, 1, 0), /* Reachable */
91+
DECLARE_DYNAMIC_ATTRIBUTE(BridgedDeviceBasicInformation::Attributes::FeatureMap::Id, BITMAP32, 4, 0), /* feature map */
92+
DECLARE_DYNAMIC_ATTRIBUTE_LIST_END();
93+
94+
// Declare Administrator Commissioning cluster attributes
95+
DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(AdministratorCommissioningAttrs)
96+
DECLARE_DYNAMIC_ATTRIBUTE(AdministratorCommissioning::Attributes::WindowStatus::Id, ENUM8, 1, 0), /* NodeLabel */
97+
DECLARE_DYNAMIC_ATTRIBUTE(AdministratorCommissioning::Attributes::AdminFabricIndex::Id, FABRIC_IDX, 1, 0), /* Reachable */
98+
DECLARE_DYNAMIC_ATTRIBUTE(AdministratorCommissioning::Attributes::AdminVendorId::Id, VENDOR_ID, 2, 0), /* Reachable */
99+
DECLARE_DYNAMIC_ATTRIBUTE_LIST_END();
100+
101+
constexpr CommandId administratorCommissioningCommands[] = {
102+
app::Clusters::AdministratorCommissioning::Commands::OpenCommissioningWindow::Id,
103+
app::Clusters::AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Id,
104+
app::Clusters::AdministratorCommissioning::Commands::RevokeCommissioning::Id,
105+
kInvalidCommandId,
106+
};
107+
108+
// Declare Cluster List for Bridged Node endpoint
109+
DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedNodeClusters)
110+
DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr),
111+
DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr),
112+
DECLARE_DYNAMIC_CLUSTER(AdministratorCommissioning::Id, AdministratorCommissioningAttrs, ZAP_CLUSTER_MASK(SERVER),
113+
administratorCommissioningCommands, nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END;
114+
115+
// Declare Bridged Node endpoint
116+
DECLARE_DYNAMIC_ENDPOINT(sBridgedNodeEndpoint, bridgedNodeClusters);
117+
DataVersion sBridgedNodeDataVersions[ArraySize(bridgedNodeClusters)];
118+
119+
const EmberAfDeviceType sBridgedDeviceTypes[] = { { DEVICE_TYPE_BRIDGED_NODE, DEVICE_VERSION_DEFAULT } };
49120

50121
} // namespace
51122

@@ -60,11 +131,13 @@ void DeviceManager::Init()
60131
mCurrentEndpointId = mFirstDynamicEndpointId;
61132
}
62133

63-
int DeviceManager::AddDeviceEndpoint(Device * dev, EmberAfEndpointType * ep,
64-
const chip::Span<const EmberAfDeviceType> & deviceTypeList,
65-
const chip::Span<chip::DataVersion> & dataVersionStorage, chip::EndpointId parentEndpointId)
134+
int DeviceManager::AddDeviceEndpoint(Device * dev, chip::EndpointId parentEndpointId)
66135
{
67-
uint8_t index = 0;
136+
uint8_t index = 0;
137+
EmberAfEndpointType * ep = &sBridgedNodeEndpoint;
138+
const chip::Span<const EmberAfDeviceType> & deviceTypeList = Span<const EmberAfDeviceType>(sBridgedDeviceTypes);
139+
const chip::Span<chip::DataVersion> & dataVersionStorage = Span<DataVersion>(sBridgedNodeDataVersions);
140+
68141
while (index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT)
69142
{
70143
if (nullptr == mDevices[index])
@@ -81,8 +154,9 @@ int DeviceManager::AddDeviceEndpoint(Device * dev, EmberAfEndpointType * ep,
81154
emberAfSetDynamicEndpoint(index, mCurrentEndpointId, ep, dataVersionStorage, deviceTypeList, parentEndpointId);
82155
if (err == CHIP_NO_ERROR)
83156
{
84-
ChipLogProgress(NotSpecified, "Added device %s to dynamic endpoint %d (index=%d)", dev->GetName(),
85-
mCurrentEndpointId, index);
157+
ChipLogProgress(NotSpecified,
158+
"Added device with nodeId=0x" ChipLogFormatX64 " to dynamic endpoint %d (index=%d)",
159+
ChipLogValueX64(dev->GetNodeId()), mCurrentEndpointId, index);
86160
return index;
87161
}
88162
if (err != CHIP_ERROR_ENDPOINT_EXISTS)
@@ -125,11 +199,43 @@ int DeviceManager::RemoveDeviceEndpoint(Device * dev)
125199
return -1;
126200
}
127201

128-
Device * DeviceManager::GetDevice(uint16_t index) const
202+
Device * DeviceManager::GetDevice(chip::EndpointId endpointId) const
203+
{
204+
for (uint8_t index = 0; index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; ++index)
205+
{
206+
if (mDevices[index] && mDevices[index]->GetEndpointId() == endpointId)
207+
{
208+
return mDevices[index];
209+
}
210+
}
211+
return nullptr;
212+
}
213+
214+
Device * DeviceManager::GetDeviceByNodeId(chip::NodeId nodeId) const
129215
{
130-
if (index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT)
216+
for (uint8_t index = 0; index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; ++index)
131217
{
132-
return mDevices[index];
218+
if (mDevices[index] && mDevices[index]->GetNodeId() == nodeId)
219+
{
220+
return mDevices[index];
221+
}
133222
}
134223
return nullptr;
135224
}
225+
226+
int DeviceManager::RemoveDeviceByNodeId(chip::NodeId nodeId)
227+
{
228+
for (uint8_t index = 0; index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; ++index)
229+
{
230+
if (mDevices[index] && mDevices[index]->GetNodeId() == nodeId)
231+
{
232+
DeviceLayer::StackLock lock;
233+
EndpointId ep = emberAfClearDynamicEndpoint(index);
234+
mDevices[index] = nullptr;
235+
ChipLogProgress(NotSpecified, "Removed device with NodeId=0x" ChipLogFormatX64 " from dynamic endpoint %d (index=%d)",
236+
ChipLogValueX64(nodeId), ep, index);
237+
return index;
238+
}
239+
}
240+
return -1;
241+
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ CHIP_ERROR InitRpcClient(uint16_t rpcServerPort)
6565

6666
CHIP_ERROR OpenCommissioningWindow(NodeId nodeId)
6767
{
68-
ChipLogProgress(NotSpecified, "OpenCommissioningWindow\n");
68+
ChipLogProgress(NotSpecified, "OpenCommissioningWindow with Node Id 0x:" ChipLogFormatX64, ChipLogValueX64(nodeId));
6969

7070
if (openCommissioningWindowCall.active())
7171
{

0 commit comments

Comments
 (0)