Skip to content

Commit de1b24c

Browse files
Merge remote-tracking branch 'upstream/master' into add-new-command-dggen
2 parents 302e123 + 473fa74 commit de1b24c

File tree

65 files changed

+4104
-159
lines changed

Some content is hidden

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

65 files changed

+4104
-159
lines changed

.github/workflows/tests.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ jobs:
155155
src/app/zap-templates/zcl/data-model/chip/operational-state-oven-cluster.xml \
156156
src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster.xml \
157157
src/app/zap-templates/zcl/data-model/chip/oven-mode-cluster.xml \
158+
src/app/zap-templates/zcl/data-model/chip/power-topology-cluster.xml \
158159
src/app/zap-templates/zcl/data-model/chip/pressure-measurement-cluster.xml \
159160
src/app/zap-templates/zcl/data-model/chip/power-source-cluster.xml \
160161
src/app/zap-templates/zcl/data-model/chip/power-source-configuration-cluster.xml \

config/esp32/components/chip/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ if ((CONFIG_BT_ENABLED) AND (CONFIG_ENABLE_CHIPOBLE))
185185
endif()
186186
endif()
187187

188+
if (CONFIG_ENABLE_PERSIST_SUBSCRIPTIONS)
189+
chip_gn_arg_append("chip_persist_subscriptions" "true")
190+
else()
191+
chip_gn_arg_append("chip_persist_subscriptions" "false")
192+
endif()
193+
188194
if (CONFIG_ENABLE_ESP32_BLE_CONTROLLER)
189195
chip_gn_arg_append("chip_enable_ble_controller" "true")
190196
endif()

config/esp32/components/chip/Kconfig

+7
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ menu "CHIP Core"
130130
help
131131
Some device types don't require the read client. Enabling this option may save some flash/ram.
132132

133+
config ENABLE_PERSIST_SUBSCRIPTIONS
134+
bool "Enable persist subscriptions"
135+
default y
136+
help
137+
Enable persist subscriptions to make the device resume the subscriptions from the persist
138+
subscriptions information after reboot.
139+
133140
config BUILD_CHIP_TESTS
134141
bool "Build CHIP tests"
135142
default n

docs/clusters.md

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Generally regenerate using one of:
8484
| 152 | 0x98 | DeviceEnergyManagement |
8585
| 153 | 0x99 | EnergyEvse |
8686
| 155 | 0x9B | EnergyPreference |
87+
| 156 | 0x9C | PowerTopology |
8788
| 157 | 0x9D | EnergyEvseMode |
8889
| 159 | 0x9F | DeviceEnergyManagementMode |
8990
| 257 | 0x101 | DoorLock |

docs/guides/BUILDING.md

+27
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,33 @@ Complete the following steps:
9494
9595
1. Reboot your Raspberry Pi after installing `pi-bluetooth`.
9696
97+
#### Enable experimental Bluetooth support in BlueZ
98+
99+
The Matter application on Linux uses BlueZ to communicate with the Bluetooth
100+
controller. The BlueZ version that comes with Ubuntu 22.04 does not support all
101+
the features required by the Matter application by default. To enable these
102+
features, you need to enable experimental Bluetooth support in BlueZ.
103+
104+
1. Edit the `bluetooth.service` unit by running the following command:
105+
106+
```sh
107+
sudo systemctl edit bluetooth.service
108+
```
109+
110+
1. Add the following content to the override file:
111+
112+
```ini
113+
[Service]
114+
ExecStart=
115+
ExecStart=/usr/lib/bluetooth/bluetoothd -E
116+
```
117+
118+
1. Restart the Bluetooth service by running the following command:
119+
120+
```sh
121+
sudo systemctl restart bluetooth.service
122+
```
123+
97124
#### Configuring wpa_supplicant for storing permanent changes
98125
99126
By default, wpa_supplicant is not allowed to update (overwrite) configuration.

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi
195195
template <typename U = T, std::enable_if_t<std::is_same<U, std::vector<CustomArgument *>>::value, int> = 0>
196196
static const char * GetAttributeValuesDescription()
197197
{
198-
return "Comma-separated list of attribute values to write. Each value is represented as follows, depending on the type:\n"
198+
return "Semicolon-separated list of attribute values to write. Each value is represented as follows, depending on the "
199+
"type:\n"
199200
" * struct: a JSON-encoded object, with field ids as keys.\n"
200201
" * list: a JSON-encoded array of values.\n"
201202
" * null: A literal null.\n"
@@ -213,7 +214,9 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi
213214
" a) The number directly, if it's not an integer.\n"
214215
" b) A string starting with \"d:\" followed by the number.\n"
215216
" * octet string: A string starting with \"hex:\" followed by the hex encoding of the bytes.\n"
216-
" * string: A string with the characters.";
217+
" * string: A string with the characters.\n"
218+
"\n"
219+
" Example values: '10;20', '10;\"u:20\"', '\"hex:aabbcc\";\"hello\"'.";
217220
}
218221

