Skip to content

Commit 4618c3c

Browse files
Merge branch 'master' into idm-4.2-troubleshoot
2 parents edb9c5f + 35eba86 commit 4618c3c

17 files changed

+227
-60
lines changed

.github/workflows/examples-linux-tv-casting-app.yaml

+11-1
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,22 @@ jobs:
6363
./scripts/run_in_build_env.sh \
6464
"scripts/examples/gn_build_example.sh examples/tv-casting-app/linux/ out/tv-casting-app chip_casting_simplified=true"
6565
66-
- name: Test casting from Linux tv-casting-app to Linux tv-app
66+
- name:
67+
Test casting from Linux tv-casting-app to Linux tv-app -
68+
Commissionee Generated Passcode
6769
run: |
6870
./scripts/run_in_build_env.sh \
6971
"python3 ./scripts/tests/run_tv_casting_test.py"
7072
timeout-minutes: 2 # Comment this out to debug if GitHub Action times out.
7173

74+
- name:
75+
Test casting from Linux tv-casting-app to Linux tv-app -
76+
Commissioner Generated Passcode
77+
run: |
78+
./scripts/run_in_build_env.sh \
79+
"python3 ./scripts/tests/run_tv_casting_test.py --commissioner-generated-passcode=True"
80+
timeout-minutes: 2 # Comment this out to debug if GitHub Action times out.
81+
7282
- name: Uploading Size Reports
7383
uses: ./.github/actions/upload-size-reports
7484
if: ${{ !env.ACT }}

scripts/tests/linux/tv_casting_test_sequences.py

+113-5
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,13 @@
6767

6868
# Values that identify the Linux tv-app and are noted in the 'Device Configuration' in the Linux tv-app output
6969
# as well as under the 'Discovered Commissioner' details in the Linux tv-casting-app output.
70-
VENDOR_ID = 0xFFF1 # Spec 7.20.2.1 MEI code: test vendor IDs are 0xFFF1 to 0xFFF4
71-
PRODUCT_ID = 0x8001 # Test product id
72-
DEVICE_TYPE_CASTING_VIDEO_PLAYER = 0x23 # Device type library 10.3: Casting Video Player
70+
VENDOR_ID = 0xFFF1 # 0xFFF1 = 65521; Spec 7.20.2.1 MEI code: test vendor IDs are 0xFFF1 to 0xFFF4
71+
PRODUCT_ID = 0x8001 # 0x8001 = 32769 = Test product id
72+
DEVICE_TYPE_CASTING_VIDEO_PLAYER = 0x23 # 0x23 = 35 = Device type library 10.3: Casting Video Player
73+
74+
# 0x457 = 1111 = Target Content Application Vendor ID for the commissioner generated passcode flow
75+
COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID = 0x457
76+
COMMISSIONER_GENERATED_PASSCODE = '0x00BC_614E' # 0x00BC_614E = 12345678 = Default commissioner generated passcode
7377

7478
# Value to verify the subscription state against in the Linux tv-casting-app output.
7579
ATTRIBUTE_CURRENT_PLAYBACK_STATE = 0x0000_0000 # Application Cluster Spec 6.10.6 Attribute ID: Current State of Playback
@@ -94,7 +98,7 @@
9498
Step(app=App.TV_CASTING_APP, output_msg=['Discovered CastingPlayer #0', f'Product ID: {PRODUCT_ID}', f'Vendor ID: {VENDOR_ID}',
9599
f'Device Type: {DEVICE_TYPE_CASTING_VIDEO_PLAYER}', 'Supports Commissioner Generated Passcode: true']),
96100

97-
# Send `cast request {valid_discovered_commissioner_number}\n` command to the tv-casting-app subprocess.
101+
# Send `cast request {valid_discovered_castingplayer_number}\n` command to the tv-casting-app subprocess.
98102
Step(app=App.TV_CASTING_APP, input_cmd='cast request 0\n'),
99103

100104
# Validate that the tv-casting-app begins the commissioning process.
@@ -112,7 +116,7 @@
112116
# Validate that we received the instructions on the tv-app output for sending the `controller ux ok` command.
113117
Step(app=App.TV_APP, output_msg=['Via Shell Enter: controller ux ok|cancel']),
114118

115-
# Send `controller ux ok` command to the tv-app subprocess.
119+
# Send `controller ux ok\n` command to the tv-app subprocess.
116120
Step(app=App.TV_APP, input_cmd='controller ux ok\n'),
117121

