SensorWeakSignalGlucoseEvent.swift 796 B

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // SensorWeakSignalGlucoseEvent.swift
  3. // RileyLink
  4. //
  5. // Created by Timothy Mecklem on 10/16/16.
  6. // Copyright © 2016 Pete Schwamb. All rights reserved.
  7. //
  8. import Foundation
  9. public struct SensorWeakSignalGlucoseEvent: RelativeTimestampedGlucoseEvent {
  10. public let length: Int
  11. public let rawData: Data
  12. public let timestamp: DateComponents
  13. public init?(availableData: Data, relativeTimestamp: DateComponents) {
  14. length = 1
  15. guard length <= availableData.count else {
  16. return nil
  17. }
  18. rawData = availableData.subdata(in: 0..<length)
  19. timestamp = relativeTimestamp
  20. }
  21. public var dictionaryRepresentation: [String: Any] {
  22. return [
  23. "name": "SensorWeakSignal",
  24. ]
  25. }
  26. }