Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
yunhanw-google committed Aug 24, 2023
1 parent 03e1cd3 commit a92b1a8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/controller/java/AndroidCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ namespace Controller {

static const int MILLIS_SINCE_BOOT = 0;
static const int MILLIS_SINCE_EPOCH = 1;
// Add the bytes for attribute tag(1:control + 8:tag + 8:length) and structure(1:struct + 1:close container)
static const int ADDITIONAL_BYTES_FOR_JSON_REPORT = 19

GetConnectedDeviceCallback::GetConnectedDeviceCallback(jobject wrapperCallback, jobject javaCallback) :
mOnSuccess(OnDeviceConnectedFn, this), mOnFailure(OnDeviceConnectionFailureFn, this)
Expand Down Expand Up @@ -230,8 +232,7 @@ CHIP_ERROR ConvertReportTlvToJson(const uint32_t id, TLV::TLVReader & data, std:
TLV::TLVReader readerForJavaTLV;
readerForJavaTLV.Init(*data);
uint32_t size = 0;
// Add the bytes for attribute tag(1:control + 8:tag + 8:length) and structure(1:struct + 1:close container)
size_t bufferLen = readerForJavaTLV.GetTotalLength() + 19;
size_t bufferLen = readerForJavaTLV.GetTotalLength() + ADDITIONAL_BYTES_FOR_JSON_REPORT;
std::unique_ptr<uint8_t[]> buffer = std::unique_ptr<uint8_t[]>(new uint8_t[bufferLen]);
writer.Init(buffer.get(), bufferLen);
TLV::TLVType outer;
Expand Down

0 comments on commit a92b1a8

Please sign in to comment.