24 lines
627 B
Swift
24 lines
627 B
Swift
import Foundation
|
|
|
|
struct DeviceInfoRequest: DeviceRequest {
|
|
|
|
typealias Response = DeviceInfo
|
|
|
|
static let type: BluetoothRequestType = .getInfo
|
|
|
|
let payload = Data()
|
|
|
|
func makeResponse(from responseData: Data, responseType: BluetoothResponseType) -> DeviceInfo? {
|
|
guard responseType == .success else {
|
|
log.warning("Invalid response \(responseType) to device info request")
|
|
return nil
|
|
}
|
|
do {
|
|
return try .init(info: responseData)
|
|
} catch {
|
|
log.error("Failed to decode device info: \(error)")
|
|
return nil
|
|
}
|
|
}
|
|
}
|