DeactivatePodCommand.swift 933 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // DeactivatePodCommand.swift
  3. // OmniKit
  4. //
  5. // Created by Pete Schwamb on 2/24/18.
  6. // Copyright © 2018 Pete Schwamb. All rights reserved.
  7. //
  8. import Foundation
  9. public struct DeactivatePodCommand : NonceResyncableMessageBlock {
  10. // ID1:1f00ee84 PTYPE:PDM SEQ:09 ID2:1f00ee84 B9:34 BLEN:6 MTYPE:1c04 BODY:0f7dc4058344 CRC:f1
  11. public let blockType: MessageBlockType = .deactivatePod
  12. public var nonce: UInt32
  13. // e1f78752 07 8196
  14. public var data: Data {
  15. var data = Data([
  16. blockType.rawValue,
  17. 4,
  18. ])
  19. data.appendBigEndian(nonce)
  20. return data
  21. }
  22. public init(encodedData: Data) throws {
  23. if encodedData.count < 6 {
  24. throw MessageBlockError.notEnoughData
  25. }
  26. self.nonce = encodedData[2...].toBigEndian(UInt32.self)
  27. }
  28. public init(nonce: UInt32) {
  29. self.nonce = nonce
  30. }
  31. }