33 lines
781 B
Swift
33 lines
781 B
Swift
|
import Foundation
|
||
|
|
||
|
struct DeviceDataResetRequest: DeviceRequest {
|
||
|
|
||
|
typealias Response = Void
|
||
|
|
||
|
static var type: BluetoothRequestType { .clearRecordingBuffer }
|
||
|
|
||
|
var payload: Data {
|
||
|
byteCount.twoByteData
|
||
|
}
|
||
|
|
||
|
let byteCount: Int
|
||
|
|
||
|
init(byteCount: Int) {
|
||
|
self.byteCount = byteCount
|
||
|
}
|
||
|
|
||
|
func makeResponse(from responseData: Data, responseType: BluetoothResponseType) -> Void? {
|
||
|
switch responseType {
|
||
|
case .success:
|
||
|
return ()
|
||
|
case .invalidNumberOfBytesToDelete:
|
||
|
log.error("Device data reset failed: Invalid number of bytes")
|
||
|
return nil
|
||
|
default:
|
||
|
log.warning("Invalid response \(responseType) to device data reset request")
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|