Skip to content

Commit

Permalink
combine vendorID and profileID in StatusReport handling
Browse files Browse the repository at this point in the history
  • Loading branch information
holbrookt committed Feb 4, 2021
1 parent f949d49 commit 0892a79
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
13 changes: 5 additions & 8 deletions src/protocols/bdx/BdxTransferSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
#include <system/SystemPacketBuffer.h>

namespace {
constexpr uint8_t kBdxVersion = 0; ///< The version of this implementation of the BDX spec
constexpr size_t kStatusReportMinSize = 2 + 4 + 2; ///< 16 bits for GeneralCode, 32 bits for ProtocolId, 16 bits for ProtocolCode
constexpr uint16_t kStatusReportVendorId = 0;
constexpr uint8_t kBdxVersion = 0; ///< The version of this implementation of the BDX spec
constexpr size_t kStatusReportMinSize = 2 + 4 + 2; ///< 16 bits for GeneralCode, 32 bits for ProtocolId, 16 bits for ProtocolCode

/**
* @brief
Expand Down Expand Up @@ -509,11 +508,10 @@ CHIP_ERROR TransferSession::HandleStatusReportMessage(PayloadHeader & header, Sy
mAwaitingResponse = false;

uint16_t generalCode = 0;
uint16_t vendorId = 0;
uint16_t protocolId = 0;
uint32_t protocolId = 0;
uint16_t protocolCode = 0;
Encoding::LittleEndian::Reader reader(msg->Start(), msg->DataLength());
ReturnErrorOnFailure(reader.Read16(&generalCode).Read16(&vendorId).Read16(&protocolId).Read16(&protocolCode).StatusCode());
ReturnErrorOnFailure(reader.Read16(&generalCode).Read32(&protocolId).Read16(&protocolCode).StatusCode());
VerifyOrReturnError((protocolId == Protocols::kProtocol_BDX), CHIP_ERROR_INVALID_MESSAGE_TYPE);

mStatusReportData.StatusCode = protocolCode;
Expand Down Expand Up @@ -857,8 +855,7 @@ void TransferSession::PrepareStatusReport(StatusCode code)
VerifyOrReturn(!bbuf.IsNull());

bbuf.Put16(static_cast<uint16_t>(Protocols::Common::StatusCode::Failure));
bbuf.Put16(kStatusReportVendorId);
bbuf.Put16(Protocols::kProtocol_BDX);
bbuf.Put32(Protocols::kProtocol_BDX);
bbuf.Put16(mStatusReportData.StatusCode);

mPendingMsgHandle = bbuf.Finalize();
Expand Down
5 changes: 2 additions & 3 deletions src/protocols/bdx/tests/TestBdxTransferSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ void VerifyStatusReport(nlTestSuite * inSuite, void * inContext, const System::P
uint16_t headerSize = 0;
PayloadHeader payloadHeader;
uint16_t generalCode = 0;
uint16_t vendorId = 0;
uint16_t protocolId = 0;
uint32_t protocolId = 0;
uint16_t protocolCode = 0;

if (msg.IsNull())
Expand All @@ -132,7 +131,7 @@ void VerifyStatusReport(nlTestSuite * inSuite, void * inContext, const System::P
NL_TEST_ASSERT(inSuite, payloadHeader.GetMessageType() == static_cast<uint8_t>(Protocols::Common::MsgType::StatusReport));

Encoding::LittleEndian::Reader reader(msg->Start() + headerSize, msg->DataLength());
err = reader.Read16(&generalCode).Read16(&vendorId).Read16(&protocolId).Read16(&protocolCode).StatusCode();
err = reader.Read16(&generalCode).Read32(&protocolId).Read16(&protocolCode).StatusCode();
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);
NL_TEST_ASSERT(inSuite, generalCode == static_cast<uint16_t>(Protocols::Common::StatusCode::Failure));
NL_TEST_ASSERT(inSuite, protocolId == Protocols::kProtocol_BDX);
Expand Down

0 comments on commit 0892a79

Please sign in to comment.