Skip to content

Commit 2f8672d

Browse files
committed
Adding support for EndpointUniqueId in examples.
1 parent f5fd31c commit 2f8672d

File tree

11 files changed

+41
-29
lines changed

11 files changed

+41
-29
lines changed

examples/bridge-app/asr/subdevice/SubDeviceManager.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static EndpointId gFirstDynamicEndpointId;
4949
static SubDevice * gSubDevices[CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT]; // number of dynamic endpoints count
5050

5151
int AddDeviceEndpoint(SubDevice * dev, EmberAfEndpointType * ep, const Span<const EmberAfDeviceType> & deviceTypeList,
52-
const Span<DataVersion> & dataVersionStorage, chip::EndpointId parentEndpointId)
52+
const Span<DataVersion> & dataVersionStorage, chip::CharSpan epUniqueId, chip::EndpointId parentEndpointId)
5353
{
5454
uint8_t index = 0;
5555
while (index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT)
@@ -62,7 +62,8 @@ int AddDeviceEndpoint(SubDevice * dev, EmberAfEndpointType * ep, const Span<cons
6262
{
6363
dev->SetEndpointId(gCurrentEndpointId);
6464
err =
65-
emberAfSetDynamicEndpoint(index, gCurrentEndpointId, ep, dataVersionStorage, deviceTypeList, parentEndpointId);
65+
emberAfSetDynamicEndpoint(index, gCurrentEndpointId, ep, dataVersionStorage, deviceTypeList,
66+
epUniqueId, parentEndpointId);
6667
if (err == CHIP_NO_ERROR)
6768
{
6869
ChipLogProgress(DeviceLayer, "Added device %s to dynamic endpoint %d (index=%d)", dev->GetName(),

examples/bridge-app/esp32/main/main.cpp

+8-7
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ DataVersion gLight4DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)];
159159
#define ZCL_ON_OFF_CLUSTER_REVISION (4u)
160160

161161
int AddDeviceEndpoint(Device * dev, EmberAfEndpointType * ep, const Span<const EmberAfDeviceType> & deviceTypeList,
162-
const Span<DataVersion> & dataVersionStorage, chip::EndpointId parentEndpointId)
162+
const Span<DataVersion> & dataVersionStorage, chip::CharSpan epUniqueId, chip::EndpointId parentEndpointId)
163163
{
164164
uint8_t index = 0;
165165
while (index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT)
@@ -172,7 +172,8 @@ int AddDeviceEndpoint(Device * dev, EmberAfEndpointType * ep, const Span<const E
172172
{
173173
dev->SetEndpointId(gCurrentEndpointId);
174174
err =
175-
emberAfSetDynamicEndpoint(index, gCurrentEndpointId, ep, dataVersionStorage, deviceTypeList, parentEndpointId);
175+
emberAfSetDynamicEndpoint(index, gCurrentEndpointId, ep, dataVersionStorage, deviceTypeList,
176+
epUniqueId, parentEndpointId);
176177
if (err == CHIP_NO_ERROR)
177178
{
178179
ChipLogProgress(DeviceLayer, "Added device %s to dynamic endpoint %d (index=%d)", dev->GetName(),
@@ -377,22 +378,22 @@ static void InitServer(intptr_t context)
377378

378379
// Add lights 1..3 --> will be mapped to ZCL endpoints 3, 4, 5
379380
AddDeviceEndpoint(&gLight1, &bridgedLightEndpoint, Span<const EmberAfDeviceType>(gBridgedOnOffDeviceTypes),
380-
Span<DataVersion>(gLight1DataVersions), 1);
381+
Span<DataVersion>(gLight1DataVersions), chip::Span(), 1);
381382
AddDeviceEndpoint(&gLight2, &bridgedLightEndpoint, Span<const EmberAfDeviceType>(gBridgedOnOffDeviceTypes),
382-
Span<DataVersion>(gLight2DataVersions), 1);
383+
Span<DataVersion>(gLight2DataVersions), chip::Span(), 1);
383384
AddDeviceEndpoint(&gLight3, &bridgedLightEndpoint, Span<const EmberAfDeviceType>(gBridgedOnOffDeviceTypes),
384-
Span<DataVersion>(gLight3DataVersions), 1);
385+
Span<DataVersion>(gLight3DataVersions), chip::Span(), 1);
385386

386387
// Remove Light 2 -- Lights 1 & 3 will remain mapped to endpoints 3 & 5
387388
RemoveDeviceEndpoint(&gLight2);
388389

389390
// Add Light 4 -- > will be mapped to ZCL endpoint 6
390391
AddDeviceEndpoint(&gLight4, &bridgedLightEndpoint, Span<const EmberAfDeviceType>(gBridgedOnOffDeviceTypes),
391-
Span<DataVersion>(gLight4DataVersions), 1);
392+
Span<DataVersion>(gLight4DataVersions), chip::Span(), 1);
392393

393394
// Re-add Light 2 -- > will be mapped to ZCL endpoint 7
394395
AddDeviceEndpoint(&gLight2, &bridgedLightEndpoint, Span<const EmberAfDeviceType>(gBridgedOnOffDeviceTypes),
395-
Span<DataVersion>(gLight2DataVersions), 1);
396+
Span<DataVersion>(gLight2DataVersions), chip::Span(), 1);
396397
}
397398

398399
extern "C" void app_main()

examples/bridge-app/telink/src/AppTask.cpp

+10-9
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ AppTask AppTask::sAppTask;
3636
#include <app/InteractionModelEngine.h>
3737

3838
int AddDeviceEndpoint(Device * dev, EmberAfEndpointType * ep, const Span<const EmberAfDeviceType> & deviceTypeList,
39-
const Span<DataVersion> & dataVersionStorage, chip::EndpointId parentEndpointId);
39+
const Span<DataVersion> & dataVersionStorage, chip:CharSpan epUniqueId, chip::EndpointId parentEndpointId);
4040
CHIP_ERROR RemoveDeviceEndpoint(Device * dev);
4141
void HandleDeviceTempSensorStatusChanged(DeviceTempSensor * dev, DeviceTempSensor::Changed_t itemChangedMask);
4242
Protocols::InteractionModel::Status HandleReadTempMeasurementAttribute(DeviceTempSensor * dev, chip::AttributeId attributeId,
@@ -184,7 +184,7 @@ const EmberAfDeviceType gBridgedTempSensorDeviceTypes[] = { { DEVICE_TYPE_TEMP_S
184184
{ DEVICE_TYPE_BRIDGED_NODE, DEVICE_VERSION_DEFAULT } };
185185

186186
int AddDeviceEndpoint(Device * dev, EmberAfEndpointType * ep, const Span<const EmberAfDeviceType> & deviceTypeList,
187-
const Span<DataVersion> & dataVersionStorage, chip::EndpointId parentEndpointId)
187+
const Span<DataVersion> & dataVersionStorage, chip:CharSpan epUniqueId, chip::EndpointId parentEndpointId)
188188
{
189189
uint8_t index = 0;
190190
while (index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT)
@@ -197,7 +197,8 @@ int AddDeviceEndpoint(Device * dev, EmberAfEndpointType * ep, const Span<const E
197197
{
198198
dev->SetEndpointId(gCurrentEndpointId);
199199
err =
200-
emberAfSetDynamicEndpoint(index, gCurrentEndpointId, ep, dataVersionStorage, deviceTypeList, parentEndpointId);
200+
emberAfSetDynamicEndpoint(index, gCurrentEndpointId, ep, dataVersionStorage, deviceTypeList, epUniqueId,
201+
parentEndpointId);
201202
if (err == CHIP_NO_ERROR)
202203
{
203204
ChipLogProgress(DeviceLayer, "Added device %s to dynamic endpoint %d (index=%d)", dev->GetName(),
@@ -452,26 +453,26 @@ void AppTask::InitServer(intptr_t context)
452453

453454
// Add lights 1..3 --> will be mapped to ZCL endpoints 3, 4, 5
454455
AddDeviceEndpoint(&gLight1, &bridgedLightEndpoint, Span<const EmberAfDeviceType>(gBridgedOnOffDeviceTypes),
455-
Span<DataVersion>(gLight1DataVersions), 1);
456+
Span<DataVersion>(gLight1DataVersions), chip::Span(), 1);
456457
AddDeviceEndpoint(&gLight2, &bridgedLightEndpoint, Span<const EmberAfDeviceType>(gBridgedOnOffDeviceTypes),
457-
Span<DataVersion>(gLight2DataVersions), 1);
458+
Span<DataVersion>(gLight2DataVersions), chip::Span(), 1);
458459
AddDeviceEndpoint(&gLight3, &bridgedLightEndpoint, Span<const EmberAfDeviceType>(gBridgedOnOffDeviceTypes),
459-
Span<DataVersion>(gLight3DataVersions), 1);
460+
Span<DataVersion>(gLight3DataVersions), chip::Span(), 1);
460461

461462
// Remove Light 2 -- Lights 1 & 3 will remain mapped to endpoints 3 & 5
462463
RemoveDeviceEndpoint(&gLight2);
463464

464465
// Add Light 4 -- > will be mapped to ZCL endpoint 6
465466
AddDeviceEndpoint(&gLight4, &bridgedLightEndpoint, Span<const EmberAfDeviceType>(gBridgedOnOffDeviceTypes),
466-
Span<DataVersion>(gLight4DataVersions), 1);
467+
Span<DataVersion>(gLight4DataVersions), chip::Span(), 1);
467468

468469
// Re-add Light 2 -- > will be mapped to ZCL endpoint 7
469470
AddDeviceEndpoint(&gLight2, &bridgedLightEndpoint, Span<const EmberAfDeviceType>(gBridgedOnOffDeviceTypes),
470-
Span<DataVersion>(gLight2DataVersions), 1);
471+
Span<DataVersion>(gLight2DataVersions), chip::Span(), 1);
471472

472473
// Add Temperature Sensor devices --> will be mapped to endpoint 8
473474
AddDeviceEndpoint(&TempSensor1, &bridgedTempSensorEndpoint, Span<const EmberAfDeviceType>(gBridgedTempSensorDeviceTypes),
474-
Span<DataVersion>(gTempSensor1DataVersions), 1);
475+
Span<DataVersion>(gTempSensor1DataVersions), chip::Span(), 1);
475476
}
476477

