Skip to content

Commit 8329f50

Browse files
authored
Merge branch 'master' into esp32/add_thread_br_ota
2 parents 9ef3c3e + 75b5405 commit 8329f50

34 files changed

+454
-203
lines changed

examples/camera-app/camera-common/camera-app.matter

+17-14
Original file line numberDiff line numberDiff line change
@@ -2444,10 +2444,11 @@ provisional cluster WebRTCTransportProvider = 1363 {
24442444
fabric_scoped struct WebRTCSessionStruct {
24452445
int16u id = 1;
24462446
node_id peerNodeID = 2;
2447-
StreamUsageEnum streamUsage = 3;
2448-
nullable int16u videoStreamID = 4;
2449-
nullable int16u audioStreamID = 5;
2450-
WebRTCMetadataOptionsBitmap metadataOptions = 6;
2447+
endpoint_no peerEndpointID = 3;
2448+
StreamUsageEnum streamUsage = 4;
2449+
nullable int16u videoStreamID = 5;
2450+
nullable int16u audioStreamID = 6;
2451+
WebRTCMetadataOptionsBitmap metadataOptions = 7;
24512452
fabric_idx fabricIndex = 254;
24522453
}
24532454

@@ -2461,11 +2462,12 @@ provisional cluster WebRTCTransportProvider = 1363 {
24612462

24622463
request struct SolicitOfferRequest {
24632464
StreamUsageEnum streamUsage = 0;
2464-
optional nullable int16u videoStreamID = 1;
2465-
optional nullable int16u audioStreamID = 2;
2466-
optional ICEServerStruct ICEServers[] = 3;
2467-
optional char_string ICETransportPolicy = 4;
2468-
optional WebRTCMetadataOptionsBitmap metadataOptions = 5;
2465+
endpoint_no originatingEndpointID = 1;
2466+
optional nullable int16u videoStreamID = 2;
2467+
optional nullable int16u audioStreamID = 3;
2468+
optional ICEServerStruct ICEServers[] = 4;
2469+
optional char_string ICETransportPolicy = 5;
2470+
optional WebRTCMetadataOptionsBitmap metadataOptions = 6;
24692471
}
24702472

24712473
response struct SolicitOfferResponse = 2 {
@@ -2479,11 +2481,12 @@ provisional cluster WebRTCTransportProvider = 1363 {
24792481
nullable int16u webRTCSessionID = 0;
24802482
char_string sdp = 1;
24812483
StreamUsageEnum streamUsage = 2;
2482-
optional nullable int16u videoStreamID = 3;
2483-
optional nullable int16u audioStreamID = 4;
2484-
optional ICEServerStruct ICEServers[] = 5;
2485-
optional char_string ICETransportPolicy = 6;
2486-
optional WebRTCMetadataOptionsBitmap metadataOptions = 7;
2484+
endpoint_no originatingEndpointID = 3;
2485+
optional nullable int16u videoStreamID = 4;
2486+
optional nullable int16u audioStreamID = 5;
2487+
optional ICEServerStruct ICEServers[] = 6;
2488+
optional char_string ICETransportPolicy = 7;
2489+
optional WebRTCMetadataOptionsBitmap metadataOptions = 8;
24872490
}
24882491

24892492
response struct ProvideOfferResponse = 4 {

src/app/clusters/on-off-server/on-off-server.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -520,12 +520,6 @@ void OnOffServer::initOnOffServer(chip::EndpointId endpoint)
520520
status = setOnOffValue(endpoint, onOffValueForStartUp, true);
521521
}
522522

523-
#if defined(MATTER_DM_PLUGIN_SCENES_MANAGEMENT) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
524-
// Registers Scene handlers for the On/Off cluster on the server
525-
app::Clusters::ScenesManagement::ScenesServer::Instance().RegisterSceneHandler(endpoint,
526-
OnOffServer::Instance().GetSceneHandler());
527-
#endif // defined(MATTER_DM_PLUGIN_SCENES_MANAGEMENT) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
528-
529523
#ifdef MATTER_DM_PLUGIN_MODE_SELECT
530524
// If OnMode is not a null value, then change the current mode to it.
531525
if (onOffValueForStartUp && emberAfContainsServer(endpoint, ModeSelect::Id) &&
@@ -542,6 +536,12 @@ void OnOffServer::initOnOffServer(chip::EndpointId endpoint)
542536
}
543537
#endif // IGNORE_ON_OFF_CLUSTER_START_UP_ON_OFF
544538

539+
#if defined(MATTER_DM_PLUGIN_SCENES_MANAGEMENT) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
540+
// Registers Scene handlers for the On/Off cluster on the server
541+
app::Clusters::ScenesManagement::ScenesServer::Instance().RegisterSceneHandler(endpoint,
542+
OnOffServer::Instance().GetSceneHandler());
543+
#endif // defined(MATTER_DM_PLUGIN_SCENES_MANAGEMENT) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
544+
545545
emberAfPluginOnOffClusterServerPostInitCallback(endpoint);
546546
}
547547

src/app/server/Dnssd.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ CHIP_ERROR DnssdServer::AdvertiseOperational()
207207
.SetPort(GetSecuredPort())
208208
.SetInterfaceId(GetInterfaceId())
209209
.SetLocalMRPConfig(GetLocalMRPConfig().std_optional())
210-
.EnableIpV4(true);
210+
.EnableIpV4(SecuredIPv4PortMatchesIPv6Port());
211211

212212
#if CHIP_CONFIG_ENABLE_ICD_SERVER
213213
AddICDKeyToAdvertisement(advertiseParameters);
@@ -234,7 +234,7 @@ CHIP_ERROR DnssdServer::Advertise(bool commissionableNode, chip::Dnssd::Commissi
234234
auto advertiseParameters = chip::Dnssd::CommissionAdvertisingParameters()
235235
.SetPort(commissionableNode ? GetSecuredPort() : GetUnsecuredPort())
236236
.SetInterfaceId(GetInterfaceId())
237-
.EnableIpV4(true);
237+
.EnableIpV4(!commissionableNode || SecuredIPv4PortMatchesIPv6Port());
238238
advertiseParameters.SetCommissionAdvertiseMode(commissionableNode ? chip::Dnssd::CommssionAdvertiseMode::kCommissionableNode
239239
: chip::Dnssd::CommssionAdvertiseMode::kCommissioner);
240240

src/app/server/Dnssd.h

+25-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <app/icd/server/ICDStateObserver.h>
2525
#include <app/server/CommissioningModeProvider.h>
2626
#include <credentials/FabricTable.h>
27+
#include <inet/InetConfig.h>
2728
#include <lib/core/CHIPError.h>
2829
#include <lib/core/Optional.h>
2930
#include <lib/dnssd/Advertiser.h>
@@ -46,11 +47,16 @@ class DLL_EXPORT DnssdServer : public ICDStateObserver
4647
return instance;
4748
}
4849

49-
/// Sets the secure Matter port
50-
void SetSecuredPort(uint16_t port) { mSecuredPort = port; }
50+
/// Sets the secure Matter IPv6 port
51+
void SetSecuredIPv6Port(uint16_t port) { mSecuredIPv6Port = port; }
52+
53+
#if INET_CONFIG_ENABLE_IPV4
54+
/// Sets the secure Matter IPv4 port.
55+
void SetSecuredIPv4Port(uint16_t port) { mSecuredIPv4Port = port; }
56+
#endif // INET_CONFIG_ENABLE_IPV4
5157

5258
/// Gets the secure Matter port
53-
uint16_t GetSecuredPort() const { return mSecuredPort; }
59+
uint16_t GetSecuredPort() const { return mSecuredIPv6Port; }
5460

5561
/// Sets the unsecure Matter port
5662
void SetUnsecuredPort(uint16_t port) { mUnsecuredPort = port; }
@@ -176,6 +182,18 @@ class DLL_EXPORT DnssdServer : public ICDStateObserver
176182
//
177183
bool HaveOperationalCredentials();
178184

185+
// Check whether the secured IPv4 port matches the secured IPv6 port. If it
186+
// does not, we should not advertise our IPv4 bits, because we can only
187+
// advertise one port number.
188+
bool SecuredIPv4PortMatchesIPv6Port() const
189+
{
190+
#if INET_CONFIG_ENABLE_IPV4
191+
return mSecuredIPv4Port == mSecuredIPv6Port;
192+
#else
193+
return false;
194+
#endif // INET_CONFIG_ENABLE_IPV4
195+
}
196+
179197
FabricTable * mFabricTable = nullptr;
180198
CommissioningModeProvider * mCommissioningModeProvider = nullptr;
181199

@@ -187,7 +205,10 @@ class DLL_EXPORT DnssdServer : public ICDStateObserver
187205
bool mTCPServerEnabled = true;
188206
#endif // INET_CONFIG_ENABLE_TCP_ENDPOINT
189207

190-
uint16_t mSecuredPort = CHIP_PORT;
208+
uint16_t mSecuredIPv6Port = CHIP_PORT;
209+
#if INET_CONFIG_ENABLE_IPV4
210+
uint16_t mSecuredIPv4Port = CHIP_PORT;
211+
#endif // INET_CONFIG_ENABLE_IPV4
191212
uint16_t mUnsecuredPort = CHIP_UDC_PORT;
192213
Inet::InterfaceId mInterfaceId = Inet::InterfaceId::Null();
193214

src/app/server/Server.cpp

+9-7
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,17 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
216216
}
217217

218218
// Init transport before operations with secure session mgr.
219+
//
220+
// The logic below expects that the IPv6 transport is at index 0. Keep that logic in sync with
221+
// this code.
219222
err = mTransports.Init(UdpListenParameters(DeviceLayer::UDPEndPointManager())
220223
.SetAddressType(IPAddressType::kIPv6)
221224
.SetListenPort(mOperationalServicePort)
222225
.SetNativeParams(initParams.endpointNativeParams)
223226
#if INET_CONFIG_ENABLE_IPV4
224227
,
228+
// The logic below expects that the IPv4 transport, if enabled, is at
229+
// index 1. Keep that logic in sync with this code.
225230
UdpListenParameters(DeviceLayer::UDPEndPointManager())
226231
.SetAddressType(IPAddressType::kIPv4)
227232
.SetListenPort(mOperationalServicePort)
@@ -318,13 +323,10 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
318323
SuccessOrExit(err);
319324
#endif
320325

321-
//
322-
// We need to advertise the port that we're listening to for unsolicited messages over UDP. However, we have both a IPv4
323-
// and IPv6 endpoint to pick from. Given that the listen port passed in may be set to 0 (which then has the kernel select
324-
// a valid port at bind time), that will result in two possible ports being provided back from the resultant endpoint
325-
// initializations. Since IPv6 is POR for Matter, let's go ahead and pick that port.
326-
//
327-
app::DnssdServer::Instance().SetSecuredPort(mTransports.GetTransport().GetImplAtIndex<0>().GetBoundPort());
326+
app::DnssdServer::Instance().SetSecuredIPv6Port(mTransports.GetTransport().GetImplAtIndex<0>().GetBoundPort());
327+
#if INET_CONFIG_ENABLE_IPV4
328+
app::DnssdServer::Instance().SetSecuredIPv4Port(mTransports.GetTransport().GetImplAtIndex<1>().GetBoundPort());
329+
#endif // INET_CONFIG_ENABLE_IPV4
328330

329331
app::DnssdServer::Instance().SetUnsecuredPort(mUserDirectedCommissioningPort);
330332
app::DnssdServer::Instance().SetInterfaceId(mInterfaceId);

src/app/zap-templates/zcl/data-model/chip/webrtc-provider-cluster.xml

+18-15
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ limitations under the License.
1818
XML generated by Alchemy; DO NOT EDIT.
1919
Source: src/app_clusters/WebRTC_Provider.adoc
2020
Parameters: in-progress
21-
Git: 0.7-summer-2025-285-g2a2bd1961
21+
Git: 0.7-summer-2025-557-g3a1482e70
2222
-->
2323
<configurator xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../zcl.xsd">
2424
<domain name="Cameras"/>
@@ -59,10 +59,11 @@ Git: 0.7-summer-2025-285-g2a2bd1961
5959
<cluster code="0x0554"/>
6060
<item fieldId="1" name="ID" type="int16u"/>
6161
<item fieldId="2" name="PeerNodeID" type="node_id"/>
62-
<item fieldId="3" name="StreamUsage" type="StreamUsageEnum" min="0x00" max="0x03"/>
63-
<item fieldId="4" name="VideoStreamID" type="int16u" isNullable="true"/>
64-
<item fieldId="5" name="AudioStreamID" type="int16u" isNullable="true"/>
65-
<item fieldId="6" name="MetadataOptions" type="WebRTCMetadataOptionsBitmap" default="0x00" min="0x00" max="0x01"/>
62+
<item fieldId="3" name="PeerEndpointID" type="endpoint_no"/>
63+
<item fieldId="4" name="StreamUsage" type="StreamUsageEnum" min="0x00" max="0x03"/>
64+
<item fieldId="5" name="VideoStreamID" type="int16u" isNullable="true"/>
65+
<item fieldId="6" name="AudioStreamID" type="int16u" isNullable="true"/>
66+
<item fieldId="7" name="MetadataOptions" type="WebRTCMetadataOptionsBitmap" default="0x00" min="0x00" max="0x01"/>
6667
</struct>
6768

6869
<cluster apiMaturity="provisional">
@@ -82,11 +83,12 @@ Git: 0.7-summer-2025-285-g2a2bd1961
8283
<description>Requests that the Provider initiates a new session with the Offer / Answer flow in a way that allows for options to be passed and work with devices needing the standby flow.</description>
8384
<quality largeMessage="true"/>
8485
<arg id="1" name="StreamUsage" type="StreamUsageEnum" min="0x00" max="0x03"/>
85-
<arg id="2" name="VideoStreamID" type="int16u" optional="true" isNullable="true"/>
86-
<arg id="3" name="AudioStreamID" type="int16u" optional="true" isNullable="true"/>
87-
<arg id="4" name="ICEServers" array="true" type="ICEServerStruct" optional="true"/>
88-
<arg id="5" name="ICETransportPolicy" type="char_string" optional="true"/>
89-
<arg id="6" name="MetadataOptions" type="WebRTCMetadataOptionsBitmap" optional="true" min="0x00" max="0x01"/>
86+
<arg id="2" name="OriginatingEndpointID" type="endpoint_no"/>
87+
<arg id="3" name="VideoStreamID" type="int16u" optional="true" isNullable="true"/>
88+
<arg id="4" name="AudioStreamID" type="int16u" optional="true" isNullable="true"/>
89+
<arg id="5" name="ICEServers" type="ICEServerStruct" optional="true" array="true"/>
90+
<arg id="6" name="ICETransportPolicy" type="char_string" optional="true"/>
91+
<arg id="7" name="MetadataOptions" type="WebRTCMetadataOptionsBitmap" optional="true" min="0x00" max="0x01"/>
9092
</command>
9193

9294
<command code="0x02" source="server" name="SolicitOfferResponse" optional="false" disableDefaultResponse="true">
@@ -104,11 +106,12 @@ Git: 0.7-summer-2025-285-g2a2bd1961
104106
<arg id="1" name="WebRTCSessionID" type="int16u" isNullable="true"/>
105107
<arg id="2" name="SDP" type="char_string"/>
106108
<arg id="3" name="StreamUsage" type="StreamUsageEnum" min="0x00" max="0x03"/>
107-
<arg id="4" name="VideoStreamID" type="int16u" optional="true" isNullable="true"/>
108-
<arg id="5" name="AudioStreamID" type="int16u" optional="true" isNullable="true"/>
109-
<arg id="6" name="ICEServers" array="true" type="ICEServerStruct" optional="true"/>
110-
<arg id="7" name="ICETransportPolicy" type="char_string" optional="true"/>
111-
<arg id="8" name="MetadataOptions" type="WebRTCMetadataOptionsBitmap" optional="true" min="0x00" max="0x01"/>
109+
<arg id="4" name="OriginatingEndpointID" type="endpoint_no"/>
110+
<arg id="5" name="VideoStreamID" type="int16u" optional="true" isNullable="true"/>
111+
<arg id="6" name="AudioStreamID" type="int16u" optional="true" isNullable="true"/>
112+
<arg id="7" name="ICEServers" type="ICEServerStruct" optional="true" array="true"/>
113+
<arg id="8" name="ICETransportPolicy" type="char_string" optional="true"/>
114+
<arg id="9" name="MetadataOptions" type="WebRTCMetadataOptionsBitmap" optional="true" min="0x00" max="0x01"/>
112115
</command>
113116

114117
<command code="0x04" source="server" name="ProvideOfferResponse" optional="false" disableDefaultResponse="true">

src/controller/CHIPDeviceControllerFactory.cpp

+15-8
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,18 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params)
169169
stateParams.transportMgr = chip::Platform::New<DeviceTransportMgr>();
170170

171171
//
172-
// The logic below expects IPv6 to be at index 0 of this tuple. Please do not alter that.
172+
// The logic below expects IPv6 to be at index 0 of this tuple. Keep that logic in sync with
173+
// this code.
173174
//
174175
ReturnErrorOnFailure(stateParams.transportMgr->Init(Transport::UdpListenParameters(stateParams.udpEndPointManager)
175176
.SetAddressType(Inet::IPAddressType::kIPv6)
176177
.SetListenPort(params.listenPort)
177178
#if INET_CONFIG_ENABLE_IPV4
178179
,
180+
//
181+
// The logic below expects IPv4 to be at index 1 of this tuple,
182+
// if it's enabled. Keep that logic in sync with this code.
183+
//
179184
Transport::UdpListenParameters(stateParams.udpEndPointManager)
180185
.SetAddressType(Inet::IPAddressType::kIPv4)
181186
.SetListenPort(params.listenPort)
@@ -272,13 +277,15 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params)
272277
stateParams.exchangeMgr, stateParams.sessionMgr, stateParams.fabricTable, sessionResumptionStorage,
273278
stateParams.certificateValidityPolicy, stateParams.groupDataProvider));
274279

