Skip to content

Commit

Permalink
#161 Add DataConvertible conformance to GATTDateTime
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Nov 8, 2024
1 parent 534c8b1 commit 8cc76a6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Sources/BluetoothGATT/GATTDateTime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ public struct GATTDateTime: GATTCharacteristic, Equatable, Hashable, Sendable {
self.minute = minute
self.second = second
}
}

// MARK: - DataConvertible

extension GATTDateTime: DataConvertible {

internal static var length: Int { 7 }
public static var length: Int { 7 }

public init?<Data: DataContainer>(data: Data) {

Expand All @@ -78,6 +83,10 @@ public struct GATTDateTime: GATTCharacteristic, Equatable, Hashable, Sendable {
data += minute.rawValue
data += second.rawValue
}

public var dataLength: Int {
Self.length
}
}

#if canImport(Foundation)
Expand Down

0 comments on commit 8cc76a6

Please sign in to comment.