Skip to content

Commit f7c27b3

Browse files
authored
Merge branch 'master' into granbery/preset_python
2 parents c1e5d29 + cea7fd8 commit f7c27b3

File tree

22 files changed

+4400
-63
lines changed

22 files changed

+4400
-63
lines changed

.github/workflows/qemu.yaml

+2-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ concurrency:
2727

2828
env:
2929
CHIP_NO_LOG_TIMESTAMPS: true
30-
30+
3131
jobs:
3232

3333
qemu-esp32:
@@ -75,12 +75,7 @@ jobs:
7575
name: Tizen
7676

7777
runs-on: ubuntu-latest
78-
# NOTE: job temporarely disabled as it seems flaky. The flake does not result in usable
79-
# logs so the current theory is that we run out of space. This is unusual as
80-
# larger docker images succeed at bootstrap, however it needs more investigation
81-
# to detect an exact/real root cause.
82-
if: false
83-
# if: github.actor != 'restyled-io[bot]'
78+
if: github.actor != 'restyled-io[bot]'
8479

8580
container:
8681
image: ghcr.io/project-chip/chip-build-tizen-qemu:54

build/config/compiler/BUILD.gn

+5-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,11 @@ config("warnings_third_party") {
334334
}
335335

336336
config("symbols_default") {
337-
cflags = [ "-g${symbol_level}" ]
337+
if (strip_symbols) {
338+
cflags = [ "-s" ]
339+
} else {
340+
cflags = [ "-g${symbol_level}" ]
341+
}
338342
}
339343

