ReadCurrentGlucosePageMessageBody.swift 691 B

123456789101112131415161718192021222324252627282930
  1. //
  2. // ReadCurrentGlucosePageMessageBody.swift
  3. // RileyLink
  4. //
  5. // Created by Timothy Mecklem on 10/19/16.
  6. // Copyright © 2016 Pete Schwamb. All rights reserved.
  7. //
  8. import Foundation
  9. public class ReadCurrentGlucosePageMessageBody: CarelinkLongMessageBody {
  10. public let pageNum: UInt32
  11. public let glucose: Int
  12. public let isig: Int
  13. public required init?(rxData: Data) {
  14. guard rxData.count == type(of: self).length else {
  15. return nil
  16. }
  17. self.pageNum = rxData[1..<5
  18. ].toBigEndian(UInt32.self)
  19. self.glucose = Int(rxData[6])
  20. self.isig = Int(rxData[8])
  21. super.init(rxData: rxData)
  22. }
  23. }