219222
static const char * GetTypedAttributeValuesDescription() { return "Comma-separated list of attribute values to write."; }

examples/lock-app/esp32/main/AppTask.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ void AppTask::FunctionHandler(AppEvent * aEvent)
322322
}
323323
else
324324
{
325-
// If the button was released before factory reset got initiated, start BLE advertissement in fast mode
325+
// If the button was released before factory reset got initiated, start BLE advertisement in fast mode
326326
if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_StartBleAdv)
327327
{
328328
sAppTask.CancelTimer();
@@ -336,7 +336,7 @@ void AppTask::FunctionHandler(AppEvent * aEvent)
336336
}
337337
else
338338
{
339-
ESP_LOGI(TAG, "Network is already provisioned, Ble advertissement not enabled");
339+
ESP_LOGI(TAG, "Network is already provisioned, Ble advertisement not enabled");
340340
}
341341
}
342342
else if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_FactoryReset)

examples/lock-app/lock-common/include/LockEndpoint.h

+10-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,16 @@ class LockEndpoint
106106
OperationSourceEnum opSource = OperationSourceEnum::kUnspecified);
107107
const char * lockStateToString(DlLockState lockState) const;
108108

109-
bool weekDayScheduleInAction(uint16_t userIndex) const;
110-
bool yearDayScheduleInAction(uint16_t userIndex) const;
109+
// Returns true if week day schedules should apply to the user, there are
110+
// schedules defined for the user, and access is not currently allowed by
111+
// those schedules. The outparam indicates whether there were in fact any
112+
// year day schedules defined for the user.
113+
bool weekDayScheduleForbidsAccess(uint16_t userIndex, bool * haveSchedule) const;
114+
// Returns true if year day schedules should apply to the user, there are
115+
// schedules defined for the user, and access is not currently allowed by
116+
// those schedules. The outparam indicates whether there were in fact any
117+
// year day schedules defined for the user.
118+
bool yearDayScheduleForbidsAccess(uint16_t userIndex, bool * haveSchedule) const;
111119

112120
static void OnLockActionCompleteCallback(chip::System::Layer *, void * callbackContext);
113121

examples/lock-app/lock-common/src/LockEndpoint.cpp

