Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0cb134e

Browse files
authoredSep 12, 2024··
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

‎src/protocols/bdx/TransferFacilitator.cpp

+15-24
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ namespace bdx {
3232
constexpr System::Clock::Timeout TransferFacilitator::kDefaultPollFreq;
3333
constexpr System::Clock::Timeout TransferFacilitator::kImmediatePollDelay;
3434

35+
TransferFacilitator::~TransferFacilitator()
36+
{
37+
ResetTransfer();
38+
}
39+
40+
void TransferFacilitator::ResetTransfer()
41+
{
42+
mTransfer.Reset();
43+
ChipLogProgress(BDX, "Stop polling for messages");
44+
45+
VerifyOrReturn(mSystemLayer != nullptr);
46+
mSystemLayer->CancelTimer(PollTimerHandler, this);
47+
}
48+
3549
CHIP_ERROR TransferFacilitator::OnMessageReceived(chip::Messaging::ExchangeContext * ec, const chip::PayloadHeader & payloadHeader,
3650
chip::System::PacketBufferHandle && payload)
3751
{
@@ -78,15 +92,7 @@ void TransferFacilitator::PollForOutput()
7892
HandleTransferSessionOutput(outEvent);
7993

8094
VerifyOrReturn(mSystemLayer != nullptr, ChipLogError(BDX, "%s mSystemLayer is null", __FUNCTION__));
81-
if (!mStopPolling)
82-
{
83-
mSystemLayer->StartTimer(mPollFreq, PollTimerHandler, this);
84-
}
85-
else
86-
{
87-
mSystemLayer->CancelTimer(PollTimerHandler, this);
88-
mStopPolling = false;
89-
}
95+
mSystemLayer->StartTimer(mPollFreq, PollTimerHandler, this);
9096
}
9197

9298
void TransferFacilitator::ScheduleImmediatePoll()
@@ -106,18 +112,10 @@ CHIP_ERROR Responder::PrepareForTransfer(System::Layer * layer, TransferRole rol
106112
ReturnErrorOnFailure(mTransfer.WaitForTransfer(role, xferControlOpts, maxBlockSize, timeout));
107113

108114
ChipLogProgress(BDX, "Start polling for messages");
109-
mStopPolling = false;
110115
mSystemLayer->StartTimer(mPollFreq, PollTimerHandler, this);
111116
return CHIP_NO_ERROR;
112117
}
113118

114-
void Responder::ResetTransfer()
115-
{
116-
mTransfer.Reset();
117-
ChipLogProgress(BDX, "Stop polling for messages");
118-
mStopPolling = true;
119-
}
120-
121119
CHIP_ERROR Initiator::InitiateTransfer(System::Layer * layer, TransferRole role, const TransferSession::TransferInitData & initData,
122120
System::Clock::Timeout timeout, System::Clock::Timeout pollFreq)
123121
{
@@ -132,12 +130,5 @@ CHIP_ERROR Initiator::InitiateTransfer(System::Layer * layer, TransferRole role,
132130
return CHIP_NO_ERROR;
133131
}
134132

135-
void Initiator::ResetTransfer()
136-
{
137-
mTransfer.Reset();
138-
ChipLogProgress(BDX, "Stop polling for messages");
139-
mStopPolling = true;
140-
}
141-
142133
} // namespace bdx
143134
} // namespace chip

‎src/protocols/bdx/TransferFacilitator.h

+6-11
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ class TransferFacilitator : public Messaging::ExchangeDelegate, public Messaging
4545
{
4646
public:
4747
TransferFacilitator() : mExchangeCtx(nullptr), mSystemLayer(nullptr), mPollFreq(kDefaultPollFreq) {}
48-
~TransferFacilitator() override = default;
48+
~TransferFacilitator() override;
49+
50+
/**
51+
* Calls reset on the TransferSession object and stops the poll timer.
52+
*/
53+
void ResetTransfer();
4954

5055
private:
5156
//// UnsolicitedMessageHandler Implementation ////
@@ -96,7 +101,6 @@ class TransferFacilitator : public Messaging::ExchangeDelegate, public Messaging
96101
System::Clock::Timeout mPollFreq;
97102
static constexpr System::Clock::Timeout kDefaultPollFreq = System::Clock::Milliseconds32(500);
98103
static constexpr System::Clock::Timeout kImmediatePollDelay = System::Clock::Milliseconds32(1);
99-
bool mStopPolling = false;
100104
};
101105

