From 0b58038723019cc6f362b06b9799bdb0e05a280d Mon Sep 17 00:00:00 2001 From: Pete Schwamb Date: Sat, 20 Aug 2016 23:03:29 -0500 Subject: [PATCH] Fix meal marker high bit parsing --- MinimedKit/PumpEvents/JournalEntryMealMarkerPumpEvent.swift | 2 +- MinimedKitTests/HistoryPageTests.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MinimedKit/PumpEvents/JournalEntryMealMarkerPumpEvent.swift b/MinimedKit/PumpEvents/JournalEntryMealMarkerPumpEvent.swift index 65208980e..8bde0b5ee 100644 --- a/MinimedKit/PumpEvents/JournalEntryMealMarkerPumpEvent.swift +++ b/MinimedKit/PumpEvents/JournalEntryMealMarkerPumpEvent.swift @@ -26,7 +26,7 @@ public struct JournalEntryMealMarkerPumpEvent: TimestampedPumpEvent { let useExchangesBit = ((availableData[8] as UInt8) >> 1) & 0b1 carbUnits = (useExchangesBit != 0) ? .Exchanges : .Grams - let carbHighBit = (availableData[8] as UInt8) & 0b1 + let carbHighBit = (availableData[1] as UInt8) & 0b1 let carbLowBits = availableData[7] as UInt8 if carbUnits == .Exchanges { diff --git a/MinimedKitTests/HistoryPageTests.swift b/MinimedKitTests/HistoryPageTests.swift index b7b64fb86..1b6ce6c2e 100644 --- a/MinimedKitTests/HistoryPageTests.swift +++ b/MinimedKitTests/HistoryPageTests.swift @@ -262,7 +262,7 @@ class HistoryPageTests: XCTestCase { let mealMarker = events[75] as! JournalEntryMealMarkerPumpEvent XCTAssertEqual(JournalEntryMealMarkerPumpEvent.CarbUnits.Grams, mealMarker.carbUnits) - XCTAssertEqual(268, mealMarker.carbohydrates) + XCTAssertEqual(12, mealMarker.carbohydrates) XCTAssertEqual(NSDateComponents(gregorianYear: 2016, month: 7, day: 11, hour: 5, minute: 9, second: 29), mealMarker.timestamp)