477478
void HandleDeviceTempSensorStatusChanged(DeviceTempSensor * dev, DeviceTempSensor::Changed_t itemChangedMask)

examples/chef/devices/icd_rootnode_contactsensor_ed3b19ec55.matter

+1
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ cluster Descriptor = 29 {
316316
readonly attribute cluster_id clientList[] = 2;
317317
readonly attribute endpoint_no partsList[] = 3;
318318
readonly attribute optional SemanticTagStruct tagList[] = 4;
319+
readonly attribute optional char_string<32> endpointUniqueId = 5;
319320
readonly attribute command_id generatedCommandList[] = 65528;
320321
readonly attribute command_id acceptedCommandList[] = 65529;
321322
readonly attribute event_id eventList[] = 65530;

examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDeviceManager.h

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class BridgedDeviceManager
6363
* @return int The index of the dynamic endpoint if successful, nullopt otherwise
6464
*/
6565
std::optional<unsigned> AddDeviceEndpoint(std::unique_ptr<BridgedDevice> dev,
66+
chip::CharSpan epUniqueId = {},
6667
chip::EndpointId parentEndpointId = chip::kInvalidEndpointId);
6768

6869
/**

examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void BridgedDeviceManager::Init()
184184
}
185185

186186
std::optional<unsigned> BridgedDeviceManager::AddDeviceEndpoint(std::unique_ptr<BridgedDevice> dev,
187-
chip::EndpointId parentEndpointId)
187+
chip::CharSpan epUniqueId, chip::EndpointId parentEndpointId)
188188
{
189189
EmberAfEndpointType * ep = dev->IsIcd() ? &sIcdBridgedNodeEndpoint : &sBridgedNodeEndpoint;
190190

@@ -216,7 +216,8 @@ std::optional<unsigned> BridgedDeviceManager::AddDeviceEndpoint(std::unique_ptr<
216216
dev->SetEndpointId(mCurrentEndpointId);
217217
dev->SetParentEndpointId(parentEndpointId);
218218
CHIP_ERROR err =
219-
emberAfSetDynamicEndpoint(index, mCurrentEndpointId, ep, dataVersionStorage, deviceTypeList, parentEndpointId);
219+
emberAfSetDynamicEndpoint(index, mCurrentEndpointId, ep, dataVersionStorage, deviceTypeList, epUniqueId,
220+
parentEndpointId);
220221
if (err == CHIP_NO_ERROR)
221222
{
222223
ChipLogProgress(NotSpecified, "Added device with Id=[%d:0x" ChipLogFormatX64 "] to dynamic endpoint %d (index=%d)",

examples/fabric-sync/bridge/include/BridgedDeviceManager.h

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class BridgedDeviceManager
6262
* @return uint16_t The index of the dynamic endpoint if successful, nullopt otherwise
6363
*/
6464
std::optional<uint16_t> AddDeviceEndpoint(std::unique_ptr<BridgedDevice> dev,
65+
chip::CharSpan epUniqueId = {},
6566
chip::EndpointId parentEndpointId = chip::kInvalidEndpointId);
6667

6768
/**

examples/fabric-sync/bridge/src/BridgedDeviceManager.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void BridgedDeviceManager::Init()
183183
}
184184

185185
std::optional<uint16_t> BridgedDeviceManager::AddDeviceEndpoint(std::unique_ptr<BridgedDevice> dev,
186-
chip::EndpointId parentEndpointId)
186+
chip::CharSpan epUniqueId, chip::EndpointId parentEndpointId)
187187
{
188188
EmberAfEndpointType * ep = dev->IsIcd() ? &sIcdBridgedNodeEndpoint : &sBridgedNodeEndpoint;
189189

@@ -216,7 +216,8 @@ std::optional<uint16_t> BridgedDeviceManager::AddDeviceEndpoint(std::unique_ptr<
216216
dev->SetEndpointId(mCurrentEndpointId);
217217
dev->SetParentEndpointId(parentEndpointId);
218218
CHIP_ERROR err =
219-
emberAfSetDynamicEndpoint(index, mCurrentEndpointId, ep, dataVersionStorage, deviceTypeList, parentEndpointId);
219+
emberAfSetDynamicEndpoint(index, mCurrentEndpointId, ep, dataVersionStorage, deviceTypeList, epUniqueId,
220+
parentEndpointId);
220221
if (err == CHIP_NO_ERROR)
221222
{
222223
ChipLogProgress(NotSpecified, "Added device with Id=[%d:0x" ChipLogFormatX64 "] to dynamic endpoint %d (index=%d)",

examples/fabric-sync/bridge/src/FabricBridge.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ CHIP_ERROR FabricBridge::AddSynchronizedDevice(const SynchronizedDevice & data)
103103
device->SetIcd(data.isIcd.value_or(false));
104104

105105
// Add the device to the bridge manager with a parent endpoint
106-
auto result = BridgedDeviceManager::Instance().AddDeviceEndpoint(std::move(device), /* parentEndpointId= */ 1);
106+
auto result = BridgedDeviceManager::Instance().AddDeviceEndpoint(std::move(device), chip::CharSpan(), /* parentEndpointId= */ 1);
107107
if (!result.has_value())
108108
{
109109
ChipLogError(NotSpecified, "Failed to add device with Id=[%d:0x" ChipLogFormatX64 "]", data.id.GetFabricIndex(),

src/app/app-platform/ContentAppPlatform.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ AppPlatformExternalAttributeWriteCallback(EndpointId endpoint, ClusterId cluster
115115

116116
EndpointId ContentAppPlatform::AddContentApp(ContentApp * app, EmberAfEndpointType * ep,
117117
const Span<DataVersion> & dataVersionStorage,
118-
const Span<const EmberAfDeviceType> & deviceTypeList)
118+
const Span<const EmberAfDeviceType> & deviceTypeList,
119+
chip::CharSpan epUniqueId)
119120
{
120121
CatalogVendorApp vendorApp = app->GetApplicationBasicDelegate()->GetCatalogVendorApp();
121122

@@ -147,7 +148,7 @@ EndpointId ContentAppPlatform::AddContentApp(ContentApp * app, EmberAfEndpointTy
147148

148149
do
149150
{
150-
err = emberAfSetDynamicEndpoint(index, mCurrentEndpointId, ep, dataVersionStorage, deviceTypeList);
151+
err = emberAfSetDynamicEndpoint(index, mCurrentEndpointId, ep, dataVersionStorage, deviceTypeList, epUniqueId);
151152
if (err == CHIP_NO_ERROR)
152153
{
153154
ChipLogProgress(DeviceLayer, "Added ContentApp %s to dynamic endpoint %d (index=%d)", vendorApp.applicationId,
@@ -173,7 +174,9 @@ EndpointId ContentAppPlatform::AddContentApp(ContentApp * app, EmberAfEndpointTy
173174

174175
EndpointId ContentAppPlatform::AddContentApp(ContentApp * app, EmberAfEndpointType * ep,
175176
const Span<DataVersion> & dataVersionStorage,
176-
const Span<const EmberAfDeviceType> & deviceTypeList, EndpointId desiredEndpointId)
177+
const Span<const EmberAfDeviceType> & deviceTypeList,
178+
chip::CharSpan epUniqueId,
179+
EndpointId desiredEndpointId)
177180
{
178181
CatalogVendorApp vendorApp = app->GetApplicationBasicDelegate()->GetCatalogVendorApp();
179182

@@ -208,7 +211,7 @@ EndpointId ContentAppPlatform::AddContentApp(ContentApp * app, EmberAfEndpointTy
208211
index++;
209212
continue;
210213
}
211-
CHIP_ERROR err = emberAfSetDynamicEndpoint(index, desiredEndpointId, ep, dataVersionStorage, deviceTypeList);
214+
CHIP_ERROR err = emberAfSetDynamicEndpoint(index, desiredEndpointId, ep, dataVersionStorage, deviceTypeList, epUniqueId);
212215
if (err != CHIP_NO_ERROR)
213216
{
214217
ChipLogError(DeviceLayer, "Adding ContentApp error : %" CHIP_ERROR_FORMAT, err.Format());

src/app/app-platform/ContentAppPlatform.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class DLL_EXPORT ContentAppPlatform
106106
// dataVersionStorage.size() needs to be at least as big as the number of
107107
// server clusters in the EmberAfEndpointType passed in.
108108
EndpointId AddContentApp(ContentApp * app, EmberAfEndpointType * ep, const Span<DataVersion> & dataVersionStorage,
109-
const Span<const EmberAfDeviceType> & deviceTypeList);
109+
const Span<const EmberAfDeviceType> & deviceTypeList, chip::CharSpan ={});
110110

111111
// add apps to the platform.
112112
// This will assign the app to the desiredEndpointId (if it is not already used)
@@ -115,7 +115,8 @@ class DLL_EXPORT ContentAppPlatform
115115
// dataVersionStorage.size() needs to be at least as big as the number of
116116
// server clusters in the EmberAfEndpointType passed in.
117117
EndpointId AddContentApp(ContentApp * app, EmberAfEndpointType * ep, const Span<DataVersion> & dataVersionStorage,
118-
const Span<const EmberAfDeviceType> & deviceTypeList, EndpointId desiredEndpointId);
118+
const Span<const EmberAfDeviceType> & deviceTypeList, chip::CharSpan epUniqueId,
119+
EndpointId desiredEndpointId);
119120

120121
// remove app from the platform.
121122
// returns the endpoint id where the app was, or 0 if app was not loaded

0 commit comments

Comments
 (0)