TempTrack-iOS/TempTrack/Connection/DeviceInfoRequest.swift
2023-06-29 10:13:37 +02:00

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
}
}
}