275-
//
276-
// We need to advertise the port that we're listening to for unsolicited messages over UDP. However, we have both a IPv4
277-
// and IPv6 endpoint to pick from. Given that the listen port passed in may be set to 0 (which then has the kernel select
278-
// a valid port at bind time), that will result in two possible ports being provided back from the resultant endpoint
279-
// initializations. Since IPv6 is POR for Matter, let's go ahead and pick that port.
280-
//
281-
app::DnssdServer::Instance().SetSecuredPort(stateParams.transportMgr->GetTransport().GetImplAtIndex<0>().GetBoundPort());
280+
// Our IPv6 transport is at index 0.
281+
app::DnssdServer::Instance().SetSecuredIPv6Port(
282+
stateParams.transportMgr->GetTransport().GetImplAtIndex<0>().GetBoundPort());
283+
284+
#if INET_CONFIG_ENABLE_IPV4
285+
// If enabled, our IPv4 transport is at index 1.
286+
app::DnssdServer::Instance().SetSecuredIPv4Port(
287+
stateParams.transportMgr->GetTransport().GetImplAtIndex<1>().GetBoundPort());
288+
#endif // INET_CONFIG_ENABLE_IPV4
282289

283290
//
284291
// TODO: This is a hack to workaround the fact that we have a bi-polar stack that has controller and server modalities that

