Skip to content

Commit

Permalink
fixup DecodeEnd
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Walker committed May 28, 2020
1 parent 41b6517 commit 8df05ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/app/chip-zcl/chip-zcl-codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,9 @@ ChipZclStatus_t chipZclCodecDecodeStart(ChipZclCodec_t * codec, ChipZclBuffer_t
*/
ChipZclStatus_t chipZclCodecDecode(ChipZclCodec_t * codec, ChipZclType_t type, void * ptr, uint16_t ptrLen, uint16_t * retLen);

/**
* @brief Call after decoding to verify that everything has been decoded
*/
ChipZclStatus_t chipZclCodecDecodeEnd(ChipZclCodec_t * me);

#endif // CHIP_ZCL_CODEC
12 changes: 9 additions & 3 deletions src/app/plugin/codec-simple/codec-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,18 @@ ChipZclStatus_t chipZclCodecDecode(ChipZclCodec_t * me, ChipZclType_t type, void
}

/**
* @brief Ends the decoding process. After this call, buffer should no longer be used for further decoding.
* @brief Call after decoding to verify that everything has been decoded
*/
ChipZclStatus_t chipZclCodecDecodeEnd(ChipZclCodec_t * me)
{
chipZclBufferSetDataLength(me->buffer, me->cursor);
return CHIP_ZCL_STATUS_SUCCESS;
if (chipZclBufferDataLength(me->buffer) == me->cursor)
{
return CHIP_ZCL_STATUS_SUCCESS;
}
else
{
return CHIP_ZCL_STATUS_FAILURE;
}
}

void chipZclEncodeZclHeader(ChipZclBuffer_t * buffer, ChipZclCommandContext_t * context)
Expand Down

0 comments on commit 8df05ef

Please sign in to comment.