@@ -265,7 +265,7 @@ uint16_t emberAfGetDynamicIndexFromEndpoint(EndpointId id)
265
265
266
266
CHIP_ERROR emberAfSetDynamicEndpoint (uint16_t index, EndpointId id, const EmberAfEndpointType * ep,
267
267
const Span<DataVersion> & dataVersionStorage, Span<const EmberAfDeviceType> deviceTypeList,
268
- EndpointId parentEndpointId)
268
+ chip::CharSpan endpointUniqueId, EndpointId parentEndpointId)
269
269
{
270
270
auto realIndex = index + FIXED_ENDPOINT_COUNT;
271
271
@@ -317,10 +317,14 @@ CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, EndpointId id, const EmberA
317
317
}
318
318
}
319
319
}
320
- emAfEndpoints[index ].endpoint = id;
321
- emAfEndpoints[index ].deviceTypeList = deviceTypeList;
322
- emAfEndpoints[index ].endpointType = ep;
323
- emAfEndpoints[index ].dataVersions = dataVersionStorage.data ();
320
+ emAfEndpoints[index ].endpoint = id;
321
+ emAfEndpoints[index ].deviceTypeList = deviceTypeList;
322
+ emAfEndpoints[index ].endpointType = ep;
323
+ emAfEndpoints[index ].dataVersions = dataVersionStorage.data ();
324
+ memcpy ((void *)(emAfEndpoints[index ].endpointUniqueId ), endpointUniqueId.data (),
325
+ endpointUniqueId.size () > Clusters::Descriptor::Attributes::EndpointUniqueId::TypeInfo::MaxLength ()?
326
+ Clusters::Descriptor::Attributes::EndpointUniqueId::TypeInfo::MaxLength () : endpointUniqueId.size ());
327
+
324
328
// Start the endpoint off as disabled.
325
329
emAfEndpoints[index ].bitmask .Clear (EmberAfEndpointOptions::isEnabled);
326
330
emAfEndpoints[index ].parentEndpointId = parentEndpointId;
@@ -1080,15 +1084,19 @@ CHIP_ERROR GetSemanticTagForEndpointAtIndex(EndpointId endpoint, size_t index,
1080
1084
return CHIP_NO_ERROR;
1081
1085
}
1082
1086
1083
- CHIP_ERROR GetEndpointUniqueIdForEndPoint (EndpointId endpoint, char * buf )
1087
+ CHIP_ERROR GetEndpointUniqueIdForEndPoint (EndpointId endpoint, chip::MutableCharSpan & epUniqueIdMutSpan )
1084
1088
{
1085
1089
uint16_t endpointIndex = emberAfIndexFromEndpoint (endpoint);
1086
1090
1087
1091
if (endpointIndex == 0xFFFF )
1088
1092
{
1089
1093
return CHIP_ERROR_NOT_FOUND;
1090
1094
}
1091
- strcpy (buf, emAfEndpoints[endpointIndex].endpointUniqueId .c_str ());
1095
+ chip::CharSpan epUniqueIdSpan (emAfEndpoints[endpointIndex].endpointUniqueId ,
1096
+ strnlen (emAfEndpoints[endpointIndex].endpointUniqueId ,
1097
+ Clusters::Descriptor::Attributes::EndpointUniqueId::TypeInfo::MaxLength ()));
1098
+ chip::CopyCharSpanToMutableCharSpan (epUniqueIdSpan, epUniqueIdMutSpan);
1099
+
1092
1100
return CHIP_NO_ERROR;
1093
1101
}
1094
1102
@@ -1116,18 +1124,6 @@ CHIP_ERROR SetTagList(EndpointId endpoint, Span<const Clusters::Descriptor::Stru
1116
1124
return CHIP_NO_ERROR;
1117
1125
}
1118
1126
1119
- CHIP_ERROR SetEndPointUniqueId (chip::EndpointId endpoint, std::string endpointUniqueId)
1120
- {
1121
- uint16_t endpointIndex = emberAfIndexFromEndpoint (endpoint);
1122
- if (endpointIndex == 0xFFFF )
1123
- {
1124
- return CHIP_ERROR_INVALID_ARGUMENT;
1125
- }
1126
-
1127
- emAfEndpoints[endpointIndex].endpointUniqueId = endpointUniqueId;
1128
- return CHIP_NO_ERROR;
1129
- }
1130
-
1131
1127
// Returns the cluster of Nth server or client cluster,
1132
1128
// depending on server toggle.
1133
1129
const EmberAfCluster * emberAfGetNthCluster (EndpointId endpoint, uint8_t n, bool server)
0 commit comments