+48-25
Original file line numberDiff line numberDiff line change
@@ -488,19 +488,20 @@ bool LockEndpoint::setLockState(const Nullable<chip::FabricIndex> & fabricIdx, c
488488
auto userIndex = static_cast<uint8_t>(user - mLockUsers.begin());
489489

490490
// Check if schedules affect the user
491-
if ((user->userType == UserTypeEnum::kScheduleRestrictedUser || user->userType == UserTypeEnum::kWeekDayScheduleUser) &&
492-
!weekDayScheduleInAction(userIndex))
491+
bool haveWeekDaySchedules = false;
492+
bool haveYearDaySchedules = false;
493+
if (weekDayScheduleForbidsAccess(userIndex, &haveWeekDaySchedules) ||
494+
yearDayScheduleForbidsAccess(userIndex, &haveYearDaySchedules) ||
495+
// Also disallow access for a user that's supposed to have _some_
496+
// schedule but doesn't have any
497+
(user->userType == UserTypeEnum::kScheduleRestrictedUser && !haveWeekDaySchedules && !haveYearDaySchedules))
493498
{
494-
if ((user->userType == UserTypeEnum::kScheduleRestrictedUser || user->userType == UserTypeEnum::kYearDayScheduleUser) &&
495-
!yearDayScheduleInAction(userIndex))
496-
{
497-
ChipLogDetail(Zcl,
498-
"Lock App: associated user is not allowed to operate the lock due to schedules"
499-
"[endpointId=%d,userIndex=%u]",
500-
mEndpointId, userIndex);
501-
err = OperationErrorEnum::kRestricted;
502-
return false;
503-
}
499+
ChipLogDetail(Zcl,
500+
"Lock App: associated user is not allowed to operate the lock due to schedules"
501+
"[endpointId=%d,userIndex=%u]",
502+
mEndpointId, userIndex);
503+
err = OperationErrorEnum::kRestricted;
504+
return false;
504505
}
505506
ChipLogProgress(
506507
Zcl,
@@ -561,12 +562,23 @@ void LockEndpoint::OnLockActionCompleteCallback(chip::System::Layer *, void * ca
561562
}
562563
}
563564

564-
bool LockEndpoint::weekDayScheduleInAction(uint16_t userIndex) const
565+
bool LockEndpoint::weekDayScheduleForbidsAccess(uint16_t userIndex, bool * haveSchedule) const
565566
{
567+
*haveSchedule = std::any_of(mWeekDaySchedules[userIndex].begin(), mWeekDaySchedules[userIndex].end(),
568+
[](const WeekDaysScheduleInfo & s) { return s.status == DlScheduleStatus::kOccupied; });
569+
566570
const auto & user = mLockUsers[userIndex];
567571
if (user.userType != UserTypeEnum::kScheduleRestrictedUser && user.userType != UserTypeEnum::kWeekDayScheduleUser)
568572
{
569-
return true;
573+
// Weekday schedules don't apply to this user.
574+
return false;
575+
}
576+
577+
if (user.userType == UserTypeEnum::kScheduleRestrictedUser && !*haveSchedule)
578+
{
579+
// It's valid to not have any schedules of a given type; on its own this
580+
// does not prevent access.
581+
return false;
570582
}
571583

572584
chip::System::Clock::Milliseconds64 cTMs;
@@ -575,7 +587,7 @@ bool LockEndpoint::weekDayScheduleInAction(uint16_t userIndex) const
575587
{
576588
ChipLogError(Zcl, "Lock App: unable to get current time to check user schedules [endpointId=%d,error=%d (%s)]", mEndpointId,
577589
chipError.AsInteger(), chipError.AsString());
578-
return false;
590+
return true;
579591
}
580592
time_t unixEpoch = std::chrono::duration_cast<chip::System::Clock::Seconds32>(cTMs).count();
581593

@@ -585,8 +597,9 @@ bool LockEndpoint::weekDayScheduleInAction(uint16_t userIndex) const
585597
auto currentTime =
586598
calendarTime.tm_hour * chip::kSecondsPerHour + calendarTime.tm_min * chip::kSecondsPerMinute + calendarTime.tm_sec;
587599

588-
// Second, check the week day schedules.
589-
return std::any_of(
600+
// Now check whether any schedule allows the current time. If it does,
601+
// access is not forbidden.
602+
return !std::any_of(
590603
mWeekDaySchedules[userIndex].begin(), mWeekDaySchedules[userIndex].end(),
591604
[currentTime, calendarTime](const WeekDaysScheduleInfo & s) {
592605
auto startTime = s.schedule.startHour * chip::kSecondsPerHour + s.schedule.startMinute * chip::kSecondsPerMinute;
@@ -596,12 +609,22 @@ bool LockEndpoint::weekDayScheduleInAction(uint16_t userIndex) const
596609
});
597610
}
598611

599-
bool LockEndpoint::yearDayScheduleInAction(uint16_t userIndex) const
612+
bool LockEndpoint::yearDayScheduleForbidsAccess(uint16_t userIndex, bool * haveSchedule) const
600613
{
614+
*haveSchedule = std::any_of(mYearDaySchedules[userIndex].begin(), mYearDaySchedules[userIndex].end(),
615+
[](const YearDayScheduleInfo & sch) { return sch.status == DlScheduleStatus::kOccupied; });
616+
601617
const auto & user = mLockUsers[userIndex];
602618
if (user.userType != UserTypeEnum::kScheduleRestrictedUser && user.userType != UserTypeEnum::kYearDayScheduleUser)
603619
{
604-
return true;
620+
return false;
621+
}
622+
623+
if (user.userType == UserTypeEnum::kScheduleRestrictedUser && !*haveSchedule)
624+
{
625+
// It's valid to not have any schedules of a given type; on its own this
626+
// does not prevent access.
627+
return false;
605628
}
606629

607630
chip::System::Clock::Milliseconds64 cTMs;
@@ -610,7 +633,7 @@ bool LockEndpoint::yearDayScheduleInAction(uint16_t userIndex) const
610633
{
611634
ChipLogError(Zcl, "Lock App: unable to get current time to check user schedules [endpointId=%d,error=%d (%s)]", mEndpointId,
612635
chipError.AsInteger(), chipError.AsString());
613-
return false;
636+
return true;
614637
}
615638
auto unixEpoch = std::chrono::duration_cast<chip::System::Clock::Seconds32>(cTMs).count();
616639
uint32_t chipEpoch = 0;
@@ -623,11 +646,11 @@ bool LockEndpoint::yearDayScheduleInAction(uint16_t userIndex) const
623646
return false;
624647
}
625648

626-
return std::any_of(mYearDaySchedules[userIndex].begin(), mYearDaySchedules[userIndex].end(),
627-
[chipEpoch](const YearDayScheduleInfo & sch) {
628-
return sch.status == DlScheduleStatus::kOccupied && sch.schedule.localStartTime <= chipEpoch &&
629-
chipEpoch <= sch.schedule.localEndTime;
630-
});
649+
return !std::any_of(mYearDaySchedules[userIndex].begin(), mYearDaySchedules[userIndex].end(),
650+
[chipEpoch](const YearDayScheduleInfo & sch) {
651+
return sch.status == DlScheduleStatus::kOccupied && sch.schedule.localStartTime <= chipEpoch &&
652+
chipEpoch <= sch.schedule.localEndTime;
653+
});
631654
}
632655

633656
const char * LockEndpoint::lockStateToString(DlLockState lockState) const

examples/platform/silabs/BaseApplication.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
453453
{
454454
// The factory reset sequence was not initiated,
455455
// Press and Release:
456-
// - Open the commissioning window and start BLE advertissement in fast mode when not commissioned
456+
// - Open the commissioning window and start BLE advertisement in fast mode when not commissioned
457457
// - Output qr code in logs
458458
// - Cycle LCD screen
459459
CancelFunctionTimer();
@@ -477,7 +477,7 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
477477
}
478478
else
479479
{
480-
SILABS_LOG("Network is already provisioned, Ble advertissement not enabled");
480+
SILABS_LOG("Network is already provisioned, Ble advertisement not enabled");
481481
#if CHIP_CONFIG_ENABLE_ICD_SERVER
482482
// Temporarily claim network activity, until we implement a "user trigger" reason for ICD wakeups.
483483
PlatformMgr().LockChipStack();

scripts/rules.matterlint

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ load "../src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster
6868
load "../src/app/zap-templates/zcl/data-model/chip/oven-mode-cluster.xml";
6969
load "../src/app/zap-templates/zcl/data-model/chip/power-source-cluster.xml";
7070
load "../src/app/zap-templates/zcl/data-model/chip/power-source-configuration-cluster.xml";
71+
load "../src/app/zap-templates/zcl/data-model/chip/power-topology-cluster.xml";
7172
load "../src/app/zap-templates/zcl/data-model/chip/pressure-measurement-cluster.xml";
7273
load "../src/app/zap-templates/zcl/data-model/chip/proxy-configuration-cluster.xml";
7374
load "../src/app/zap-templates/zcl/data-model/chip/proxy-discovery-cluster.xml";

src/app/server/Dnssd.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ CHIP_ERROR DnssdServer::GenerateRotatingDeviceId(char rotatingDeviceIdHexBuffer[
496496
void DnssdServer::OnICDModeChange()
497497
{
498498
// ICDMode changed, restart DNS-SD advertising, because SII and ICD key are affected by this change.
499-
// StartServer will take care of setting the operational and commissionable advertissements
499+
// StartServer will take care of setting the operational and commissionable advertisements
500500
StartServer();
501501
}
502502

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
Copyright (c) 2024 Project CHIP Authors
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<configurator>
18+
<domain name="Measurement &amp; Sensing"/>
19+
<bitmap name="Feature" type="bitmap32">
20+
<cluster code="0x009C"/>
21+
<field name="NodeTopology" mask="0x01"/>
22+
<field name="TreeTopology" mask="0x02"/>
23+
<field name="SetTopology" mask="0x04"/>
24+
<field name="DynamicPowerFlow" mask="0x08"/>
25+
</bitmap>
26+
<cluster code="0x009C">
27+
<domain>Measurement &amp; Sensing</domain>
28+
<name>Power Topology</name>
29+
<code>0x009C</code>
30+
<define>POWER_TOPOLOGY_CLUSTER</define>
31+
<description>The Power Topology Cluster provides a mechanism for expressing how power is flowing between endpoints.</description>
32+
<client init="false" tick="false">true</client>
33+
<server init="false" tick="false">true</server>
34+
<globalAttribute code="0xFFFD" side="either" value="1"/>
35+
<attribute code="0x0000" side="server" define="AVAILABLE_ENDPOINTS" type="array" entryType="endpoint_no" length="20" optional="true">AvailableEndpoints</attribute>
36+
<attribute code="0x0001" side="server" define="ACTIVE_ENDPOINTS" type="array" entryType="endpoint_no" length="20" optional="true">ActiveEndpoints</attribute>
37+
</cluster>
38+
</configurator>

src/app/zap-templates/zcl/zcl-with-test-extensions.json

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"operational-state-oven-cluster.xml",
8989
"operational-state-rvc-cluster.xml",
9090
"oven-mode-cluster.xml",
91+
"power-topology-cluster.xml",
9192
"pressure-measurement-cluster.xml",
9293
"power-source-cluster.xml",
9394
"power-source-configuration-cluster.xml",

src/app/zap-templates/zcl/zcl.json

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"operational-state-oven-cluster.xml",
8686
"operational-state-rvc-cluster.xml",
8787
"oven-mode-cluster.xml",
88+
"power-topology-cluster.xml",
8889
"pressure-measurement-cluster.xml",
8990
"power-source-cluster.xml",
9091
"power-source-configuration-cluster.xml",

src/app/zap_cluster_list.json

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"MESSAGES_CLUSTER": [],
6969
"MODE_SELECT_CLUSTER": [],
7070
"NETWORK_COMMISSIONING_CLUSTER": [],
71+
"POWER_TOPOLOGY_CLUSTER": [],
7172
"SAMPLE_MEI_CLUSTER": [],
7273
"NITROGEN_DIOXIDE_CONCENTRATION_MEASUREMENT_CLUSTER": [],
7374
"OCCUPANCY_SENSING_CLUSTER": ["occupancy-sensor-server"],
@@ -227,6 +228,7 @@
227228
"SAMPLE_MEI_CLUSTER": ["sample-mei-server"],
228229
"OCCUPANCY_SENSING_CLUSTER": ["occupancy-sensor-server"],
229230
"ON_OFF_CLUSTER": ["on-off-server"],
231+
"POWER_TOPOLOGY_CLUSTER": [],
230232
"ON_OFF_SWITCH_CONFIGURATION_CLUSTER": [],
231233
"OPERATIONAL_CREDENTIALS_CLUSTER": ["operational-credentials-server"],
232234
"OPERATIONAL_STATE_CLUSTER": ["operational-state-server"],

src/controller/data_model/controller-clusters.matter

+21
Original file line numberDiff line numberDiff line change
@@ -5010,6 +5010,27 @@ cluster EnergyPreference = 155 {
50105010
readonly attribute int16u clusterRevision = 65533;
50115011
}
50125012

5013+
/** The Power Topology Cluster provides a mechanism for expressing how power is flowing between endpoints. */
5014+
cluster PowerTopology = 156 {
5015+
revision 1;
5016+
5017+
bitmap Feature : bitmap32 {
5018+
kNodeTopology = 0x1;
5019+
kTreeTopology = 0x2;
5020+
kSetTopology = 0x4;
5021+
kDynamicPowerFlow = 0x8;
5022+
}
5023+
5024+
readonly attribute optional endpoint_no availableEndpoints[] = 0;
5025+
readonly attribute optional endpoint_no activeEndpoints[] = 1;
5026+
readonly attribute command_id generatedCommandList[] = 65528;
5027+
readonly attribute command_id acceptedCommandList[] = 65529;
5028+
readonly attribute event_id eventList[] = 65530;
5029+
readonly attribute attrib_id attributeList[] = 65531;
5030+
readonly attribute bitmap32 featureMap = 65532;
5031+
readonly attribute int16u clusterRevision = 65533;
5032+
}
5033+
50135034
/** Attributes and commands for selecting a mode from a list of supported options. */
50145035
provisional cluster EnergyEvseMode = 157 {
50155036
revision 1;

0 commit comments

Comments
 (0)