118122
# Validate that pairing succeeded between the tv-casting-app and the tv-app.
@@ -140,6 +144,110 @@
140144
# Signal to stop the tv-casting-app as we finished validation.
141145
Step(app=App.TV_CASTING_APP, input_cmd=STOP_APP),
142146

147+
# Signal to stop the tv-app as we finished validation.
148+
Step(app=App.TV_APP, input_cmd=STOP_APP)
149+
]
150+
),
151+
Sequence(
152+
name='commissioner_generated_passcode_test',
153+
steps=[
154+
# Signal to start the tv-app.
155+
Step(app=App.TV_APP, input_cmd=START_APP),
156+
157+
# Validate that the tv-app is up and running.
158+
Step(app=App.TV_APP, timeout_sec=APP_MAX_START_WAIT_SEC, output_msg=['Started commissioner']),
159+
160+
# Signal to start the tv-casting-app.
161+
Step(app=App.TV_CASTING_APP, input_cmd=START_APP),
162+
163+
# Validate that the server is properly initialized in the tv-casting-app output.
164+
Step(app=App.TV_CASTING_APP, timeout_sec=APP_MAX_START_WAIT_SEC, output_msg=['Server initialization complete']),
165+
166+
# Validate that there is a valid discovered casting player with {PRODUCT_ID}, {VENDOR_ID}, {DEVICE_TYPE_CASTING_VIDEO_PLAYER}, and the
167+
# `Commissioner Generated Passcode` flag is set to true in the tv-casting-app output.
168+
Step(app=App.TV_CASTING_APP, output_msg=['Discovered CastingPlayer #0', f'Product ID: {PRODUCT_ID}', f'Vendor ID: {VENDOR_ID}',
169+
f'Device Type: {DEVICE_TYPE_CASTING_VIDEO_PLAYER}', 'Supports Commissioner Generated Passcode: true']),
170+
171+
# Send `cast request {valid_discovered_castingplayer_number} commissioner-generated-passcode\n` command to the tv-casting-app subprocess.
172+
Step(app=App.TV_CASTING_APP, input_cmd='cast request 0 commissioner-generated-passcode\n'),
173+
174+
# Validate that the tv-casting-app begins the commissioning process.
175+
Step(app=App.TV_CASTING_APP, output_msg=[
176+
'CastingPlayer::VerifyOrEstablishConnection() calling OpenBasicCommissioningWindow()']),
177+
178+
# Validate that the `IdentificationDeclaration` message sent from the tv-casting-app to the tv-app will contain the following entries:
179+
# mCommissionerPasscode: true -> This flag instructs the commissioner to use the commissioner-generated-passcode flow for commissioning.
180+
# mCommissionerPasscodeReady: false -> This flag indicates that the commissionee has not obtained the commissioner passcode from the user and
181+
# thus is not ready for commissioning.
182+
# Vendor ID: {COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID} -> The initial VENDOR_ID of the casting player will be overridden to {COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID}.
183+
# Otherwise we will enter the commissionee-generated-passcode flow.
184+
Step(app=App.TV_CASTING_APP, output_msg=['IdentificationDeclarationOptions::LogDetail()', 'IdentificationDeclarationOptions::mCommissionerPasscode: true',
185+
'IdentificationDeclarationOptions::mCommissionerPasscodeReady: false', 'IdentificationDeclarationOptions::TargetAppInfos list:', f'TargetAppInfo 1, Vendor ID: {COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID}']),
186+
187+
# Validate that we received the cast request from the tv-casting-app on the tv-app output.
188+
Step(app=App.TV_APP,
189+
output_msg=['------PROMPT USER: Test TV casting app is requesting permission to cast to this TV, approve?']),
190+
191+
# Validate that we received the instructions on the tv-app output for sending the `controller ux ok` command.
192+
Step(app=App.TV_APP, output_msg=['Via Shell Enter: controller ux ok|cancel']),
193+
194+
# Send `controller ux ok` command to the tv-app subprocess.
195+
Step(app=App.TV_APP, input_cmd='controller ux ok\n'),
196+
197+
# Validate that the tv-app sent a message to the tv-casting-app indicating that the tv-app is now displaying the passcode to the user.
198+
Step(app=App.TV_APP, output_msg=['Commissioner Declaration Start',
199+
'commissioner passcode: true', 'Commissioner Declaration End']),
200+
201+
# Validate that we received the cast request with the casting passcode on the tv-app output.
202+
Step(app=App.TV_APP, output_msg=[
203+
f'------PROMPT USER: Test TV casting app is requesting permission to cast to this TV. Casting passcode: [{COMMISSIONER_GENERATED_PASSCODE}].']),
204+
205+
# Validate that the tv-casting-app received the message from the tv-app indicating that the tv-app is now displaying the passcode to the user.
206+
Step(app=App.TV_CASTING_APP, output_msg=['Commissioner Declaration Start',
207+
'commissioner passcode: true', 'Commissioner Declaration End']),
208+
209+
# Validate that the user is prompted to input passcode from the tv-app on the tv-casting-app output.
210+
Step(app=App.TV_CASTING_APP, output_msg=['Awaiting user input', 'Input the Commissioner-Generated passcode displayed on the CastingPlayer UX.',
211+
f'cast setcommissionerpasscode {int(COMMISSIONER_GENERATED_PASSCODE, 16)}', 'Awaiting user input']),
212+
213+
# Send `cast setcommissionerpasscode {COMMISSIONER_GENERATED_PASSCODE}\n` to the tv-casting-app subprocess.
214+
Step(app=App.TV_CASTING_APP, input_cmd=f'cast setcommissionerpasscode {int(COMMISSIONER_GENERATED_PASSCODE, 16)}\n'),
215+
216+
# Validate the commissioner passcode that the user entered on the tv-casting-app output.
217+
Step(app=App.TV_CASTING_APP, output_msg=[
218+
f'CommandHandler() setcommissionerpasscode user-entered passcode: {int(COMMISSIONER_GENERATED_PASSCODE, 16)}']),
219+
220+
# Validate that the `IdentificationDeclaration` message sent from the tv-casting-app to the tv-app will contain the following entries:
221+
# mCommissionerPasscode: true -> This flag instructs the commissioner to use the commissioner-generated-passcode flow for commissioning.
222+
# mCommissionerPasscodeReady: true -> This flag indicates that the commissionee has obtained the commissioner passcode from the user and
223+
# thus is ready for commissioning.
224+
# Vendor ID: {COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID} -> The initial VENDOR_ID of the casting player will be overridden to {COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID}.
225+
# Otherwise we will enter the commissionee-generated-passcode flow.
226+
Step(app=App.TV_CASTING_APP, output_msg=['IdentificationDeclarationOptions::LogDetail()', 'IdentificationDeclarationOptions::mCommissionerPasscode: true',
227+
'IdentificationDeclarationOptions::mCommissionerPasscodeReady: true', 'IdentificationDeclarationOptions::TargetAppInfos list:', f'TargetAppInfo 1, Vendor ID: {COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID}']),
228+
229+
# Validate that pairing succeeded between the tv-casting-app and the tv-app.
230+
Step(app=App.TV_APP, output_msg=['Secure Pairing Success']),
231+
232+
# Validate that the connection succeeded in the tv-casting-app output.
233+
Step(app=App.TV_CASTING_APP, output_msg=['Successfully connected to CastingPlayer']),
234+
235+
# Validate that commissioning succeeded in the tv-app output.
236+
Step(app=App.TV_APP, output_msg=['------PROMPT USER: commissioning success']),
237+
238+
# Validate that we are able to subscribe to the media playback cluster by reading the CurrentState value and that it matches {ATTRIBUTE_CURRENT_PLAYBACK_STATE}.
239+
Step(app=App.TV_CASTING_APP, output_msg=[f'Read CurrentState value: {ATTRIBUTE_CURRENT_PLAYBACK_STATE}']),
240+
241+
# Validate the LaunchURL in the tv-app output.
242+
Step(app=App.TV_APP,
243+
output_msg=['ContentLauncherManager::HandleLaunchUrl TEST CASE ContentURL=https://www.test.com/videoid DisplayString=Test video']),
244+
245+
# Validate the LaunchURL in the tv-casting-app output.
246+
Step(app=App.TV_CASTING_APP, output_msg=['LaunchURL Success with response.data: exampleData']),
247+
248+
# Signal to stop the tv-casting-app as we finished validation.
249+
Step(app=App.TV_CASTING_APP, input_cmd=STOP_APP),
250+
143251
# Signal to stop the tv-app as we finished validation.
144252
Step(app=App.TV_APP, input_cmd=STOP_APP)
145253
]

scripts/tests/run_tv_casting_test.py

+23-7
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,26 @@ def run_test_sequence_steps(
270270
@click.command()
271271
@click.option('--tv-app-rel-path', type=str, default='out/tv-app/chip-tv-app', help='Path to the Linux tv-app executable.')
272272
@click.option('--tv-casting-app-rel-path', type=str, default='out/tv-casting-app/chip-tv-casting-app', help='Path to the Linux tv-casting-app executable.')
273-
def test_casting_fn(tv_app_rel_path, tv_casting_app_rel_path):
273+
@click.option('--commissioner-generated-passcode', type=bool, default=False, help='Enable the commissioner generated passcode test flow.')
274+
def test_casting_fn(tv_app_rel_path, tv_casting_app_rel_path, commissioner_generated_passcode):
274275
"""Test if the casting experience between the Linux tv-casting-app and the Linux tv-app continues to work.
275276
276-
Default paths for the executables are provided but can be overridden via command line arguments.
277-
For example: python3 run_tv_casting_test.py --tv-app-rel-path=path/to/tv-app
278-
--tv-casting-app-rel-path=path/to/tv-casting-app
277+
By default, it uses the provided executable paths and the commissionee generated passcode flow as the test sequence.
278+
279+
Example usages:
280+
1. Use default paths and test sequence:
281+
python3 run_tv_casting_test.py
282+
283+
2. Use custom executable paths and default test sequence:
284+
python3 run_tv_casting_test.py --tv-app-rel-path=path/to/tv-app --tv-casting-app-rel-path=path/to/tv-casting-app
285+
286+
3. Use default paths and a test sequence that is not the default test sequence (replace `test-sequence-name` with the actual name of the test sequence):
287+
python3 run_tv_casting_test.py --test-sequence-name=True
288+
289+
4. Use custom executable paths and a test sequence that is not the default test sequence (replace `test-sequence-name` with the actual name of the test sequence):
290+
python3 run_tv_casting_test.py --tv-app-rel-path=path/to/tv-app --tv-casting-app-rel-path=path/to/tv-casting-app --test-sequence-name=True
291+
292+
Note: In order to enable a new test sequence, we also need to define a @click.option() entry for the test sequence.
279293
"""
280294

281295
# Store the log files to a temporary directory.
@@ -288,15 +302,17 @@ def test_casting_fn(tv_app_rel_path, tv_casting_app_rel_path):
288302
# Get all the test sequences.
289303
test_sequences = Sequence.get_test_sequences()
290304

291-
# Get the test sequence of interest.
292-
test_sequence = Sequence.get_test_sequence_by_name(test_sequences, 'commissionee_generated_passcode_test')
305+
# Get the test sequence that we are interested in validating.
306+
test_sequence_name = 'commissionee_generated_passcode_test'
307+
if commissioner_generated_passcode:
308+
test_sequence_name = 'commissioner_generated_passcode_test'
309+
test_sequence = Sequence.get_test_sequence_by_name(test_sequences, test_sequence_name)
293310

294311
if not test_sequence:
295312
logging.error('No test sequence found by the test sequence name provided.')
296313
handle_casting_failure(None, [])
297314

298315
# At this point, we have retrieved the test sequence of interest.
299-
test_sequence_name = test_sequence.name
300316
test_sequence_steps = test_sequence.steps
301317

302318
# Configure command options to disable stdout buffering during tests.

src/app/AttributeAccessInterfaceCache.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class AttributeAccessInterfaceCache
4848
kDefinitelyUsed
4949
};
5050

51-
AttributeAccessInterfaceCache() { Invalidate(); }
51+
constexpr AttributeAccessInterfaceCache() = default;
5252

5353
/**
5454
* @brief Invalidate the whole cache. Must be called every time list of AAI registrations changes.
@@ -106,6 +106,8 @@ class AttributeAccessInterfaceCache
106106
private:
107107
struct AttributeAccessCacheEntry
108108
{
109+
constexpr AttributeAccessCacheEntry() = default;
110+
109111
EndpointId endpointId = kInvalidEndpointId;
110112
ClusterId clusterId = kInvalidClusterId;
111113
AttributeAccessInterface * accessor = nullptr;
@@ -137,8 +139,8 @@ class AttributeAccessInterfaceCache
137139
return &mCacheSlots[0];
138140
}
139141

140-
AttributeAccessCacheEntry mCacheSlots[1];
141-
AttributeAccessCacheEntry mLastUnusedEntry;
142+
AttributeAccessCacheEntry mCacheSlots[1] = {};
143+
AttributeAccessCacheEntry mLastUnusedEntry{};
142144
};
143145

144146
} // namespace app

src/app/EventLoggingTypes.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct Timestamp
100100
kSystem = 0,
101101
kEpoch
102102
};
103-
Timestamp() {}
103+
constexpr Timestamp() = default;
104104
Timestamp(Type aType, uint64_t aValue) : mType(aType), mValue(aValue) {}
105105
Timestamp(System::Clock::Timestamp aValue) : mType(Type::kSystem), mValue(aValue.count()) {}
106106
static Timestamp Epoch(System::Clock::Timestamp aValue)

src/app/EventManagement.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ using namespace chip::TLV;
3232

3333
namespace chip {
3434
namespace app {
35-
static EventManagement sInstance;
35+
EventManagement EventManagement::sInstance;
3636

3737
/**
3838
* @brief

src/app/EventManagement.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace app {
7373
inline constexpr const uint32_t kEventManagementProfile = 0x1;
7474
inline constexpr const uint32_t kFabricIndexTag = 0x1;
7575
inline constexpr size_t kMaxEventSizeReserve = 512;
76-
constexpr uint16_t kRequiredEventField =
76+
inline constexpr uint16_t kRequiredEventField =
7777
(1 << to_underlying(EventDataIB::Tag::kPriority)) | (1 << to_underlying(EventDataIB::Tag::kPath));
7878

7979
/**
@@ -388,6 +388,9 @@ class EventManagement
388388
void SetScheduledEventInfo(EventNumber & aEventNumber, uint32_t & aInitialWrittenEventBytes) const;
389389

390390
private:
391+
constexpr EventManagement() = default;
392+
static EventManagement sInstance;
393+
391394
/**
392395
* @brief
393396
* Internal structure for traversing events.
@@ -555,9 +558,9 @@ class EventManagement
555558
MonotonicallyIncreasingCounter<EventNumber> * mpEventNumberCounter = nullptr;
556559

557560
EventNumber mLastEventNumber = 0; ///< Last event Number vended
558-
Timestamp mLastEventTimestamp; ///< The timestamp of the last event in this buffer
561+
Timestamp mLastEventTimestamp{}; ///< The timestamp of the last event in this buffer
559562

560-
System::Clock::Milliseconds64 mMonotonicStartupTime;
563+
System::Clock::Milliseconds64 mMonotonicStartupTime{};
561564
};
562565
} // namespace app
563566
} // namespace chip

src/app/clusters/descriptor/descriptor.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <app/AttributeAccessInterfaceRegistry.h>
2828
#include <app/util/attribute-storage.h>
2929
#include <app/util/endpoint-config-api.h>
30+
#include <lib/core/Global.h>
3031
#include <lib/support/CodeUtils.h>
3132
#include <lib/support/logging/CHIPLogging.h>
3233

@@ -205,7 +206,9 @@ CHIP_ERROR DescriptorAttrAccess::ReadClusterRevision(EndpointId endpoint, Attrib
205206
return aEncoder.Encode(kClusterRevision);
206207
}
207208

208-
DescriptorAttrAccess gAttrAccess;
209+
namespace {
210+
Global<DescriptorAttrAccess> gAttrAccess;
211+
}
209212

210213
CHIP_ERROR DescriptorAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder)
211214
{
@@ -244,5 +247,5 @@ CHIP_ERROR DescriptorAttrAccess::Read(const ConcreteReadAttributePath & aPath, A
244247

245248
void MatterDescriptorPluginServerInitCallback()
246249
{
247-
registerAttributeAccessOverride(&gAttrAccess);
250+
registerAttributeAccessOverride(&gAttrAccess.get());
248251
}

src/darwin/Framework/Matter.xcodeproj/project.pbxproj

+2
Original file line numberDiff line numberDiff line change
@@ -2497,6 +2497,7 @@
24972497
"-Wl,-unexported_symbol,\"__Unwind_*\"",
24982498
"-Wl,-unexported_symbol,\"_unw_*\"",
24992499
"-Wl,-hidden-lCHIP",
2500+
"-Wl,-no_inits",
25002501
);
25012502
"OTHER_LDFLAGS[sdk=macosx*]" = (
25022503
"-framework",
@@ -2515,6 +2516,7 @@
25152516
"-Wl,-unexported_symbol,\"__Unwind_*\"",
25162517
"-Wl,-unexported_symbol,\"_unw_*\"",
25172518
"-Wl,-hidden-lCHIP",
2519+
"-Wl,-no_inits",
25182520
);
25192521
PRODUCT_BUNDLE_IDENTIFIER = com.csa.matter;
25202522
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";

0 commit comments

Comments
 (0)