import Foundation /** A result from sending a key to the device. */ enum KeyResult: UInt8 { /// No result from the device, or state not applicable case none = 0 /// Text content was received, although binary data was expected case textReceived = 1 /// A socket event on the device was unexpected (not binary data) case unexpectedSocketEvent = 2 /// The size of the payload (key id + key data) was invalid case invalidPayloadSize = 3 /// The index of the key was out of bounds case invalidKeyIndex = 4 /// The transmitted key data did not match the expected key case invalidKey = 5 /// The key has been previously used and is no longer valid case keyAlreadyUsed = 6 /// A later key has been used, invalidating this key (to prevent replay attacks after blocked communication) case keyWasSkipped = 7 /// The key was accepted by the device, and the door will be opened case keyAccepted = 8 /// The device produced an unknown error case uknownDeviceError = 9 /// The device is not connected through the socket case notConnected = 10 } /** A response from the server to a key request. */ enum KeyPostResponse: Int { /// The key will be transmitted to the device case success = 0 /// The key id is out of bounds or otherwise invalid case invalidKeyId = 1 /// The request did not contain body data with the key case noBodyData = 2 /// The key contained in the body data has an invalid size case invalidKeySize = 3 /// The body data could not be read case corruptkeyData = 4 /// The device is not connected case deviceNotConnected = 5 }