-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1fcebe0
commit b92ffcb
Showing
13 changed files
with
123 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// | ||
// HCICommandTimeout.swift | ||
// Bluetooth | ||
// | ||
// Created by Alsey Coleman Miller on 3/31/18. | ||
// Copyright © 2018 PureSwift. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
/// The duration of an HCI command. | ||
public struct HCICommandTimeout: RawRepresentable { | ||
|
||
/// The duration of the timeout in miliseconds. | ||
public var rawValue: UInt | ||
|
||
public init(rawValue: UInt) { | ||
self.rawValue = rawValue | ||
} | ||
|
||
/// Default timeout of HCI commands in miliseconds. | ||
public static let `default`: HCICommandTimeout = 1000 | ||
} | ||
|
||
public extension HCICommandTimeout { | ||
|
||
/// Duration in seconds. | ||
var duration: TimeInterval { | ||
|
||
return TimeInterval(rawValue) / 1000.0 | ||
} | ||
} | ||
|
||
// MARK: - ExpressibleByIntegerLiteral | ||
|
||
extension HCICommandTimeout: ExpressibleByIntegerLiteral { | ||
|
||
public init(integerLiteral value: UInt) { | ||
|
||
self.rawValue = value | ||
} | ||
} | ||
|
||
// MARK: - Equatable | ||
|
||
extension HCICommandTimeout: Equatable { | ||
|
||
public static func == (lhs: HCICommandTimeout, rhs: HCICommandTimeout) -> Bool { | ||
|
||
return lhs.rawValue == rhs.rawValue | ||
} | ||
} | ||
|
||
// MARK: - Hashable | ||
|
||
extension HCICommandTimeout: Hashable { | ||
|
||
public var hashValue: Int { | ||
|
||
return rawValue.hashValue | ||
} | ||
} | ||
|
||
// MARK: - CustomStringConvertible | ||
|
||
extension HCICommandTimeout: CustomStringConvertible { | ||
|
||
public var description: String { | ||
|
||
return "\(duration) seconds" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.