Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using MSEC_PER_SEC without directly including relevant headers. #33795

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/darwin/Framework/CHIP/MTRConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#import <Foundation/Foundation.h>

#include <chrono>
#include <lib/core/CASEAuthTag.h>
#include <lib/core/CHIPError.h>
#include <lib/core/Optional.h>
Expand All @@ -40,6 +41,12 @@ inline NSDate * MatterEpochSecondsAsDate(uint32_t matterEpochSeconds)
return [NSDate dateWithTimeIntervalSince1970:(chip::kChipEpochSecondsSinceUnixEpoch + (NSTimeInterval) matterEpochSeconds)];
}

template <typename Rep, typename Period>
inline NSTimeInterval DurationToTimeInterval(std::chrono::duration<Rep, Period> duration)
{
return std::chrono::duration<NSTimeInterval>(duration).count();
}

/**
* Returns whether the conversion could be performed. Will return false if the
* passed-in date is our of the range representable as a Matter epoch-s value.
Expand Down
3 changes: 2 additions & 1 deletion src/darwin/Framework/CHIP/MTRDeviceConnectionBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#import "MTRDeviceConnectionBridge.h"
#import "MTRBaseDevice_Internal.h"
#import "MTRConversion.h"
#import "MTRError_Internal.h"

void MTRDeviceConnectionBridge::OnConnected(
Expand All @@ -31,7 +32,7 @@
{
NSNumber * retryDelay;
if (failureInfo.requestedBusyDelay.HasValue()) {
retryDelay = @(static_cast<double>(failureInfo.requestedBusyDelay.Value().count()) / MSEC_PER_SEC);
retryDelay = @(DurationToTimeInterval(failureInfo.requestedBusyDelay.Value()));
}
auto * object = static_cast<MTRDeviceConnectionBridge *>(context);
object->mCompletionHandler(nil, chip::NullOptional, [MTRError errorForCHIPErrorCode:failureInfo.error], retryDelay);
Expand Down
Loading