Skip to content

Commit

Permalink
Fixed NAK response
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Apr 19, 2021
1 parent 710d793 commit c876f4d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Sources/MPPSolar/MPPSolar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ public final class MPPSolar {
let responseString = try send(command.rawValue)
// parse response string
guard let response = T.Response.init(rawValue: responseString) else {
if let acknowledgement = Acknowledgement(rawValue: responseString),
acknowledgement == .notAcknowledged {
throw MPPSolarError.notAcknowledged
} else {
throw MPPSolarError.invalidResponse(command.data)
}
throw MPPSolarError.invalidResponse(command.data)
}
return response
}
Expand All @@ -61,6 +56,9 @@ public final class MPPSolar {
// validate checksum
guard responseChecksum == expectedChecksum
else { throw MPPSolarError.invalidChecksum(responseChecksum, expected: expectedChecksum) }
guard responseString != Acknowledgement.notAcknowledged.rawValue else {
throw MPPSolarError.notAcknowledged
}
return responseString
}
}
Expand Down

0 comments on commit c876f4d

Please sign in to comment.