Skip to content

Commit 73ab16b

Browse files
authored
Merge branch 'master' into camera-push
2 parents be43b7e + a4f6ca8 commit 73ab16b

27 files changed

+493
-101
lines changed

examples/platform/silabs/SoftwareFaultReports.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include "SoftwareFaultReports.h"
20+
#include "FreeRTOSConfig.h"
2021
#include "silabs_utils.h"
2122
#include <app/clusters/software-diagnostics-server/software-diagnostics-server.h>
2223
#include <app/util/attribute-storage.h>

examples/thermostat/silabs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ If the LCD is enabled, the LCD on the Silabs WSTK shows a QR Code containing the
4747
needed commissioning information for the BLE connection and starting the
4848
Rendez-vous procedure.
4949

50-
The light switch example is intended to serve both as a means to explore the
50+
The thermostat example is intended to serve both as a means to explore the
5151
workings of Matter as well as a template for creating real products based on the
5252
Silicon Labs platform.
5353

examples/tv-casting-app/APIs.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,21 @@ In order to illustrate these steps, refer to the figure below
7171
The Casting Client is expected to consume the Matter TV Casting library built
7272
for its respective platform which implements the APIs described in this
7373
document. Refer to the tv-casting-app READMEs for [Linux](linux/README.md),
74-
Android and [iOS](darwin/TvCasting/README.md) to understand how to build and
75-
consume each platform's specific libraries. The libraries MUST be built with the
74+
[Android](https://github.com/project-chip/connectedhomeip/blob/master/examples/tv-casting-app/android/README.md)
75+
and [iOS](darwin/TvCasting/README.md) to understand how to build and consume
76+
each platform's specific libraries. The libraries MUST be built with the
7677
client's specific values for `CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID` and
7778
`CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID` updated in the
7879
[CHIPProjectAppConfig.h](tv-casting-common/include/CHIPProjectAppConfig.h) file.
7980
Other values like the `CHIP_DEVICE_CONFIG_DEVICE_NAME` may be updated as well to
8081
correspond to the client being built.
8182

83+
`CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID` and `CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID`
84+
can be obtained during the CSA certification of your mobile app. The Matter SDK
85+
has pre-configured sample/test values for them in the
86+
[CHIPDeviceConfig.h](https://github.com/project-chip/connectedhomeip/blob/master/src/include/platform/CHIPDeviceConfig.h)
87+
file.
88+
8289
### Initialize the Casting Client
8390

8491
_{Complete Initialization examples: [Linux](linux/simple-app.cpp) |

examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public void handle(CommissionerDeclaration cd) {
211211

212212
FragmentActivity activity = getActivity();
213213
// Prevent possible NullPointerException. This callback could be called when
214-
// this Fragment is not attached to its host activity or when the fragment's
214+
// this fragment is not attached to its host activity or when the fragment's
215215
// lifecycle is not in a valid state for interacting with the activity.
216216
if (activity != null && !activity.isFinishing()) {
217217
activity.runOnUiThread(

examples/tv-casting-app/android/README.md

+42-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ commissioning mode, advertises itself as a Commissionable Node and gets
77
commissioned. Then it allows the user to send Matter ContentLauncher commands to
88
the TV.
99

10+
Refer to the
11+
[Matter Casting APIs documentation](https://project-chip.github.io/connectedhomeip-doc/examples/tv-casting-app/APIs.html)
12+
to build the Matter “Casting Client” into your consumer-facing mobile app.
13+
1014
<hr>
1115

1216
- [Matter TV Casting Android App Example](#matter-tv-casting-android-app-example)
@@ -15,6 +19,8 @@ the TV.
1519
- [Gradle \& JDK Version](#gradle--jdk-version)
1620
- [Preparing for build](#preparing-for-build)
1721
- [Building \& Installing the app](#building--installing-the-app)
22+
- [Common build environment issues](#common-build-environment-issues)
23+
- [Running the app](#running-the-app)
1824

1925
<hr>
2026

@@ -50,10 +56,24 @@ We are using Gradle 7.1.1 for all android project which does not support Java 17
5056
(https://docs.gradle.org/current/userguide/compatibility.html) while the default
5157
JDK version on MacOS for Apple Silicon is 'openjdk 17.0.1' or above.
5258

53-
Using JDK bundled with Android Studio will help with that.
59+
If you attempt to build with an incompatible Java version, you may encounter the
60+
following error:
61+
62+
```text
63+
Unsupported class file major version XX
64+
```
65+
66+
This error occurs when the Java version being used is not compatible with the
67+
Gradle version in your project.
68+
69+
See the
70+
[Building Android](../../../docs/platforms/android/android_building.md#gradle--jdk-version)
71+
guide for more info about the supported Gradle & JDK Version.
72+
73+
You can verify your current Java version by running:
5474

5575
```shell
56-
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home/
76+
java -version
5777
```
5878

5979
<hr>
@@ -107,3 +127,23 @@ adb install out/android-$TARGET_CPU-tv-casting-app/outputs/apk/debug/app-debug.a
107127
You can use Android Studio to edit the Android app itself and run it after
108128
build_examples.py, but you will not be able to edit Matter Android code from
109129
`src/controller/java`, or other Matter C++ code within Android Studio.
130+
131+
## Common build environment issues
132+
133+
1. If you see an error like `kotlinc: command not found`, install the Kotlin in
134+
your build environment. Eg. on MacOS, this can be done with the command:
135+
136+
```shell
137+
brew install kotlin
138+
```
139+
140+
## Running the app
141+
142+
This example Matter TV Casting Android app can be tested with the following
143+
video players:
144+
145+
1. With the
146+
[example Matter tv-app](https://github.com/project-chip/connectedhomeip/tree/master/examples/tv-app)
147+
running on a Raspberry Pi - works out of the box.
148+
2. With a FireTV device - requires your Amazon Customer ID to be allow-listed
149+
first.

examples/tv-casting-app/darwin/TvCasting/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ commissioning mode, advertises itself as a Commissionable Node and gets
77
commissioned. Then it allows the user to send Matter ContentLauncher commands to
88
the TV.
99

10+
Refer to the
11+
[Matter Casting APIs documentation](https://project-chip.github.io/connectedhomeip-doc/examples/tv-casting-app/APIs.html)
12+
to build the Matter “Casting Client” into your consumer-facing mobile app.
13+
1014
---
1115

1216
- [Matter TV Casting iOS App Example](#matter-tv-casting-ios-app-example)
1317
- [Building the Application](#building-the-application)
1418
- [Building through command line](#building-through-command-line)
1519
- [Compilation Fixes](#compilation-fixes)
1620
- [Installing the Application](#installing-the-application)
21+
- [Debugging](#debugging)
22+
- [Running the Application](#running-the-application)
1723

1824
---
1925

@@ -98,3 +104,14 @@ the run button once more.
98104

99105
Use the "TvCasting" scheme when building to enable debugging. If you wish to
100106
build the app without any debugging symbols, use the "TvCasting Release" scheme.
107+
108+
## Running the Application
109+
110+
This example Matter TV Casting iOS application can be tested with the following
111+
video players:
112+
113+
1. With the
114+
[example Matter tv-app](https://github.com/project-chip/connectedhomeip/tree/master/examples/tv-app)
115+
running on a Raspberry Pi - works out of the box.
116+
2. With a FireTV device - requires your Amazon Customer ID to be allow-listed
117+
first.

examples/tv-casting-app/linux/README.md

+16-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ select one, sends the TV a User Directed Commissioning request, enters
66
commissioning mode, advertises itself as a Commissionable Node and gets
77
commissioned. Then it allows the user to send CHIP commands to the TV.
88

9+
Refer to the
10+
[Matter Casting APIs documentation](https://project-chip.github.io/connectedhomeip-doc/examples/tv-casting-app/APIs.html)
11+
to build the Matter “Casting Client” into your consumer-facing mobile app.
12+
913
<hr>
1014

1115
- [CHIP TV Casting App Example](#chip-tv-casting-app-example)
@@ -63,10 +67,15 @@ commissioned. Then it allows the user to send CHIP commands to the TV.
6367

6468
### Commissioning the tv-casting-app
6569

66-
The tv-casting-app will automatically discover video players and print these out
67-
upon startup. The user-directed-commissioning (UDC) process can be initiated
68-
using the shell by specifying the index of the discovered video player in the
69-
printed list.
70+
This example Matter TV Casting iOS application can be tested with the following
71+
video players:
72+
73+
1. With the
74+
[example Matter tv-app](https://github.com/project-chip/connectedhomeip/tree/master/examples/tv-app)
75+
running on a Raspberry Pi - works out of the box. The tv-casting-app will
76+
automatically discover video players and print these out upon startup. The
77+
user-directed-commissioning (UDC) process can be initiated using the shell by
78+
specifying the index of the discovered video player in the printed list.
7079

7180
- Initiate UDC for the discovered video player with index 0
7281

@@ -81,6 +90,9 @@ printed list.
8190

8291
tv-casting-app> cast discover
8392

93+
2. With a FireTV device - requires your Amazon Customer ID to be allow-listed
94+
first.
95+
8496
### Re-Running the Example on Linux with Cached Fabrics
8597

8698
After successfully commissioning the tv-casting-app onto a fabric the app can be

examples/tv-casting-app/linux/simple-app-helper.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,15 @@ void ConnectionHandler(CHIP_ERROR err, matter::casting::core::CastingPlayer * ca
318318
castingPlayer->GetId(), endpoints[index]->GetId());
319319

320320
// demonstrate invoking a command
321+
ChipLogProgress(AppServer, "simple-app-helper.cpp::ConnectionHandler() calling InvokeContentLauncherLaunchURL()");
321322
InvokeContentLauncherLaunchURL(endpoints[index]);
322323

323324
// demonstrate reading an attribute
325+
ChipLogProgress(AppServer, "simple-app-helper.cpp::ConnectionHandler() calling ReadApplicationBasicVendorID()");
324326
ReadApplicationBasicVendorID(endpoints[index]);
325327

326328
// demonstrate subscribing to an attribute
329+
ChipLogProgress(AppServer, "simple-app-helper.cpp::ConnectionHandler() calling SubscribeToMediaPlaybackCurrentState()");
327330
SubscribeToMediaPlaybackCurrentState(endpoints[index]);
328331
}
329332
else

examples/tv-casting-app/tv-casting-common/support/ChipDeviceEventHandler.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ void ChipDeviceEventHandler::Handle(const chip::DeviceLayer::ChipDeviceEvent * e
4444
if (event->Type == chip::DeviceLayer::DeviceEventType::kFailSafeTimerExpired &&
4545
CastingPlayer::GetTargetCastingPlayer()->mConnectionState == CASTING_PLAYER_CONNECTING)
4646
{
47+
ChipLogProgress(AppServer, "ChipDeviceEventHandler::Handle() event kFailSafeTimerExpired");
4748
HandleFailSafeTimerExpired();
4849
}
4950
else if (event->Type == chip::DeviceLayer::DeviceEventType::kBindingsChangedViaCluster &&
@@ -53,16 +54,19 @@ void ChipDeviceEventHandler::Handle(const chip::DeviceLayer::ChipDeviceEvent * e
5354
}
5455
else if (event->Type == chip::DeviceLayer::DeviceEventType::kCommissioningComplete)
5556
{
57+
// True when device completes initial commissioning (PASE).
58+
// Note: Not triggered for subsequent CASE sessions established via CastingPlayer::FindOrEstablishSession()
5659
HandleCommissioningComplete(event, arg, runPostCommissioning, targetNodeId, targetFabricIndex);
5760
}
5861

62+
// Run post commissioing for kBindingsChangedViaCluster and kCommissioningComplete events.
5963
if (runPostCommissioning)
6064
{
6165
sUdcInProgress = false;
6266
CastingPlayer::GetTargetCastingPlayer()->SetNodeId(targetNodeId);
6367
CastingPlayer::GetTargetCastingPlayer()->SetFabricIndex(targetFabricIndex);
6468

65-
ChipLogProgress(AppServer, "ChipDeviceEventHandler::Handle() calling FindOrEstablishSession()");
69+
ChipLogProgress(AppServer, "ChipDeviceEventHandler::Handle() calling CastingPlayer FindOrEstablishSession()");
6670
CastingPlayer::GetTargetCastingPlayer()->FindOrEstablishSession(
6771
nullptr,
6872
[](void * context, chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle) {

examples/tv-casting-app/tv-casting-common/support/EndpointListLoader.cpp

+21-4
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ CHIP_ERROR EndpointListLoader::Load()
130130

131131
if (!isLoadingRequired)
132132
{
133-
ChipLogProgress(AppServer, "EndpointListLoader::Load found no new endpoints to load");
133+
ChipLogProgress(AppServer,
134+
"EndpointListLoader::Load() found no new endpoints to load. Calling EndpointListLoader::Complete()");
134135
mPendingAttributeReads = 0;
135136
Complete();
136137
}
@@ -172,16 +173,32 @@ void EndpointListLoader::Complete()
172173
mNewEndpointsToLoad = 0;
173174

174175
// done loading endpoints, store TargetCastingPlayer
176+
ChipLogProgress(AppServer, "EndpointListLoader::Complete() Calling CastingStore::AddOrUpdate()");
175177
CHIP_ERROR err = support::CastingStore::GetInstance()->AddOrUpdate(*CastingPlayer::GetTargetCastingPlayer());
176178
if (err != CHIP_NO_ERROR)
177179
{
178180
ChipLogError(AppServer, "CastingStore::AddOrUpdate() failed. Err: %" CHIP_ERROR_FORMAT, err.Format());
179181
}
180182

181-
// callback client OnCompleted
183+
// Only trigger OnCompleted callback for target CastingPlayer when it has loaded endpoints (count >= 1)
184+
// Note: After initial commissioning (kCommissioningComplete event), endpoints will be 0.
185+
// CastingPlayer Endpoints are populated later, after receiving the kBindingsChangedViaCluster device event.
182186
VerifyOrReturn(CastingPlayer::GetTargetCastingPlayer()->mOnCompleted,
183-
ChipLogError(AppServer, "EndpointListLoader::Complete() mOnCompleted() not found"));
184-
CastingPlayer::GetTargetCastingPlayer()->mOnCompleted(CHIP_NO_ERROR, CastingPlayer::GetTargetCastingPlayer());
187+
ChipLogError(AppServer, "EndpointListLoader::Complete() OnCompleted() not found"));
188+
189+
std::vector<matter::casting::memory::Strong<matter::casting::core::Endpoint>> endpoints =
190+
CastingPlayer::GetTargetCastingPlayer()->GetEndpoints();
191+
if (!endpoints.empty())
192+
{
193+
ChipLogProgress(AppServer,
194+
"EndpointListLoader::Complete() Target CastingPlayer endpoints: %d, calling client's OnCompleted()",
195+
static_cast<int>(endpoints.size()));
196+
CastingPlayer::GetTargetCastingPlayer()->mOnCompleted(CHIP_NO_ERROR, CastingPlayer::GetTargetCastingPlayer());
197+
}
198+
else
199+
{
200+
ChipLogProgress(AppServer, "EndpointListLoader::Complete() Target CastingPlayer endpoints pending setup.");
201+
}
185202
}
186203
}
187204

src/app/server/Server.cpp

+13-8
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
116116
mUserDirectedCommissioningPort = initParams.userDirectedCommissioningPort;
117117
mInterfaceId = initParams.interfaceId;
118118

119+
#if INET_CONFIG_ENABLE_TCP_ENDPOINT
120+
auto tcpListenParams = TcpListenParameters(DeviceLayer::TCPEndPointManager())
121+
.SetAddressType(IPAddressType::kIPv6)
122+
.SetListenPort(mOperationalServicePort);
123+
#endif
124+
119125
CHIP_ERROR err = CHIP_NO_ERROR;
120126

121127
VerifyOrExit(initParams.persistentStorageDelegate != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT);
@@ -214,12 +220,6 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
214220
.SetAddressType(IPAddressType::kIPv6)
215221
.SetListenPort(mOperationalServicePort)
216222
.SetNativeParams(initParams.endpointNativeParams)
217-
#if INET_CONFIG_ENABLE_TCP_ENDPOINT
218-
,
219-
TcpListenParameters(DeviceLayer::TCPEndPointManager())
220-
.SetAddressType(IPAddressType::kIPv6)
221-
.SetListenPort(mOperationalServicePort)
222-
#endif
223223
#if INET_CONFIG_ENABLE_IPV4
224224
,
225225
UdpListenParameters(DeviceLayer::UDPEndPointManager())
@@ -230,8 +230,12 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
230230
,
231231
BleListenParameters(DeviceLayer::ConnectivityMgr().GetBleLayer())
232232
#endif
233-
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
233+
#if INET_CONFIG_ENABLE_TCP_ENDPOINT
234234
,
235+
tcpListenParams
236+
#endif
237+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
238+
,
235239
Transport::WiFiPAFListenParameters(DeviceLayer::ConnectivityMgr().GetWiFiPAF())
236240
#endif
237241
);
@@ -333,7 +337,8 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
333337
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
334338

335339
#if INET_CONFIG_ENABLE_TCP_ENDPOINT
336-
app::DnssdServer::Instance().SetTCPServerEnabled(mTransports.GetTransport().GetImplAtIndex<1>().IsServerListenEnabled());
340+
// Enable the TCP Server based on the TCPListenParameters setting.
341+
app::DnssdServer::Instance().SetTCPServerEnabled(tcpListenParams.IsServerListenEnabled());
337342
#endif // INET_CONFIG_ENABLE_TCP_ENDPOINT
338343

339344
if (GetFabricTable().FabricCount() != 0)

src/app/server/Server.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ inline constexpr size_t kMaxTcpPendingPackets = CHIP_CONFIG_MAX_TCP_PENDING_PACK
9696
// in the Server impl depends on this.
9797
//
9898
using ServerTransportMgr = chip::TransportMgr<chip::Transport::UDP
99-
#if INET_CONFIG_ENABLE_TCP_ENDPOINT
100-
,
101-
chip::Transport::TCP<kMaxTcpActiveConnectionCount, kMaxTcpPendingPackets>
102-
#endif
10399
#if INET_CONFIG_ENABLE_IPV4
104100
,
105101
chip::Transport::UDP
@@ -108,6 +104,10 @@ using ServerTransportMgr = chip::TransportMgr<chip::Transport::UDP
108104
,
109105
chip::Transport::BLE<kMaxBlePendingPackets>
110106
#endif
107+
#if INET_CONFIG_ENABLE_TCP_ENDPOINT
108+
,
109+
chip::Transport::TCP<kMaxTcpActiveConnectionCount, kMaxTcpPendingPackets>
110+
#endif
111111
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
112112
,
113113
chip::Transport::WiFiPAFBase

0 commit comments

Comments
 (0)