Skip to content

Commit 1c04a69

Browse files
committed
Code review updates
1 parent 9bbe92a commit 1c04a69

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

src/app/codegen-data-model/CodegenDataModel_Read.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ struct ShortPascalString
9292
static size_t GetLength(ByteSpan buffer)
9393
{
9494
VerifyOrDie(buffer.size() >= 1);
95-
// NOTE: we do NOT use emberAfLongStringLength because that will result in 0 length
96-
// for null sizes (i.e. 0xFF is translated to 0 and we do not want that here)
95+
// NOTE: we do NOT use emberAfStringLength from ember-strings.h because that will result in 0
96+
// length for null sizes (i.e. 0xFF is translated to 0 and we do not want that here)
9797
return buffer[0];
9898
}
9999
};
@@ -106,8 +106,8 @@ struct LongPascalString
106106

107107
static size_t GetLength(ByteSpan buffer)
108108
{
109-
// NOTE: we do NOT use emberAfLongStringLength because that will result in 0 length
110-
// for null sizes (i.e. 0xFFFF is translated to 0 and we do not want that here)
109+
// NOTE: we do NOT use emberAfLongStringLength from ember-strings.h because that will result in 0
110+
// length for null sizes (i.e. 0xFFFF is translated to 0 and we do not want that here)
111111
VerifyOrDie(buffer.size() >= 2);
112112
const uint8_t * data = buffer.data();
113113
return Encoding::LittleEndian::Read16(data);

src/app/codegen-data-model/CodegenDataModel_Write.cpp

+15-11
Original file line numberDiff line numberDiff line change
@@ -365,34 +365,38 @@ CHIP_ERROR CodegenDataModel::WriteAttribute(const InteractionModel::WriteAttribu
365365

366366
Protocols::InteractionModel::Status status;
367367

368+
if (dataBuffer.size() > (*attributeMetadata)->size)
369+
{
370+
ChipLogDetail(Zcl, "Data to write exceeds the attribute size claimed.");
371+
return CHIP_IM_GLOBAL_STATUS(InvalidValue);
372+
}
373+
368374
if (request.operationFlags.Has(InteractionModel::OperationFlags::kInternal))
369375
{
370376
// Internal requests use the non-External interface that has less enforcement
371377
// than the external version (e.g. does not check/enforce writable settings, does not
372378
// validate attribute types) - see attribute-table.h documentation for details.
373379
status = emberAfWriteAttribute(request.path.mEndpointId, request.path.mClusterId, request.path.mAttributeId,
374-
gEmberAttributeIOBufferSpan.data(), (*attributeMetadata)->attributeType);
380+
dataBuffer.data(), (*attributeMetadata)->attributeType);
375381
}
376382
else
377383
{
378-
if (dataBuffer.size() > (*attributeMetadata)->size)
379-
{
380-
ChipLogDetail(Zcl, "Data to write exceeds the attribute size claimed.");
381-
return CHIP_IM_GLOBAL_STATUS(InvalidValue);
382-
}
383-
384384
status = emAfWriteAttributeExternal(request.path.mEndpointId, request.path.mClusterId, request.path.mAttributeId,
385-
gEmberAttributeIOBufferSpan.data(), (*attributeMetadata)->attributeType);
385+
dataBuffer.data(), (*attributeMetadata)->attributeType);
386386
}
387387

388388
if (status != Protocols::InteractionModel::Status::Success)
389389
{
390390
return CHIP_ERROR_IM_GLOBAL_STATUS_VALUE(status);
391391
}
392392

393-
// TODO: this may need more refinement:
394-
// - should internal requests be able to decide if something is marked dirty or not?
395-
// - changes-omitted paths should not be marked dirty (ember is not aware of these)
393+
// TODO: this WILL requre updates
394+
//
395+
// - Internal writes may need to be able to decide if to mark things dirty or not (see AAI as well)
396+
// - Changes-ommited paths should not be marked dirty (ember is not aware of that flag)
397+
// - This likely maps to `MatterReportingAttributeChangeCallback` HOWEVER current ember write functions
398+
// will selectively call that one depending on old attribute state (i.e. calling every time is a
399+
// change in behavior)
396400
CurrentContext().dataModelChangeListener->MarkDirty(request.path);
397401
return CHIP_NO_ERROR;
398402
}

0 commit comments

Comments
 (0)