Skip to content

Commit 0cb134e

Browse files
Merge branch 'master' into silabs/add_air_quality_app
2 parents a4305a5 + 0adae42 commit 0cb134e

File tree

17 files changed

+125
-107
lines changed

17 files changed

+125
-107
lines changed

build/config/linux/pkg-config.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ def main():
142142
dest='dridriverdir')
143143
parser.add_option('--version-as-components', action='store_true',
144144
dest='version_as_components')
145+
parser.add_option('--static', action='store_true',
146+
dest='static')
145147
(options, args) = parser.parse_args()
146148

147149
# Make a list of regular expressions to strip out.
@@ -203,7 +205,13 @@ def main():
203205
sys.stdout.write(dridriverdir.strip())
204206
return
205207

206-
cmd = [options.pkg_config, "--cflags", "--libs"] + args
208+
cmd = [options.pkg_config, "--cflags", "--libs"]
209+
210+
if options.static:
211+
cmd.append("--static")
212+
213+
cmd.extend(args)
214+
207215
if options.debug:
208216
sys.stderr.write('Running: %s\n' % ' '.join(cmd))
209217

build/config/linux/pkg_config.gni

+11-2
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,19 @@ template("pkg_config") {
137137

138138
# Link libraries statically for OSS-Fuzz fuzzer build
139139
if (oss_fuzz) {
140+
# Output libs needed for static linking (direct + transitive/non-direct libs), we will re-execute the script to get those libs
141+
args += [ "--static" ]
142+
pkgresult_static = exec_script(pkg_config_script, args, "value")
140143
libs = []
141144
ldflags = [ "-Wl,-Bstatic" ]
142-
foreach(lib, pkgresult[3]) {
143-
ldflags += [ "-l$lib" ]
145+
foreach(lib, pkgresult_static[3]) {
146+
# dl(dynamic loading) lib is not needed for linking statically and its presence triggers errors.
147+
# example of errors:
148+
# ld.lld: error: undefined symbol: __dlsym
149+
# >>> referenced by dlsym.o:(dlsym) in archive /lib/x86_64-linux-gnu/libdl.a
150+
if (lib != "dl") {
151+
ldflags += [ "-l$lib" ]
152+
}
144153
}
145154
ldflags += [ "-Wl,-Bdynamic" ]
146155
lib_dirs = pkgresult[4]

examples/chef/dockerfile

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
FROM debian:bullseye
1+
FROM debian:trixie
22

33
ARG DEVICE_NAME
44

55
RUN apt-get update && \
66
apt-get install -y \
7-
libglib2.0-0 && \
7+
libglib2.0-0 \
8+
libc6 \
9+
libssl3 && \
810
apt-get clean && \
911
rm -rf /var/lib/apt/lists/*
1012

examples/ota-provider-app/esp32/main/BdxOtaSender.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ void BdxOtaSender::HandleTransferSessionOutput(TransferSession::OutputEvent & ev
174174
{
175175
ChipLogError(BDX, "onTransferComplete Callback not set");
176176
}
177-
mStopPolling = true; // Stop polling the TransferSession only after receiving BlockAckEOF
178177
Reset();
179178
break;
180179
case TransferSession::OutputEventType::kStatusReceived:
@@ -228,7 +227,7 @@ void BdxOtaSender::Reset()
228227
{
229228
mFabricIndex.ClearValue();
230229
mNodeId.ClearValue();
231-
mTransfer.Reset();
230+
ResetTransfer();
232231
if (mExchangeCtx != nullptr)
233232
{
234233
mExchangeCtx->Close();

examples/ota-provider-app/ota-provider-common/BdxOtaSender.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ void BdxOtaSender::HandleTransferSessionOutput(TransferSession::OutputEvent & ev
180180
break;
181181
case TransferSession::OutputEventType::kAckEOFReceived:
182182
ChipLogDetail(BDX, "Transfer completed, got AckEOF");
183-
mStopPolling = true; // Stop polling the TransferSession only after receiving BlockAckEOF
184183
Reset();
185184
break;
186185
case TransferSession::OutputEventType::kStatusReceived:
@@ -212,7 +211,7 @@ void BdxOtaSender::Reset()
212211
{
213212
mFabricIndex.ClearValue();
214213
mNodeId.ClearValue();
215-
Responder::ResetTransfer();
214+
ResetTransfer();
216215
if (mExchangeCtx != nullptr)
217216
{
218217
mExchangeCtx->Close();

src/app/tests/suites/certification/Test_TC_OO_2_7.yaml

+9-9
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ tests:
5858
}
5959

6060
- label:
61-
"Step 0b: TH binds GroupIds 0x0001 and 0x0002 with GroupKeySetID
62-
0x01a1 in the GroupKeyMap attribute list on GroupKeyManagement cluster
63-
by writing the GroupKeyMap attribute with two entries as follows:"
61+
"Step 0b: TH binds GroupIds 0x0001 with GroupKeySetID 0x01a1 in the
62+
GroupKeyMap attribute list on GroupKeyManagement cluster by writing
63+
the GroupKeyMap attribute with two entries as follows:"
6464
cluster: "Group Key Management"
6565
endpoint: 0
6666
command: "writeAttribute"
@@ -142,7 +142,7 @@ tests:
142142
value: 0
143143

144144
- label:
145-
"Step 2b: TH sends a StoreScene command to DUT with the GroupID field
145+
"Step 3: TH sends a StoreScene command to DUT with the GroupID field
146146
set to G1 and the SceneID field set to 0x01."
147147
command: "StoreScene"
148148
arguments:
@@ -160,7 +160,7 @@ tests:
160160
- name: "SceneID"
161161
value: 0x01
162162

163-
- label: "Step 3: TH sends a AddScene command to DUT with the GroupID field
163+
- label: "Step 4: TH sends a AddScene command to DUT with the GroupID field
164164
set to G1, the SceneID field set to 0x02, the TransitionTime field set
165165
to 1000 (1s) and the ExtensionFieldSets set to: '[{ ClusterID: 0x0006,
166166
AttributeValueList: [{ AttributeID: 0x0000, ValueUnsigned8: 0x01 }]}]'
@@ -195,7 +195,7 @@ tests:
195195
value: 0x02
196196

197197
- label:
198-
"Step 4a: TH sends a RecallScene command to DUT with the GroupID field
198+
"Step 5a: TH sends a RecallScene command to DUT with the GroupID field
199199
set to G1 and the SceneID field set to 0x02."
200200
PICS: S.S.C05.Rsp
201201
command: "RecallScene"
@@ -214,15 +214,15 @@ tests:
214214
- name: "ms"
215215
value: 2000
216216

217-
- label: "Step 4b: after a few seconds, TH reads OnOff attribute from DUT"
217+
- label: "Step 5b: after a few seconds, TH reads OnOff attribute from DUT"
218218
cluster: "On/Off"
219219
command: "readAttribute"
220220
attribute: "OnOff"
221221
response:
222222
value: 1
223223

224224
- label:
225-
"Step 5a: TH sends a RecallScene command to DUT with the GroupID field
225+
"Step 6a: TH sends a RecallScene command to DUT with the GroupID field
226226
set to G1 and the SceneID field set to 0x01."
227227
PICS: S.S.C05.Rsp
228228
command: "RecallScene"
@@ -241,7 +241,7 @@ tests:
241241
- name: "ms"
242242
value: 1000
243243

244-
- label: "Step 5b: after a few seconds, TH reads OnOff attribute from DUT"
244+
- label: "Step 6b: after a few seconds, TH reads OnOff attribute from DUT"
245245
cluster: "On/Off"
246246
command: "readAttribute"
247247
attribute: "OnOff"

src/darwin/Framework/CHIP/MTRDefines_Internal.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,4 @@ typedef struct {} variable_hidden_by_mtr_hide;
151151
}
152152
#endif
153153

154-
#ifndef YES_NO
155-
#define YES_NO(x) ((x) ? @"YES" : @"NO")
156-
#endif
154+
#define MTR_YES_NO(x) ((x) ? @"YES" : @"NO")

src/darwin/Framework/CHIP/MTRDevice.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ - (nullable MTRDeviceClusterData *)_clusterDataForPath:(MTRClusterPath *)cluster
11581158

11591159
// Page in the stored value for the data.
11601160
MTRDeviceClusterData * data = [_deviceController.controllerDataStore getStoredClusterDataForNodeID:_nodeID endpointID:clusterPath.endpoint clusterID:clusterPath.cluster];
1161-
MTR_LOG("%@ cluster path %@ cache miss - load from storage success %@", self, clusterPath, YES_NO(data));
1161+
MTR_LOG("%@ cluster path %@ cache miss - load from storage success %@", self, clusterPath, MTR_YES_NO(data));
11621162
if (data != nil) {
11631163
[_persistedClusterData setObject:data forKey:clusterPath];
11641164
} else {

src/darwin/Framework/CHIP/MTRDeviceController.h

+7
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,13 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
198198
/**
199199
* Adds a Delegate to the device controller as well as the Queue on which the Delegate callbacks will be triggered
200200
*
201+
* Multiple delegates can be added to monitor MTRDeviceController state changes. Note that there should only
202+
* be one delegate that responds to pairing related callbacks.
203+
*
204+
* If a delegate is added a second time, the call would be ignored.
205+
*
206+
* All delegates are held by weak references, and so if a delegate object goes away, it will be automatically removed.
207+
*
201208
* @param[in] delegate The delegate the commissioning process should use
202209
*
203210
* @param[in] queue The queue on which the callbacks will be delivered

src/darwin/Framework/CHIP/MTRDeviceController.mm

+17-9
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ @implementation MTRDeviceController {
165165
BOOL _shutdownPending;
166166
os_unfair_lock _assertionLock;
167167

168-
NSMutableSet<MTRDeviceControllerDelegateInfo *> * _delegates;
168+
NSMutableArray<MTRDeviceControllerDelegateInfo *> * _delegates;
169169
id<MTRDeviceControllerDelegate> _strongDelegateForSetDelegateAPI;
170170
}
171171

@@ -196,7 +196,7 @@ - (instancetype)initForSubclasses:(BOOL)startSuspended
196196

197197
_nodeIDToDeviceMap = [NSMapTable strongToWeakObjectsMapTable];
198198

199-
_delegates = [NSMutableSet set];
199+
_delegates = [NSMutableArray array];
200200

201201
return self;
202202
}
@@ -1793,7 +1793,7 @@ + (void)forceLocalhostAdvertisingOnly
17931793

17941794
#pragma mark - MTRDeviceControllerDelegate management
17951795

1796-
// Note these are implemented in the base class so that XPC subclass can use it as well when it
1796+
// Note these are implemented in the base class so that XPC subclass can use it as well
17971797
- (void)setDeviceControllerDelegate:(id<MTRDeviceControllerDelegate>)delegate queue:(dispatch_queue_t)queue
17981798
{
17991799
@synchronized(self) {
@@ -1814,6 +1814,17 @@ - (void)setDeviceControllerDelegate:(id<MTRDeviceControllerDelegate>)delegate qu
18141814
- (void)addDeviceControllerDelegate:(id<MTRDeviceControllerDelegate>)delegate queue:(dispatch_queue_t)queue
18151815
{
18161816
@synchronized(self) {
1817+
__block BOOL delegateAlreadyAdded = NO;
1818+
[self _iterateDelegateInfoWithBlock:^(MTRDeviceControllerDelegateInfo * delegateInfo) {
1819+
if (delegateInfo.delegate == delegate) {
1820+
delegateAlreadyAdded = YES;
1821+
}
1822+
}];
1823+
if (delegateAlreadyAdded) {
1824+
MTR_LOG("%@ addDeviceControllerDelegate: delegate already added", self);
1825+
return;
1826+
}
1827+
18171828
MTRDeviceControllerDelegateInfo * newDelegateInfo = [[MTRDeviceControllerDelegateInfo alloc] initWithDelegate:delegate queue:queue];
18181829
[_delegates addObject:newDelegateInfo];
18191830
MTR_LOG("%@ addDeviceControllerDelegate: added %p total %lu", self, delegate, static_cast<unsigned long>(_delegates.count));
@@ -1836,9 +1847,6 @@ - (void)removeDeviceControllerDelegate:(id<MTRDeviceControllerDelegate>)delegate
18361847

18371848
if (delegateInfoToRemove) {
18381849
[_delegates removeObject:delegateInfoToRemove];
1839-
if (_strongDelegateForSetDelegateAPI == delegate) {
1840-
_strongDelegateForSetDelegateAPI = nil;
1841-
}
18421850
MTR_LOG("%@ removeDeviceControllerDelegate: removed %p remaining %lu", self, delegate, static_cast<unsigned long>(_delegates.count));
18431851
} else {
18441852
MTR_LOG("%@ removeDeviceControllerDelegate: delegate %p not found in %lu", self, delegate, static_cast<unsigned long>(_delegates.count));
@@ -1857,7 +1865,7 @@ - (NSUInteger)_iterateDelegateInfoWithBlock:(void (^_Nullable)(MTRDeviceControll
18571865
}
18581866

18591867
// Opportunistically remove defunct delegate references on every iteration
1860-
NSMutableSet * delegatesToRemove = nil;
1868+
NSMutableArray * delegatesToRemove = nil;
18611869
for (MTRDeviceControllerDelegateInfo * delegateInfo in _delegates) {
18621870
id<MTRDeviceControllerDelegate> strongDelegate = delegateInfo.delegate;
18631871
if (strongDelegate) {
@@ -1866,14 +1874,14 @@ - (NSUInteger)_iterateDelegateInfoWithBlock:(void (^_Nullable)(MTRDeviceControll
18661874
}
18671875
} else {
18681876
if (!delegatesToRemove) {
1869-
delegatesToRemove = [NSMutableSet set];
1877+
delegatesToRemove = [NSMutableArray array];
18701878
}
18711879
[delegatesToRemove addObject:delegateInfo];
18721880
}
18731881
}
18741882

18751883
if (delegatesToRemove.count) {
1876-
[_delegates minusSet:delegatesToRemove];
1884+
[_delegates removeObjectsInArray:delegatesToRemove];
18771885
MTR_LOG("%@ _iterateDelegatesWithBlock: removed %lu remaining %lu", self, static_cast<unsigned long>(delegatesToRemove.count), static_cast<unsigned long>(_delegates.count));
18781886
}
18791887

src/darwin/Framework/CHIP/MTRDevice_Concrete.mm

+3-3
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,8 @@ - (NSString *)description
445445
wifi = @"NO";
446446
thread = @"NO";
447447
} else {
448-
wifi = YES_NO(networkFeatures.unsignedLongLongValue & MTRNetworkCommissioningFeatureWiFiNetworkInterface);
449-
thread = YES_NO(networkFeatures.unsignedLongLongValue & MTRNetworkCommissioningFeatureThreadNetworkInterface);
448+
wifi = MTR_YES_NO(networkFeatures.unsignedLongLongValue & MTRNetworkCommissioningFeatureWiFiNetworkInterface);
449+
thread = MTR_YES_NO(networkFeatures.unsignedLongLongValue & MTRNetworkCommissioningFeatureThreadNetworkInterface);
450450
}
451451

452452
NSString * reportAge;
@@ -2103,7 +2103,7 @@ - (nullable MTRDeviceClusterData *)_clusterDataForPath:(MTRClusterPath *)cluster
21032103

21042104
// Page in the stored value for the data.
21052105
MTRDeviceClusterData * data = [_deviceController.controllerDataStore getStoredClusterDataForNodeID:_nodeID endpointID:clusterPath.endpoint clusterID:clusterPath.cluster];
2106-
MTR_LOG("%@ cluster path %@ cache miss - load from storage success %@", self, clusterPath, YES_NO(data));
2106+
MTR_LOG("%@ cluster path %@ cache miss - load from storage success %@", self, clusterPath, MTR_YES_NO(data));
21072107
if (data != nil) {
21082108
[_persistedClusterData setObject:data forKey:clusterPath];
21092109
} else {

src/darwin/Framework/CHIP/MTRDevice_XPC.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ - (NSString *)description
111111
wifi = @"NO";
112112
thread = @"NO";
113113
} else {
114-
wifi = YES_NO(networkFeatures.unsignedLongLongValue & MTRNetworkCommissioningFeatureWiFiNetworkInterface);
115-
thread = YES_NO(networkFeatures.unsignedLongLongValue & MTRNetworkCommissioningFeatureThreadNetworkInterface);
114+
wifi = MTR_YES_NO(networkFeatures.unsignedLongLongValue & MTRNetworkCommissioningFeatureWiFiNetworkInterface);
115+
thread = MTR_YES_NO(networkFeatures.unsignedLongLongValue & MTRNetworkCommissioningFeatureThreadNetworkInterface);
116116
}
117117

118118
// TODO: Add these to the description

src/darwin/Framework/CHIPTests/MTRPairingTests.m

+20-2
Original file line numberDiff line numberDiff line change
@@ -138,21 +138,35 @@ @interface MTRPairingTestMonitoringControllerDelegate : NSObject <MTRDeviceContr
138138
@property (atomic, readwrite) BOOL commissioningSessionEstablishmentDoneCalled;
139139
@property (atomic, readwrite) BOOL commissioningCompleteCalled;
140140
@property (atomic, readwrite) BOOL readCommissioningInfoCalled;
141+
@property (atomic, readwrite, strong) XCTestExpectation * allCallbacksCalledExpectation;
141142
@end
142143

143144
@implementation MTRPairingTestMonitoringControllerDelegate
144145
- (NSString *)description
145146
{
146-
return [NSString stringWithFormat:@"<MTRPairingTestMonitoringControllerDelegate: %p statusUpdateCalled %@ commissioningSessionEstablishmentDoneCalled %@ commissioningCompleteCalled %@ readCommissioningInfoCalled %@>", self, YES_NO(_statusUpdateCalled), YES_NO(_commissioningSessionEstablishmentDoneCalled), YES_NO(_commissioningCompleteCalled), YES_NO(_readCommissioningInfoCalled)];
147+
return [NSString stringWithFormat:@"<MTRPairingTestMonitoringControllerDelegate: %p statusUpdateCalled %@ commissioningSessionEstablishmentDoneCalled %@ commissioningCompleteCalled %@ readCommissioningInfoCalled %@>", self, MTR_YES_NO(_statusUpdateCalled), MTR_YES_NO(_commissioningSessionEstablishmentDoneCalled), MTR_YES_NO(_commissioningCompleteCalled), MTR_YES_NO(_readCommissioningInfoCalled)];
147148
}
149+
150+
- (void)_checkIfAllCallbacksCalled
151+
{
152+
if (self.allCallbacksCalledExpectation) {
153+
if (self.statusUpdateCalled && self.commissioningSessionEstablishmentDoneCalled && self.commissioningCompleteCalled && self.readCommissioningInfoCalled) {
154+
[self.allCallbacksCalledExpectation fulfill];
155+
self.allCallbacksCalledExpectation = nil;
156+
}
157+
}
158+
}
159+
148160
- (void)controller:(MTRDeviceController *)controller statusUpdate:(MTRCommissioningStatus)status
149161
{
150162
self.statusUpdateCalled = YES;
163+
[self _checkIfAllCallbacksCalled];
151164
}
152165

153166
- (void)controller:(MTRDeviceController *)controller commissioningSessionEstablishmentDone:(NSError * _Nullable)error
154167
{
155168
self.commissioningSessionEstablishmentDoneCalled = YES;
169+
[self _checkIfAllCallbacksCalled];
156170
}
157171

158172
- (void)controller:(MTRDeviceController *)controller
@@ -161,11 +175,13 @@ - (void)controller:(MTRDeviceController *)controller
161175
metrics:(MTRMetrics *)metrics
162176
{
163177
self.commissioningCompleteCalled = YES;
178+
[self _checkIfAllCallbacksCalled];
164179
}
165180

166181
- (void)controller:(MTRDeviceController *)controller readCommissioningInfo:(MTRProductIdentity *)info
167182
{
168183
self.readCommissioningInfoCalled = YES;
184+
[self _checkIfAllCallbacksCalled];
169185
}
170186
@end
171187

@@ -259,6 +275,8 @@ - (void)doPairingTestWithAttestationDelegate:(id<MTRDeviceAttestationDelegate>)a
259275

260276
// Test that a monitoring delegate works
261277
__auto_type * monitoringControllerDelegate = [[MTRPairingTestMonitoringControllerDelegate alloc] init];
278+
XCTestExpectation * allCallbacksCalledExpectation = [self expectationWithDescription:@"All callbacks called on monitoring delegate"];
279+
monitoringControllerDelegate.allCallbacksCalledExpectation = allCallbacksCalledExpectation;
262280
[sController addDeviceControllerDelegate:monitoringControllerDelegate queue:callbackQueue];
263281
XCTAssertEqual([sController unitTestDelegateCount], 2);
264282

@@ -278,7 +296,7 @@ - (void)doPairingTestWithAttestationDelegate:(id<MTRDeviceAttestationDelegate>)a
278296
XCTAssertTrue([sController setupCommissioningSessionWithPayload:payload newNodeID:@(sDeviceId) error:&error]);
279297
XCTAssertNil(error);
280298

281-
[self waitForExpectations:@[ expectation ] timeout:kPairingTimeoutInSeconds];
299+
[self waitForExpectations:@[ expectation, allCallbacksCalledExpectation ] timeout:kPairingTimeoutInSeconds];
282300
XCTAssertNil(controllerDelegate.commissioningCompleteError);
283301

284302
// Test that the monitoring delegate got all the callbacks

0 commit comments

Comments
 (0)