diff --git a/examples/ota-provider-app/linux/main.cpp b/examples/ota-provider-app/linux/main.cpp index d125e4312452e8..f4cf840025523e 100644 --- a/examples/ota-provider-app/linux/main.cpp +++ b/examples/ota-provider-app/linux/main.cpp @@ -54,9 +54,9 @@ constexpr uint16_t kOptionQueryImageBehavior = 'q'; constexpr uint16_t kOptionDelayedActionTimeSec = 'd'; // Arbitrary BDX Transfer Params -constexpr uint32_t kMaxBdxBlockSize = 1024; -constexpr uint32_t kBdxTimeoutMs = 5 * 60 * 1000; // OTA Spec mandates >= 5 minutes -constexpr uint32_t kBdxPollFreqMs = 500; +constexpr uint32_t kMaxBdxBlockSize = 1024; +constexpr chip::System::Clock::Timeout kBdxTimeout = chip::System::Clock::Seconds16(5 * 60); // OTA Spec mandates >= 5 minutes +constexpr chip::System::Clock::Timeout kBdxPollFreq = chip::System::Clock::Milliseconds32(500); // Global variables used for passing the CLI arguments to the OTAProviderExample object OTAProviderExample::queryImageBehaviorType gQueryImageBehavior = OTAProviderExample::kRespondWithUpdateAvailable; @@ -188,7 +188,7 @@ int main(int argc, char * argv[]) BitFlags bdxFlags; bdxFlags.Set(TransferControlFlags::kReceiverDrive); err = bdxServer.PrepareForTransfer(&chip::DeviceLayer::SystemLayer(), chip::bdx::TransferRole::kSender, bdxFlags, - kMaxBdxBlockSize, kBdxTimeoutMs, kBdxPollFreqMs); + kMaxBdxBlockSize, kBdxTimeout, kBdxPollFreq); if (err != CHIP_NO_ERROR) { ChipLogError(BDX, "failed to init BDX server: %s", chip::ErrorStr(err)); diff --git a/examples/ota-requestor-app/linux/main.cpp b/examples/ota-requestor-app/linux/main.cpp index c4f9e6985a65e0..857294fa859294 100644 --- a/examples/ota-requestor-app/linux/main.cpp +++ b/examples/ota-requestor-app/linux/main.cpp @@ -97,7 +97,8 @@ void OnQueryImageResponse(void * context, uint8_t status, uint32_t delayedAction bdxDownloader.SetInitialExchange(exchangeCtx); // This will kick of a timer which will regularly check for updates to the bdx::TransferSession state machine. - bdxDownloader.InitiateTransfer(&chip::DeviceLayer::SystemLayer(), chip::bdx::TransferRole::kReceiver, initOptions, 20000); + bdxDownloader.InitiateTransfer(&chip::DeviceLayer::SystemLayer(), chip::bdx::TransferRole::kReceiver, initOptions, + chip::System::Clock::Seconds16(20)); } void OnQueryFailure(void * context, uint8_t status) diff --git a/src/protocols/bdx/BdxTransferSession.cpp b/src/protocols/bdx/BdxTransferSession.cpp index d7d168168135ce..a4b17ec736a848 100644 --- a/src/protocols/bdx/BdxTransferSession.cpp +++ b/src/protocols/bdx/BdxTransferSession.cpp @@ -64,17 +64,17 @@ TransferSession::TransferSession() mSuppportedXferOpts.ClearAll(); } -void TransferSession::PollOutput(OutputEvent & event, uint64_t curTimeMs) +void TransferSession::PollOutput(OutputEvent & event, System::Clock::Timestamp curTime) { event = OutputEvent(OutputEventType::kNone); if (mShouldInitTimeoutStart) { - mTimeoutStartTimeMs = curTimeMs; + mTimeoutStartTime = curTime; mShouldInitTimeoutStart = false; } - if (mAwaitingResponse && ((curTimeMs - mTimeoutStartTimeMs) >= mTimeoutMs)) + if (mAwaitingResponse && ((curTime - mTimeoutStartTime) >= mTimeout)) { event = OutputEvent(OutputEventType::kTransferTimeout); mState = TransferState::kErrorState; @@ -94,8 +94,8 @@ void TransferSession::PollOutput(OutputEvent & event, uint64_t curTimeMs) event = OutputEvent::StatusReportEvent(OutputEventType::kStatusReceived, mStatusReportData); break; case OutputEventType::kMsgToSend: - event = OutputEvent::MsgToSendEvent(mMsgTypeData, std::move(mPendingMsgHandle)); - mTimeoutStartTimeMs = curTimeMs; + event = OutputEvent::MsgToSendEvent(mMsgTypeData, std::move(mPendingMsgHandle)); + mTimeoutStartTime = curTime; break; case OutputEventType::kInitReceived: event = OutputEvent::TransferInitEvent(mTransferRequestData, std::move(mPendingMsgHandle)); @@ -131,12 +131,12 @@ void TransferSession::PollOutput(OutputEvent & event, uint64_t curTimeMs) mPendingOutput = OutputEventType::kNone; } -CHIP_ERROR TransferSession::StartTransfer(TransferRole role, const TransferInitData & initData, uint32_t timeoutMs) +CHIP_ERROR TransferSession::StartTransfer(TransferRole role, const TransferInitData & initData, System::Clock::Timeout timeout) { VerifyOrReturnError(mState == TransferState::kUnitialized, CHIP_ERROR_INCORRECT_STATE); - mRole = role; - mTimeoutMs = timeoutMs; + mRole = role; + mTimeout = timeout; // Set transfer parameters. They may be overridden later by an Accept message mSuppportedXferOpts = initData.TransferCtlFlags; @@ -169,13 +169,13 @@ CHIP_ERROR TransferSession::StartTransfer(TransferRole role, const TransferInitD } CHIP_ERROR TransferSession::WaitForTransfer(TransferRole role, BitFlags xferControlOpts, - uint16_t maxBlockSize, uint32_t timeoutMs) + uint16_t maxBlockSize, System::Clock::Timeout timeout) { VerifyOrReturnError(mState == TransferState::kUnitialized, CHIP_ERROR_INCORRECT_STATE); // Used to determine compatibility with any future TransferInit parameters mRole = role; - mTimeoutMs = timeoutMs; + mTimeout = timeout; mSuppportedXferOpts = xferControlOpts; mMaxSupportedBlockSize = maxBlockSize; @@ -361,14 +361,14 @@ void TransferSession::Reset() mLastQueryNum = 0; mNextQueryNum = 0; - mTimeoutMs = 0; - mTimeoutStartTimeMs = 0; + mTimeout = System::Clock::Zero; + mTimeoutStartTime = System::Clock::Zero; mShouldInitTimeoutStart = true; mAwaitingResponse = false; } CHIP_ERROR TransferSession::HandleMessageReceived(const PayloadHeader & payloadHeader, System::PacketBufferHandle msg, - uint64_t curTimeMs) + System::Clock::Timestamp curTime) { VerifyOrReturnError(!msg.IsNull(), CHIP_ERROR_INVALID_ARGUMENT); @@ -376,7 +376,7 @@ CHIP_ERROR TransferSession::HandleMessageReceived(const PayloadHeader & payloadH { ReturnErrorOnFailure(HandleBdxMessage(payloadHeader, std::move(msg))); - mTimeoutStartTimeMs = curTimeMs; + mTimeoutStartTime = curTime; } else if (payloadHeader.HasMessageType(Protocols::SecureChannel::MsgType::StatusReport)) { diff --git a/src/protocols/bdx/BdxTransferSession.h b/src/protocols/bdx/BdxTransferSession.h index fb92289380ea1e..628a7d3e7aadc1 100644 --- a/src/protocols/bdx/BdxTransferSession.h +++ b/src/protocols/bdx/BdxTransferSession.h @@ -144,14 +144,14 @@ class DLL_EXPORT TransferSession * TransferSession object. * * Note that if the type outputted is kMsgToSend, the caller is expected to send the message immediately, and the session - * timeout timer will begin at curTimeMs. + * timeout timer will begin at curTime. * * See OutputEventType for all possible output event types. * * @param event Reference to an OutputEvent struct that will be filled out with any pending output data - * @param curTimeMs Current time indicated by the number of milliseconds since some epoch defined by the platform + * @param curTime Current time */ - void PollOutput(OutputEvent & event, uint64_t curTimeMs); + void PollOutput(OutputEvent & event, System::Clock::Timestamp curTime); /** * @brief @@ -162,13 +162,13 @@ class DLL_EXPORT TransferSession * @param role Inidcates whether this object will be sending or receiving data * @param initData Data for initializing this object and for populating a TransferInit message * The role parameter will determine whether to populate a ReceiveInit or SendInit - * @param timeoutMs The amount of time to wait for a response before considering the transfer failed (milliseconds) - * @param curTimeMs The current time since epoch in milliseconds. Needed to set a start time for the transfer timeout. + * @param timeout The amount of time to wait for a response before considering the transfer failed + * @param curTime The current time since epoch. Needed to set a start time for the transfer timeout. * * @return CHIP_ERROR Result of initialization and preparation of a TransferInit message. May also indicate if the * TransferSession object is unable to handle this request. */ - CHIP_ERROR StartTransfer(TransferRole role, const TransferInitData & initData, uint32_t timeoutMs); + CHIP_ERROR StartTransfer(TransferRole role, const TransferInitData & initData, System::Clock::Timeout timeout); /** * @brief @@ -179,13 +179,13 @@ class DLL_EXPORT TransferSession * @param role Inidcates whether this object will be sending or receiving data * @param xferControlOpts Indicates all supported control modes. Used to respond to a TransferInit message * @param maxBlockSize The max Block size that this object supports. - * @param timeoutMs The amount of time to wait for a response before considering the transfer failed (milliseconds) + * @param timeout The amount of time to wait for a response before considering the transfer failed * * @return CHIP_ERROR Result of initialization. May also indicate if the TransferSession object is unable to handle this * request. */ CHIP_ERROR WaitForTransfer(TransferRole role, BitFlags xferControlOpts, uint16_t maxBlockSize, - uint32_t timeoutMs); + System::Clock::Timeout timeout); /** * @brief @@ -263,12 +263,13 @@ class DLL_EXPORT TransferSession * @param payloadHeader A PayloadHeader containing the Protocol type and Message Type * @param msg A PacketBufferHandle pointing to the message buffer to process. May be BDX or StatusReport protocol. * Buffer is expected to start at data (not header). - * @param curTimeMs Current time indicated by the number of milliseconds since some epoch defined by the platform + * @param curTime Current time * * @return CHIP_ERROR Indicates any problems in decoding the message, or if the message is not of the BDX or StatusReport * protocols. */ - CHIP_ERROR HandleMessageReceived(const PayloadHeader & payloadHeader, System::PacketBufferHandle msg, uint64_t curTimeMs); + CHIP_ERROR HandleMessageReceived(const PayloadHeader & payloadHeader, System::PacketBufferHandle msg, + System::Clock::Timestamp curTime); TransferControlFlags GetControlMode() const { return mControlMode; } uint64_t GetStartOffset() const { return mStartOffset; } @@ -349,8 +350,8 @@ class DLL_EXPORT TransferSession uint32_t mLastQueryNum = 0; uint32_t mNextQueryNum = 0; - uint32_t mTimeoutMs = 0; - uint64_t mTimeoutStartTimeMs = 0; + System::Clock::Timeout mTimeout{ 0 }; + System::Clock::Timestamp mTimeoutStartTime{ 0 }; bool mShouldInitTimeoutStart = true; bool mAwaitingResponse = false; }; diff --git a/src/protocols/bdx/TransferFacilitator.cpp b/src/protocols/bdx/TransferFacilitator.cpp index 98ff832089c39e..5a9ce8ef66b92f 100644 --- a/src/protocols/bdx/TransferFacilitator.cpp +++ b/src/protocols/bdx/TransferFacilitator.cpp @@ -29,6 +29,9 @@ namespace chip { namespace bdx { +constexpr System::Clock::Timeout TransferFacilitator::kDefaultPollFreq; +constexpr System::Clock::Timeout TransferFacilitator::kImmediatePollDelay; + CHIP_ERROR TransferFacilitator::OnMessageReceived(chip::Messaging::ExchangeContext * ec, const chip::PayloadHeader & payloadHeader, chip::System::PacketBufferHandle && payload) { @@ -40,7 +43,7 @@ CHIP_ERROR TransferFacilitator::OnMessageReceived(chip::Messaging::ExchangeConte ChipLogDetail(BDX, "%s: message " ChipLogFormatMessageType " protocol " ChipLogFormatProtocolId, __FUNCTION__, payloadHeader.GetMessageType(), ChipLogValueProtocolId(payloadHeader.GetProtocolID())); CHIP_ERROR err = - mTransfer.HandleMessageReceived(payloadHeader, std::move(payload), System::SystemClock().GetMonotonicMilliseconds()); + mTransfer.HandleMessageReceived(payloadHeader, std::move(payload), System::SystemClock().GetMonotonicTimestamp()); if (err != CHIP_NO_ERROR) { ChipLogError(BDX, "failed to handle message: %s", ErrorStr(err)); @@ -71,44 +74,44 @@ void TransferFacilitator::PollTimerHandler(chip::System::Layer * systemLayer, vo void TransferFacilitator::PollForOutput() { TransferSession::OutputEvent outEvent; - mTransfer.PollOutput(outEvent, System::SystemClock().GetMonotonicMilliseconds()); + mTransfer.PollOutput(outEvent, System::SystemClock().GetMonotonicTimestamp()); HandleTransferSessionOutput(outEvent); VerifyOrReturn(mSystemLayer != nullptr, ChipLogError(BDX, "%s mSystemLayer is null", __FUNCTION__)); - mSystemLayer->StartTimer(System::Clock::Milliseconds32(mPollFreqMs), PollTimerHandler, this); + mSystemLayer->StartTimer(mPollFreq, PollTimerHandler, this); } void TransferFacilitator::ScheduleImmediatePoll() { VerifyOrReturn(mSystemLayer != nullptr, ChipLogError(BDX, "%s mSystemLayer is null", __FUNCTION__)); - mSystemLayer->StartTimer(System::Clock::Milliseconds32(kImmediatePollDelayMs), PollTimerHandler, this); + mSystemLayer->StartTimer(System::Clock::Milliseconds32(kImmediatePollDelay), PollTimerHandler, this); } CHIP_ERROR Responder::PrepareForTransfer(System::Layer * layer, TransferRole role, BitFlags xferControlOpts, - uint16_t maxBlockSize, uint32_t timeoutMs, uint32_t pollFreqMs) + uint16_t maxBlockSize, System::Clock::Timeout timeout, System::Clock::Timeout pollFreq) { VerifyOrReturnError(layer != nullptr, CHIP_ERROR_INVALID_ARGUMENT); - mPollFreqMs = pollFreqMs; + mPollFreq = pollFreq; mSystemLayer = layer; - ReturnErrorOnFailure(mTransfer.WaitForTransfer(role, xferControlOpts, maxBlockSize, timeoutMs)); + ReturnErrorOnFailure(mTransfer.WaitForTransfer(role, xferControlOpts, maxBlockSize, timeout)); - mSystemLayer->StartTimer(System::Clock::Milliseconds32(mPollFreqMs), PollTimerHandler, this); + mSystemLayer->StartTimer(mPollFreq, PollTimerHandler, this); return CHIP_NO_ERROR; } CHIP_ERROR Initiator::InitiateTransfer(System::Layer * layer, TransferRole role, const TransferSession::TransferInitData & initData, - uint32_t timeoutMs, uint32_t pollFreqMs) + System::Clock::Timeout timeout, System::Clock::Timeout pollFreq) { VerifyOrReturnError(layer != nullptr, CHIP_ERROR_INVALID_ARGUMENT); - mPollFreqMs = pollFreqMs; + mPollFreq = pollFreq; mSystemLayer = layer; - ReturnErrorOnFailure(mTransfer.StartTransfer(role, initData, timeoutMs)); + ReturnErrorOnFailure(mTransfer.StartTransfer(role, initData, timeout)); - mSystemLayer->StartTimer(System::Clock::Milliseconds32(mPollFreqMs), PollTimerHandler, this); + mSystemLayer->StartTimer(mPollFreq, PollTimerHandler, this); return CHIP_NO_ERROR; } diff --git a/src/protocols/bdx/TransferFacilitator.h b/src/protocols/bdx/TransferFacilitator.h index ec043cb935807a..40f606d3524881 100644 --- a/src/protocols/bdx/TransferFacilitator.h +++ b/src/protocols/bdx/TransferFacilitator.h @@ -44,7 +44,7 @@ namespace bdx { class TransferFacilitator : public Messaging::ExchangeDelegate { public: - TransferFacilitator() : mExchangeCtx(nullptr), mSystemLayer(nullptr), mPollFreqMs(kDefaultPollFreqMs) {} + TransferFacilitator() : mExchangeCtx(nullptr), mSystemLayer(nullptr), mPollFreq(kDefaultPollFreq) {} ~TransferFacilitator() = default; private: @@ -82,9 +82,9 @@ class TransferFacilitator : public Messaging::ExchangeDelegate TransferSession mTransfer; Messaging::ExchangeContext * mExchangeCtx; System::Layer * mSystemLayer; - uint32_t mPollFreqMs; - static constexpr uint32_t kDefaultPollFreqMs = 500; - static constexpr uint32_t kImmediatePollDelayMs = 1; + System::Clock::Timeout mPollFreq; + static constexpr System::Clock::Timeout kDefaultPollFreq = System::Clock::Milliseconds32(500); + static constexpr System::Clock::Timeout kImmediatePollDelay = System::Clock::Milliseconds32(1); }; /** @@ -103,12 +103,12 @@ class Responder : public TransferFacilitator * @param[in] role The role of the Responder: Sender or Receiver of BDX data * @param[in] xferControlOpts Supported transfer modes (see TransferControlFlags) * @param[in] maxBlockSize The supported maximum size of BDX Block data - * @param[in] timeoutMs The chosen timeout delay for the BDX transfer in milliseconds - * @param[in] pollFreqMs The period for the TransferSession poll timer in milliseconds + * @param[in] timeout The chosen timeout delay for the BDX transfer + * @param[in] pollFreq The period for the TransferSession poll timer */ CHIP_ERROR PrepareForTransfer(System::Layer * layer, TransferRole role, BitFlags xferControlOpts, - uint16_t maxBlockSize, uint32_t timeoutMs, - uint32_t pollFreqMs = TransferFacilitator::kDefaultPollFreqMs); + uint16_t maxBlockSize, System::Clock::Timeout timeout, + System::Clock::Timeout pollFreq = TransferFacilitator::kDefaultPollFreq); }; /** @@ -131,7 +131,8 @@ class Initiator : public TransferFacilitator * @param[in] pollFreqMs The period for the TransferSession poll timer in milliseconds */ CHIP_ERROR InitiateTransfer(System::Layer * layer, TransferRole role, const TransferSession::TransferInitData & initData, - uint32_t timeoutMs, uint32_t pollFreqMs = TransferFacilitator::kDefaultPollFreqMs); + System::Clock::Timeout timeout, + System::Clock::Timeout pollFreq = TransferFacilitator::kDefaultPollFreq); }; } // namespace bdx diff --git a/src/protocols/bdx/tests/TestBdxTransferSession.cpp b/src/protocols/bdx/tests/TestBdxTransferSession.cpp index 9cf9557c85cd4a..249b646596c0c2 100644 --- a/src/protocols/bdx/tests/TestBdxTransferSession.cpp +++ b/src/protocols/bdx/tests/TestBdxTransferSession.cpp @@ -21,7 +21,7 @@ using namespace ::chip::Protocols; namespace { // Use this as a timestamp if not needing to test BDX timeouts. -constexpr uint64_t kNoAdvanceTime = 0; +constexpr System::Clock::Timestamp kNoAdvanceTime{ 0 }; const TLV::Tag tlvStrTag = TLV::ContextTag(4); const TLV::Tag tlvListTag = TLV::ProfileTag(7777, 8888); @@ -137,22 +137,22 @@ void VerifyNoMoreOutput(nlTestSuite * inSuite, void * inContext, TransferSession // Helper method for initializing two TransferSession objects, generating a TransferInit message, and passing it to a responding // TransferSession. -void SendAndVerifyTransferInit(nlTestSuite * inSuite, void * inContext, TransferSession::OutputEvent & outEvent, uint32_t timeoutMs, - TransferSession & initiator, TransferRole initiatorRole, TransferSession::TransferInitData initData, - TransferSession & responder, BitFlags & responderControlOpts, - uint16_t responderMaxBlock) +void SendAndVerifyTransferInit(nlTestSuite * inSuite, void * inContext, TransferSession::OutputEvent & outEvent, + System::Clock::Timeout timeout, TransferSession & initiator, TransferRole initiatorRole, + TransferSession::TransferInitData initData, TransferSession & responder, + BitFlags & responderControlOpts, uint16_t responderMaxBlock) { CHIP_ERROR err = CHIP_NO_ERROR; TransferRole responderRole = (initiatorRole == TransferRole::kSender) ? TransferRole::kReceiver : TransferRole::kSender; MessageType expectedInitMsg = (initiatorRole == TransferRole::kSender) ? MessageType::SendInit : MessageType::ReceiveInit; // Initializer responder to wait for transfer - err = responder.WaitForTransfer(responderRole, responderControlOpts, responderMaxBlock, timeoutMs); + err = responder.WaitForTransfer(responderRole, responderControlOpts, responderMaxBlock, timeout); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); VerifyNoMoreOutput(inSuite, inContext, responder); // Verify initiator outputs respective Init message (depending on role) after StartTransfer() - err = initiator.StartTransfer(initiatorRole, initData, timeoutMs); + err = initiator.StartTransfer(initiatorRole, initData, timeout); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); initiator.PollOutput(outEvent, kNoAdvanceTime); NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kMsgToSend); @@ -357,12 +357,12 @@ void TestInitiatingReceiverReceiverDrive(nlTestSuite * inSuite, void * inContext uint32_t numBlocksSent = 0; // Chosen arbitrarily for this test - uint32_t numBlockSends = 10; - uint16_t proposedBlockSize = 128; - uint16_t testSmallerBlockSize = 64; - uint64_t proposedOffset = 64; - uint64_t proposedLength = 0; - uint32_t timeoutMs = 1000 * 24; + uint32_t numBlockSends = 10; + uint16_t proposedBlockSize = 128; + uint16_t testSmallerBlockSize = 64; + uint64_t proposedOffset = 64; + uint64_t proposedLength = 0; + System::Clock::Timeout timeout = System::Clock::Seconds16(24); // Chosen specifically for this test TransferControlFlags driveMode = TransferControlFlags::kReceiverDrive; @@ -379,7 +379,7 @@ void TestInitiatingReceiverReceiverDrive(nlTestSuite * inSuite, void * inContext BitFlags senderOpts; senderOpts.Set(driveMode); - SendAndVerifyTransferInit(inSuite, inContext, outEvent, timeoutMs, initiatingReceiver, TransferRole::kReceiver, initOptions, + SendAndVerifyTransferInit(inSuite, inContext, outEvent, timeout, initiatingReceiver, TransferRole::kReceiver, initOptions, respondingSender, senderOpts, proposedBlockSize); // Test metadata for Accept message @@ -462,8 +462,8 @@ void TestInitiatingSenderSenderDrive(nlTestSuite * inSuite, void * inContext) TransferControlFlags driveMode = TransferControlFlags::kSenderDrive; // Chosen arbitrarily for this test - uint16_t transferBlockSize = 10; - uint32_t timeoutMs = 1000 * 24; + uint16_t transferBlockSize = 10; + System::Clock::Timeout timeout = System::Clock::Seconds16(24); // Initialize respondingReceiver BitFlags receiverOpts; @@ -487,7 +487,7 @@ void TestInitiatingSenderSenderDrive(nlTestSuite * inSuite, void * inContext) initOptions.Metadata = tlvBuf; initOptions.MetadataLength = metadataSize; - SendAndVerifyTransferInit(inSuite, inContext, outEvent, timeoutMs, initiatingSender, TransferRole::kSender, initOptions, + SendAndVerifyTransferInit(inSuite, inContext, outEvent, timeout, initiatingSender, TransferRole::kSender, initOptions, respondingReceiver, receiverOpts, transferBlockSize); // Verify parsed TLV metadata matches the original @@ -532,7 +532,7 @@ void TestBadAcceptMessageFields(nlTestSuite * inSuite, void * inContext) TransferControlFlags driveMode = TransferControlFlags::kReceiverDrive; uint64_t commonLength = 0; uint64_t commonOffset = 0; - uint32_t timeoutMs = 1000 * 24; + System::Clock::Timeout timeout = System::Clock::Seconds16(24); // Initialize struct with TransferInit parameters TransferSession::TransferInitData initOptions; @@ -550,7 +550,7 @@ void TestBadAcceptMessageFields(nlTestSuite * inSuite, void * inContext) BitFlags responderControl; responderControl.Set(driveMode); - SendAndVerifyTransferInit(inSuite, inContext, outEvent, timeoutMs, initiatingReceiver, TransferRole::kReceiver, initOptions, + SendAndVerifyTransferInit(inSuite, inContext, outEvent, timeout, initiatingReceiver, TransferRole::kReceiver, initOptions, respondingSender, responderControl, maxBlockSize); // Verify AcceptTransfer() returns error for choosing larger max block size @@ -580,9 +580,9 @@ void TestTimeout(nlTestSuite * inSuite, void * inContext) TransferSession initiator; TransferSession::OutputEvent outEvent; - uint32_t timeoutMs = 24; - uint64_t startTimeMs = 100; - uint64_t endTimeMs = 124; + System::Clock::Timeout timeout = System::Clock::Milliseconds32(24); + System::Clock::Timestamp startTime = System::Clock::Milliseconds64(100); + System::Clock::Timestamp endTime = System::Clock::Milliseconds64(124); // Initialize struct with arbitrary TransferInit parameters TransferSession::TransferInitData initOptions; @@ -599,17 +599,17 @@ void TestTimeout(nlTestSuite * inSuite, void * inContext) TransferRole role = TransferRole::kReceiver; // Verify initiator outputs respective Init message (depending on role) after StartTransfer() - err = initiator.StartTransfer(role, initOptions, timeoutMs); + err = initiator.StartTransfer(role, initOptions, timeout); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); // First PollOutput() should output the TransferInit message - initiator.PollOutput(outEvent, startTimeMs); + initiator.PollOutput(outEvent, startTime); NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kMsgToSend); MessageType expectedInitMsg = (role == TransferRole::kSender) ? MessageType::SendInit : MessageType::ReceiveInit; VerifyBdxMessageToSend(inSuite, inContext, outEvent, expectedInitMsg); // Second PollOutput() with no call to HandleMessageReceived() should result in a timeout. - initiator.PollOutput(outEvent, endTimeMs); + initiator.PollOutput(outEvent, endTime); NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kTransferTimeout); } @@ -628,9 +628,9 @@ void TestDuplicateBlockError(nlTestSuite * inSuite, void * inContext) uint16_t blockSize = sizeof(fakeData); // Chosen arbitrarily for this test - uint64_t proposedOffset = 64; - uint64_t proposedLength = 0; - uint32_t timeoutMs = 1000 * 24; + uint64_t proposedOffset = 64; + uint64_t proposedLength = 0; + System::Clock::Timeout timeout = System::Clock::Seconds16(24); // Chosen specifically for this test TransferControlFlags driveMode = TransferControlFlags::kReceiverDrive; @@ -647,7 +647,7 @@ void TestDuplicateBlockError(nlTestSuite * inSuite, void * inContext) BitFlags senderOpts; senderOpts.Set(driveMode); - SendAndVerifyTransferInit(inSuite, inContext, outEvent, timeoutMs, initiatingReceiver, TransferRole::kReceiver, initOptions, + SendAndVerifyTransferInit(inSuite, inContext, outEvent, timeout, initiatingReceiver, TransferRole::kReceiver, initOptions, respondingSender, senderOpts, blockSize); // Compose ReceiveAccept parameters struct and give to respondingSender