src/controller/data_model/controller-clusters.matter

+22-18
Original file line numberDiff line numberDiff line change
@@ -10117,10 +10117,11 @@ provisional cluster WebRTCTransportProvider = 1363 {
1011710117
fabric_scoped struct WebRTCSessionStruct {
1011810118
int16u id = 1;
1011910119
node_id peerNodeID = 2;
10120-
StreamUsageEnum streamUsage = 3;
10121-
nullable int16u videoStreamID = 4;
10122-
nullable int16u audioStreamID = 5;
10123-
WebRTCMetadataOptionsBitmap metadataOptions = 6;
10120+
endpoint_no peerEndpointID = 3;
10121+
StreamUsageEnum streamUsage = 4;
10122+
nullable int16u videoStreamID = 5;
10123+
nullable int16u audioStreamID = 6;
10124+
WebRTCMetadataOptionsBitmap metadataOptions = 7;
1012410125
fabric_idx fabricIndex = 254;
1012510126
}
1012610127

@@ -10134,11 +10135,12 @@ provisional cluster WebRTCTransportProvider = 1363 {
1013410135

1013510136
request struct SolicitOfferRequest {
1013610137
StreamUsageEnum streamUsage = 0;
10137-
optional nullable int16u videoStreamID = 1;
10138-
optional nullable int16u audioStreamID = 2;
10139-
optional ICEServerStruct ICEServers[] = 3;
10140-
optional char_string ICETransportPolicy = 4;
10141-
optional WebRTCMetadataOptionsBitmap metadataOptions = 5;
10138+
endpoint_no originatingEndpointID = 1;
10139+
optional nullable int16u videoStreamID = 2;
10140+
optional nullable int16u audioStreamID = 3;
10141+
optional ICEServerStruct ICEServers[] = 4;
10142+
optional char_string ICETransportPolicy = 5;
10143+
optional WebRTCMetadataOptionsBitmap metadataOptions = 6;
1014210144
}
1014310145

1014410146
response struct SolicitOfferResponse = 2 {
@@ -10152,11 +10154,12 @@ provisional cluster WebRTCTransportProvider = 1363 {
1015210154
nullable int16u webRTCSessionID = 0;
1015310155
char_string sdp = 1;
1015410156
StreamUsageEnum streamUsage = 2;
10155-
optional nullable int16u videoStreamID = 3;
10156-
optional nullable int16u audioStreamID = 4;
10157-
optional ICEServerStruct ICEServers[] = 5;
10158-
optional char_string ICETransportPolicy = 6;
10159-
optional WebRTCMetadataOptionsBitmap metadataOptions = 7;
10157+
endpoint_no originatingEndpointID = 3;
10158+
optional nullable int16u videoStreamID = 4;
10159+
optional nullable int16u audioStreamID = 5;
10160+
optional ICEServerStruct ICEServers[] = 6;
10161+
optional char_string ICETransportPolicy = 7;
10162+
optional WebRTCMetadataOptionsBitmap metadataOptions = 8;
1016010163
}
1016110164

1016210165
response struct ProvideOfferResponse = 4 {
@@ -10232,10 +10235,11 @@ provisional cluster WebRTCTransportRequestor = 1364 {
1023210235
fabric_scoped struct WebRTCSessionStruct {
1023310236
int16u id = 1;
1023410237
node_id peerNodeID = 2;
10235-
StreamUsageEnum streamUsage = 3;
10236-
nullable int16u videoStreamID = 4;
10237-
nullable int16u audioStreamID = 5;
10238-
WebRTCMetadataOptionsBitmap metadataOptions = 6;
10238+
endpoint_no peerEndpointID = 3;
10239+
StreamUsageEnum streamUsage = 4;
10240+
nullable int16u videoStreamID = 5;
10241+
nullable int16u audioStreamID = 6;
10242+
WebRTCMetadataOptionsBitmap metadataOptions = 7;
1023910243
fabric_idx fabricIndex = 254;
1024010244
}
1024110245

0 commit comments

Comments
 (0)