Improve logging

This commit is contained in:
Christoph Hagen
2023-02-06 21:44:56 +01:00
parent 790662a1ec
commit b3c58ce4c7
5 changed files with 19 additions and 13 deletions

View File

@ -54,13 +54,13 @@ struct DeviceResponse {
the remaining bytes contain the message.
- Parameter buffer: The buffer where the message bytes are stored
*/
init?(_ buffer: ByteBuffer) {
init?(_ buffer: ByteBuffer, request: String) {
guard let byte = buffer.getBytes(at: 0, length: 1) else {
print("No bytes received from device")
log("\(request): No bytes received from device")
return nil
}
guard let event = MessageResult(rawValue: byte[0]) else {
print("Unknown response \(byte[0]) received from device")
log("\(request): Unknown response \(byte[0]) received from device")
return nil
}
self.event = event