Skip to content

Commit

Permalink
Upgrade to SpeziNetworking 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Supereg committed Jun 13, 2024
1 parent add69bb commit c54b3f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ let package = Package(
.library(name: "SpeziOmron", targets: ["SpeziOmron"])
],
dependencies: [
.package(url: "https://github.com/StanfordSpezi/SpeziBluetooth", branch: "main"),
.package(url: "https://github.com/StanfordSpezi/SpeziNetworking", from: "1.0.0")
.package(url: "https://github.com/StanfordSpezi/SpeziBluetooth", branch: "feature/accessory-discovery"),
.package(url: "https://github.com/StanfordSpezi/SpeziNetworking", from: "2.0.0")
],
targets: [
.target(
Expand Down
21 changes: 10 additions & 11 deletions Sources/SpeziOmron/Characteristic/OmronRecordAccessOperand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,38 +44,37 @@ extension OmronRecordAccessOperand: RecordAccessOperand {

public init?( // swiftlint:disable:this cyclomatic_complexity
from byteBuffer: inout ByteBuffer,
preferredEndianness endianness: Endianness,
opCode: RecordAccessOpCode,
operator: RecordAccessOperator
) {
switch opCode {
case .responseCode:
guard let response = RecordAccessGeneralResponse(from: &byteBuffer, preferredEndianness: endianness) else {
guard let response = RecordAccessGeneralResponse(from: &byteBuffer) else {
return nil
}
self = .generalResponse(response)
case .reportStoredRecords, .deleteStoredRecords, .reportNumberOfStoredRecords:
switch `operator` {
case .lessThanOrEqualTo, .greaterThanOrEqual:
guard let filterCriteria = RecordAccessFilterCriteria(from: &byteBuffer, preferredEndianness: endianness) else {
guard let filterCriteria = RecordAccessFilterCriteria(from: &byteBuffer) else {
return nil
}
self = .filterCriteria(filterCriteria)
case .withinInclusiveRangeOf:
guard let filterCriteria = RecordAccessRangeFilterCriteria(from: &byteBuffer, preferredEndianness: endianness) else {
guard let filterCriteria = RecordAccessRangeFilterCriteria(from: &byteBuffer) else {
return nil
}
self = .rangeFilterCriteria(filterCriteria)
default:
return nil
}
case .numberOfStoredRecordsResponse:
guard let count = UInt16(from: &byteBuffer, preferredEndianness: endianness) else {
guard let count = UInt16(from: &byteBuffer) else {
return nil
}
self = .numberOfRecords(count)
case .omronSequenceNumberOfLatestRecordsResponse:
guard let sequenceNumber = UInt16(from: &byteBuffer, preferredEndianness: endianness) else {
guard let sequenceNumber = UInt16(from: &byteBuffer) else {
return nil
}
self = .sequenceNumber(sequenceNumber)
Expand All @@ -84,16 +83,16 @@ extension OmronRecordAccessOperand: RecordAccessOperand {
}
}

public func encode(to byteBuffer: inout ByteBuffer, preferredEndianness endianness: Endianness) {
public func encode(to byteBuffer: inout ByteBuffer) {
switch self {
case let .generalResponse(response):
response.encode(to: &byteBuffer, preferredEndianness: endianness)
response.encode(to: &byteBuffer)
case let .filterCriteria(criteria):
criteria.encode(to: &byteBuffer, preferredEndianness: endianness)
criteria.encode(to: &byteBuffer)
case let .rangeFilterCriteria(criteria):
criteria.encode(to: &byteBuffer, preferredEndianness: endianness)
criteria.encode(to: &byteBuffer)
case let .numberOfRecords(value), let .sequenceNumber(value):
value.encode(to: &byteBuffer, preferredEndianness: endianness)
value.encode(to: &byteBuffer)
}
}
}

0 comments on commit c54b3f4

Please sign in to comment.