340344
config("std_default") {

build/config/compiler/compiler.gni

+6-3
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ declare_args() {
3030
symbol_level = 2
3131

3232
# Enable position independent code (-fPIC).
33-
enable_pic =
34-
current_os == "linux" || current_os == "mac" || current_os == "android"
33+
enable_pic = current_os == "linux" || current_os == "mac" ||
34+
current_os == "android" || current_os == "tizen"
3535

3636
# Enable position independent executables (-pie).
37-
enable_pie = current_os == "linux"
37+
enable_pie = current_os == "linux" || current_os == "tizen"
3838

3939
# Remove unwind tables from the binary to save space.
4040
exclude_unwind_tables = current_os != "android"
@@ -48,6 +48,9 @@ declare_args() {
4848
# enable libfuzzer
4949
is_libfuzzer = false
5050

51+
# Remove all symbol table and relocation information from the binary.
52+
strip_symbols = false
53+
5154
# Generate code coverage analysis artifacts when enabled.
5255
use_coverage = false
5356

examples/fabric-bridge-app/fabric-bridge-common/src/ZCLCallbacks.cpp

+23-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using namespace ::chip;
2626
using namespace ::chip::app::Clusters;
2727

2828
#define ZCL_DESCRIPTOR_CLUSTER_REVISION (1u)
29+
#define ZCL_ADMINISTRATOR_COMMISSIONING_CLUSTER_REVISION (1u)
2930
#define ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_REVISION (2u)
3031
#define ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_FEATURE_MAP (0u)
3132

@@ -37,9 +38,14 @@ Protocols::InteractionModel::Status emberAfExternalAttributeReadCallback(Endpoin
3738
AttributeId attributeId = attributeMetadata->attributeId;
3839

3940
BridgedDevice * dev = BridgeDeviceMgr().GetDevice(endpoint);
40-
if (dev != nullptr && clusterId == app::Clusters::BridgedDeviceBasicInformation::Id)
41+
if (dev == nullptr)
4142
{
42-
using namespace app::Clusters::BridgedDeviceBasicInformation::Attributes;
43+
return Protocols::InteractionModel::Status::Failure;
44+
}
45+
46+
if (clusterId == BridgedDeviceBasicInformation::Id)
47+
{
48+
using namespace BridgedDeviceBasicInformation::Attributes;
4349
ChipLogProgress(NotSpecified, "HandleReadBridgedDeviceBasicAttribute: attrId=%d, maxReadLength=%d", attributeId,
4450
maxReadLength);
4551

@@ -69,6 +75,21 @@ Protocols::InteractionModel::Status emberAfExternalAttributeReadCallback(Endpoin
6975
return Protocols::InteractionModel::Status::Success;
7076
}
7177

78+
if (clusterId == AdministratorCommissioning::Id)
79+
{
80+
// TODO(#34791) This is a workaround to prevent crash. CADMIN is still reading incorrect
81+
// Attribute values on dynamic endpoint as it only reads the root node and not the actual bridge
82+
// device we are representing here, when addressing the issue over there we can more easily
83+
// resolve this workaround.
84+
if ((attributeId == AdministratorCommissioning::Attributes::ClusterRevision::Id) && (maxReadLength == 2))
85+
{
86+
uint16_t rev = ZCL_ADMINISTRATOR_COMMISSIONING_CLUSTER_REVISION;
87+
memcpy(buffer, &rev, sizeof(rev));
88+
return Protocols::InteractionModel::Status::Success;
89+
}
90+
return Protocols::InteractionModel::Status::Failure;
91+
}
92+
7293
return Protocols::InteractionModel::Status::Failure;
7394
}
7495

examples/network-manager-app/linux/include/CHIPProjectAppConfig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#pragma once
2020

21-
#define CHIP_DEVICE_CONFIG_DEVICE_TYPE 0xFFF10010 // TODO: ID-TBD
21+
#define CHIP_DEVICE_CONFIG_DEVICE_TYPE 144 // 0x0090 Network Infrastructure Manager
2222
#define CHIP_DEVICE_CONFIG_DEVICE_NAME "Network Infrastructure Manager"
2323

2424
// Inherit defaults from config/standalone/CHIPProjectConfig.h

scripts/build/builders/tizen.py

+4
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ def __init__(self,
117117

118118
if app == TizenApp.TESTS:
119119
self.extra_gn_options.append('chip_build_tests=true')
120+
# Tizen test driver creates ISO image with all unit test files. So,
121+
# it uses twice as much space as regular build. Due to CI storage
122+
# limitations, we need to strip debug symbols from executables.
123+
self.extra_gn_options.append('strip_symbols=true')
120124
self.build_command = 'check'
121125

122126
if not enable_ble:

src/app/clusters/color-control-server/color-control-server.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -3113,15 +3113,15 @@ void ColorControlServer::levelControlColorTempChangeCommand(EndpointId endpoint)
31133113
* - When it changes from null to any other value and vice versa. (Implicit to the QuieterReportingAttribute class)
31143114
*
31153115
* The QuietReportAttribute class is updated with the new value and when the report conditions are met,
3116-
* this function will return MarkAttributeDirty::kIfChanged.
3116+
* this function will return MarkAttributeDirty::kYes.
31173117
* It is expected that the user will use this return value to trigger a reporting mechanism for the attribute with the new value
31183118
* (Which was updated in the quietReporter)
31193119
*
31203120
* @param quietReporter: The QuieterReportingAttribute<TYPE> object for the attribute to update.
31213121
* @param newValue: Value to update the attribute with
31223122
* @param isStartOrEndOfTransition: Boolean that indicatse whether the update is occurring at the start or end of a level transition
3123-
* @return MarkAttributeDirty::kIfChanged when the attribute must be maredk dirty and be reported. MarkAttributeDirty::kNo when it
3124-
* when it no report is needed.
3123+
* @return MarkAttributeDirty::kYes when the attribute must be marked dirty and be reported. MarkAttributeDirty::kNo when
3124+
* no report is needed.
31253125
*/
31263126
template <typename Q, typename V>
31273127
MarkAttributeDirty ColorControlServer::SetQuietReportAttribute(QuieterReportingAttribute<Q> & quietReporter, V newValue,
@@ -3132,7 +3132,7 @@ MarkAttributeDirty ColorControlServer::SetQuietReportAttribute(QuieterReportingA
31323132

31333133
if (isStartOrEndOfTransition)
31343134
{
3135-
// At the start or end of the movement/transition we must report
3135+
// At the start or end of the movement/transition we must report if the value changed
31363136
auto predicate = [](const typename QuieterReportingAttribute<Q>::SufficientChangePredicateCandidate &) -> bool {
31373137
return true;
31383138
};
@@ -3155,7 +3155,7 @@ MarkAttributeDirty ColorControlServer::SetQuietReportAttribute(QuieterReportingA
31553155
dirtyState = quietReporter.SetValue(newValue, now, predicate);
31563156
}
31573157

3158-
return (dirtyState == AttributeDirtyState::kMustReport) ? MarkAttributeDirty::kIfChanged : MarkAttributeDirty::kNo;
3158+
return (dirtyState == AttributeDirtyState::kMustReport) ? MarkAttributeDirty::kYes : MarkAttributeDirty::kNo;
31593159
}
31603160

31613161
/*
@@ -3180,7 +3180,7 @@ Status ColorControlServer::SetQuietReportRemainingTime(EndpointId endpoint, uint
31803180
// - kMarkDirtyOnIncrement : When the value increases.
31813181
if (quietRemainingTime[epIndex].SetValue(newRemainingTime, now) == AttributeDirtyState::kMustReport)
31823182
{
3183-
markDirty = MarkAttributeDirty::kIfChanged;
3183+
markDirty = MarkAttributeDirty::kYes;
31843184
}
31853185

31863186
return Attributes::RemainingTime::Set(endpoint, quietRemainingTime[epIndex].value().Value(), markDirty);

src/app/clusters/level-control/level-control.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ static void writeRemainingTime(EndpointId endpoint, uint16_t remainingTimeMs)
545545
markDirty = MarkAttributeDirty::kYes;
546546
}
547547

548-
Attributes::RemainingTime::Set(endpoint, state->quietRemainingTime.value().ValueOr(0), markDirty);
548+
Attributes::RemainingTime::Set(endpoint, state->quietRemainingTime.value().Value(), markDirty);
549549
}
550550
#endif // IGNORE_LEVEL_CONTROL_CLUSTER_LEVEL_CONTROL_REMAINING_TIME
551551
}

src/controller/CommissionerDiscoveryController.cpp

+26-2
Original file line numberDiff line numberDiff line change
@@ -589,12 +589,36 @@ void CommissionerDiscoveryController::Cancel()
589589
return;
590590
}
591591
UDCClientState * client = mUdcServer->GetUDCClients().FindUDCClientState(mCurrentInstance);
592-
if (client == nullptr || client->GetUDCClientProcessingState() != UDCClientProcessingState::kPromptingUser)
592+
593+
if (client == nullptr)
594+
{
595+
ChipLogError(AppServer, "UX Cancel: client not found");
596+
return;
597+
}
598+
599+
auto state = client->GetUDCClientProcessingState();
600+
601+
bool isCancelableState =
602+
(state == UDCClientProcessingState::kPromptingUser || state == UDCClientProcessingState::kObtainingOnboardingPayload ||
603+
state == UDCClientProcessingState::kWaitingForCommissionerPasscodeReady);
604+
605+
if (!isCancelableState)
593606
{
594-
ChipLogError(AppServer, "UX Cancel: invalid state for cancel");
607+
ChipLogError(AppServer, "UX Cancel: invalid state for cancel, state: %hhu", static_cast<uint8_t>(state));
595608
return;
596609
}
610+
597611
client->SetUDCClientProcessingState(UDCClientProcessingState::kUserDeclined);
612+
613+
if (state == UDCClientProcessingState::kObtainingOnboardingPayload ||
614+
state == UDCClientProcessingState::kWaitingForCommissionerPasscodeReady)
615+
{
616+
ChipLogDetail(AppServer, "UX Cancel: user cancelled entering PIN code, sending CDC");
617+
CommissionerDeclaration cd;
618+
cd.SetCancelPasscode(true);
619+
mUdcServer->SendCDCMessage(cd, Transport::PeerAddress::UDP(client->GetPeerAddress().GetIPAddress(), client->GetCdPort()));
620+
}
621+
598622
mPendingConsent = false;
599623
ResetState();
600624
}

src/darwin/Framework/CHIP/MTRDevice.mm

+31-25
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,6 @@ - (BOOL)callDelegateSynchronouslyWithBlock:(void (^)(id<MTRDeviceDelegate>))bloc
142142
#endif
143143
@end
144144

145-
NSNumber * MTRClampedNumber(NSNumber * aNumber, NSNumber * min, NSNumber * max)
146-
{
147-
if ([aNumber compare:min] == NSOrderedAscending) {
148-
return min;
149-
} else if ([aNumber compare:max] == NSOrderedDescending) {
150-
return max;
151-
}
152-
return aNumber;
153-
}
154-
155145
/* BEGIN DRAGONS: Note methods here cannot be renamed, and are used by private callers, do not rename, remove or modify behavior here */
156146

157147
@interface NSObject (MatterPrivateForInternalDragonsDoNotFeed)
@@ -252,10 +242,6 @@ @implementation MTRDeviceClusterData {
252242
NSMutableDictionary<NSNumber *, MTRDeviceDataValueDictionary> * _attributes;
253243
}
254244

255-
static NSString * const sDataVersionKey = @"dataVersion";
256-
static NSString * const sAttributesKey = @"attributes";
257-
static NSString * const sLastInitialSubscribeLatencyKey = @"lastInitialSubscribeLatency";
258-
259245
- (void)storeValue:(MTRDeviceDataValueDictionary _Nullable)value forAttribute:(NSNumber *)attribute
260246
{
261247
_attributes[attribute] = value;
@@ -498,6 +484,15 @@ @implementation MTRDevice {
498484
NSMutableSet<MTRDeviceDelegateInfo *> * _delegates;
499485
}
500486

487+
- (instancetype)initForSubclasses
488+
{
489+
if (self = [super init]) {
490+
// nothing, as superclass of MTRDevice is NSObject
491+
}
492+
493+
return self;
494+
}
495+
501496
- (instancetype)initWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller
502497
{
503498
if (self = [super init]) {
@@ -1193,23 +1188,21 @@ - (void)_handleSubscriptionEstablished
11931188
{
11941189
os_unfair_lock_lock(&self->_lock);
11951190

1196-
// We have completed the subscription work - remove from the subscription pool.
1197-
[self _clearSubscriptionPoolWork];
1198-
1199-
// reset subscription attempt wait time when subscription succeeds
1200-
_lastSubscriptionAttemptWait = 0;
1201-
if (HadSubscriptionEstablishedOnce(_internalDeviceState)) {
1202-
[self _changeInternalState:MTRInternalDeviceStateLaterSubscriptionEstablished];
1203-
} else {
1204-
MATTER_LOG_METRIC_END(kMetricMTRDeviceInitialSubscriptionSetup, CHIP_NO_ERROR);
1205-
[self _changeInternalState:MTRInternalDeviceStateInitialSubscriptionEstablished];
1191+
// If subscription had reset since this handler was scheduled, do not execute "established" logic below
1192+
if (!HaveSubscriptionEstablishedRightNow(_internalDeviceState)) {
1193+
MTR_LOG("%@ _handleSubscriptionEstablished run with internal state %lu - skipping subscription establishment logic", self, static_cast<unsigned long>(_internalDeviceState));
1194+
return;
12061195
}
12071196

1208-
[self _changeState:MTRDeviceStateReachable];
1197+
// We have completed the subscription work - remove from the subscription pool.
1198+
[self _clearSubscriptionPoolWork];
12091199

12101200
// No need to monitor connectivity after subscription establishment
12111201
[self _stopConnectivityMonitoring];
12121202

1203+
// reset subscription attempt wait time when subscription succeeds
1204+
_lastSubscriptionAttemptWait = 0;
1205+
12131206
auto initialSubscribeStart = _initialSubscribeStart;
12141207
// We no longer need to track subscribe latency for this device.
12151208
_initialSubscribeStart = nil;
@@ -2476,6 +2469,19 @@ - (void)_setupSubscriptionWithReason:(NSString *)reason
24762469
},
24772470
^(void) {
24782471
MTR_LOG("%@ got subscription established", self);
2472+
std::lock_guard lock(self->_lock);
2473+
2474+
// First synchronously change state
2475+
if (HadSubscriptionEstablishedOnce(self->_internalDeviceState)) {
2476+
[self _changeInternalState:MTRInternalDeviceStateLaterSubscriptionEstablished];
2477+
} else {
2478+
MATTER_LOG_METRIC_END(kMetricMTRDeviceInitialSubscriptionSetup, CHIP_NO_ERROR);
2479+
[self _changeInternalState:MTRInternalDeviceStateInitialSubscriptionEstablished];
2480+
}
2481+
2482+
[self _changeState:MTRDeviceStateReachable];
2483+
2484+
// Then async work that shouldn't be performed on the matter queue
24792485
dispatch_async(self.queue, ^{
24802486
// OnSubscriptionEstablished
24812487
[self _handleSubscriptionEstablished];

src/darwin/Framework/CHIP/MTRDeviceController.mm

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#import "MTRDeviceControllerLocalTestStorage.h"
3232
#import "MTRDeviceControllerStartupParams.h"
3333
#import "MTRDeviceControllerStartupParams_Internal.h"
34+
#import "MTRDevice_Concrete.h"
3435
#import "MTRDevice_Internal.h"
3536
#import "MTRError_Internal.h"
3637
#import "MTRKeypair.h"
@@ -988,7 +989,7 @@ - (MTRDevice *)_setupDeviceForNodeID:(NSNumber *)nodeID prefetchedClusterData:(N
988989
{
989990
os_unfair_lock_assert_owner(&_deviceMapLock);
990991

991-
MTRDevice * deviceToReturn = [[MTRDevice alloc] initWithNodeID:nodeID controller:self];
992+
MTRDevice * deviceToReturn = [[MTRDevice_Concrete alloc] initWithNodeID:nodeID controller:self];
992993
// If we're not running, don't add the device to our map. That would
993994
// create a cycle that nothing would break. Just return the device,
994995
// which will be in exactly the state it would be in if it were created
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
*
3+
* Copyright (c) 2022-2023 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+
18+
#import <Foundation/Foundation.h>
19+
#import <Matter/MTRDevice.h>
20+
21+
NS_ASSUME_NONNULL_BEGIN
22+
23+
@interface MTRDevice_Concrete : MTRDevice
24+
25+
@end
26+
27+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)