102106
/**
@@ -121,11 +125,6 @@ class Responder : public TransferFacilitator
121125
CHIP_ERROR PrepareForTransfer(System::Layer * layer, TransferRole role, BitFlags<TransferControlFlags> xferControlOpts,
122126
uint16_t maxBlockSize, System::Clock::Timeout timeout,
123127
System::Clock::Timeout pollFreq = TransferFacilitator::kDefaultPollFreq);
124-
125-
/**
126-
* Calls reset on the TransferSession object and stops the poll timer.
127-
*/
128-
void ResetTransfer();
129128
};
130129

131130
/**
@@ -150,10 +149,6 @@ class Initiator : public TransferFacilitator
150149
CHIP_ERROR InitiateTransfer(System::Layer * layer, TransferRole role, const TransferSession::TransferInitData & initData,
151150
System::Clock::Timeout timeout,
152151
System::Clock::Timeout pollFreq = TransferFacilitator::kDefaultPollFreq);
153-
/**
154-
* Calls reset on the TransferSession object and stops the poll timer.
155-
*/
156-
void ResetTransfer();
157152
};
158153

159154
} // namespace bdx

‎src/python_testing/TC_MCORE_FS_1_4.py

+17-33
Original file line numberDiff line numberDiff line change
@@ -47,32 +47,6 @@
4747
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, type_matches
4848
from mobly import asserts
4949

50-
51-
async def wait_for_server_initialization(server_port, timeout=5):
52-
"""Wait until the server is ready by checking if it opens the expected port."""
53-
start_time = asyncio.get_event_loop().time()
54-
elapsed_time = 0
55-
retry_interval = 1
56-
57-
logging.info(f"Waiting for server to initialize on TCP port {server_port} for up to {timeout} seconds.")
58-
59-
while elapsed_time < timeout:
60-
try:
61-
# Try connecting to the server to check if it's ready
62-
reader, writer = await asyncio.open_connection('::1', server_port)
63-
writer.close()
64-
await writer.wait_closed()
65-
logging.info(f"TH_SERVER_NO_UID is initialized and ready on port {server_port}.")
66-
return
67-
except (ConnectionRefusedError, OSError) as e:
68-
logging.warning(f"Connection to port {server_port} failed: {e}. Retrying in {retry_interval} seconds...")
69-
70-
await asyncio.sleep(retry_interval)
71-
elapsed_time = asyncio.get_event_loop().time() - start_time
72-
73-
raise TimeoutError(f"Server on port {server_port} did not initialize within {timeout} seconds. "
74-
f"Total time waited: {elapsed_time} seconds.")
75-
7650
# TODO: Make this class more generic. Issue #35348
7751

7852

@@ -174,16 +148,32 @@ def stop(self):
174148

175149
class AppServer:
176150

151+
def _process_admin_output(self, line):
152+
if self.wait_for_text_text is not None and self.wait_for_text_text in line:
153+
self.wait_for_text_event.set()
154+
155+
def wait_for_text(self, timeout=30):
156+
if not self.wait_for_text_event.wait(timeout=timeout):
157+
raise Exception(f"Timeout waiting for text: {self.wait_for_text_text}")
158+
self.wait_for_text_event.clear()
159+
self.wait_for_text_text = None
160+
177161
def __init__(self, app, storage_dir, port=None, discriminator=None, passcode=None):
162+
self.wait_for_text_event = threading.Event()
163+
self.wait_for_text_text = None
178164

179165
args = [app]
180166
args.extend(["--KVS", tempfile.mkstemp(dir=storage_dir, prefix="kvs-app-")[1]])
181167
args.extend(['--secured-device-port', str(port)])
182168
args.extend(["--discriminator", str(discriminator)])
183169
args.extend(["--passcode", str(passcode)])
184-
self.app = Subprocess(args, tag="SERVER")
170+
self.app = Subprocess(args, stdout_cb=self._process_admin_output, tag="SERVER")
171+
self.wait_for_text_text = "Server initialization complete"
185172
self.app.start()
186173

174+
# Wait for the server-app to be ready.
175+
self.wait_for_text()
176+
187177
def stop(self):
188178
self.app.stop()
189179

@@ -265,12 +255,6 @@ def setup_class(self):
265255
discriminator=self.th_server_discriminator,
266256
passcode=self.th_server_passcode)
267257

268-
# Wait for TH_SERVER_NO_UID get initialized.
269-
try:
270-
asyncio.run(wait_for_server_initialization(self.th_server_port))
271-
except TimeoutError:
272-
asserts.fail(f"TH_SERVER_NO_UID server failed to open port {self.th_server_port}")
273-
274258
def teardown_class(self):
275259
if self.th_fsa_controller is not None:
276260
self.th_fsa_controller.stop()

‎third_party/openthread/repo

Submodule repo updated 67 files

0 commit comments

Comments
 (0)
Please sign in to comment.