| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426 |
- // Autogenerated from Pigeon (v9.1.0), do not edit directly.
- // See also: https://pub.dev/packages/pigeon
- import Foundation
- #if os(iOS)
- import Flutter
- #elseif os(macOS)
- import FlutterMacOS
- #else
- #error("Unsupported platform.")
- #endif
- private func wrapResult(_ result: Any?) -> [Any?] {
- return [result]
- }
- private func wrapError(_ error: Any) -> [Any?] {
- if let flutterError = error as? FlutterError {
- return [
- flutterError.code,
- flutterError.message,
- flutterError.details
- ]
- }
- return [
- "\(error)",
- "\(type(of: error))",
- "Stacktrace: \(Thread.callStackSymbols)"
- ]
- }
- /// Generated class from Pigeon that represents data sent in messages.
- struct Orientation {
- var x: Double? = nil
- var y: Double? = nil
- var z: Double? = nil
- static func fromList(_ list: [Any]) -> Orientation? {
- let x = list[0] as! Double?
- let y = list[1] as! Double?
- let z = list[2] as! Double?
- return Orientation(
- x: x,
- y: y,
- z: z
- )
- }
- func toList() -> [Any?] {
- return [
- x,
- y,
- z,
- ]
- }
- }
- /// Generated class from Pigeon that represents data sent in messages.
- struct Position {
- var latitude: Double? = nil
- var longitude: Double? = nil
- var altitude: Double? = nil
- var bearing: Double? = nil
- var accuracy: Double? = nil
- /// the speed at the time of this location in meters per second.
- var speed: Double? = nil
- var timeMs: Int64? = nil
- static func fromList(_ list: [Any]) -> Position? {
- let latitude = list[0] as! Double?
- let longitude = list[1] as! Double?
- let altitude = list[2] as! Double?
- let bearing = list[3] as! Double?
- let accuracy = list[4] as! Double?
- let speed = list[5] as! Double?
- let timeMs = list[6] as! Int64?
- return Position(
- latitude: latitude,
- longitude: longitude,
- altitude: altitude,
- bearing: bearing,
- accuracy: accuracy,
- speed: speed,
- timeMs: timeMs
- )
- }
- func toList() -> [Any?] {
- return [
- latitude,
- longitude,
- altitude,
- bearing,
- accuracy,
- speed,
- timeMs,
- ]
- }
- }
- /// Generated class from Pigeon that represents data sent in messages.
- struct SportWear {
- var address: String? = nil
- var name: String? = nil
- var rssi: Int64? = nil
- var batteryLevel: Int64? = nil
- static func fromList(_ list: [Any]) -> SportWear? {
- let address = list[0] as! String?
- let name = list[1] as! String?
- let rssi = list[2] as! Int64?
- let batteryLevel = list[3] as! Int64?
- return SportWear(
- address: address,
- name: name,
- rssi: rssi,
- batteryLevel: batteryLevel
- )
- }
- func toList() -> [Any?] {
- return [
- address,
- name,
- rssi,
- batteryLevel,
- ]
- }
- }
- /// Generated class from Pigeon that represents data sent in messages.
- struct HeartRateMeasurement {
- var deviceMac: String? = nil
- var heartRate: Int64? = nil
- var contactDetected: Bool? = nil
- var rrIntervals: [Int64?]? = nil
- var timestampMill: Int64? = nil
- static func fromList(_ list: [Any]) -> HeartRateMeasurement? {
- let deviceMac = list[0] as! String?
- let heartRate = list[1] as! Int64?
- let contactDetected = list[2] as! Bool?
- let rrIntervals = list[3] as! [Int64?]?
- let timestampMill = list[4] as! Int64?
- return HeartRateMeasurement(
- deviceMac: deviceMac,
- heartRate: heartRate,
- contactDetected: contactDetected,
- rrIntervals: rrIntervals,
- timestampMill: timestampMill
- )
- }
- func toList() -> [Any?] {
- return [
- deviceMac,
- heartRate,
- contactDetected,
- rrIntervals,
- timestampMill,
- ]
- }
- }
- private class SensorApiCodecReader: FlutterStandardReader {
- override func readValue(ofType type: UInt8) -> Any? {
- switch type {
- case 128:
- return HeartRateMeasurement.fromList(self.readValue() as! [Any])
- case 129:
- return Orientation.fromList(self.readValue() as! [Any])
- case 130:
- return Position.fromList(self.readValue() as! [Any])
- case 131:
- return SportWear.fromList(self.readValue() as! [Any])
- default:
- return super.readValue(ofType: type)
- }
- }
- }
- private class SensorApiCodecWriter: FlutterStandardWriter {
- override func writeValue(_ value: Any) {
- if let value = value as? HeartRateMeasurement {
- super.writeByte(128)
- super.writeValue(value.toList())
- } else if let value = value as? Orientation {
- super.writeByte(129)
- super.writeValue(value.toList())
- } else if let value = value as? Position {
- super.writeByte(130)
- super.writeValue(value.toList())
- } else if let value = value as? SportWear {
- super.writeByte(131)
- super.writeValue(value.toList())
- } else {
- super.writeValue(value)
- }
- }
- }
- private class SensorApiCodecReaderWriter: FlutterStandardReaderWriter {
- override func reader(with data: Data) -> FlutterStandardReader {
- return SensorApiCodecReader(data: data)
- }
- override func writer(with data: NSMutableData) -> FlutterStandardWriter {
- return SensorApiCodecWriter(data: data)
- }
- }
- class SensorApiCodec: FlutterStandardMessageCodec {
- static let shared = SensorApiCodec(readerWriter: SensorApiCodecReaderWriter())
- }
- /// Generated protocol from Pigeon that represents a handler of messages from Flutter.
- protocol SensorApi {
- /// 获取当前位置,[force]为 false 时,
- /// 优先使用 lastPosition,为 true 强制重新获取当前位置。
- func getCurrentPosition(force: Bool, completion: @escaping (Result<Position, Error>) -> Void)
- func locationStart(minTimeMs: Int64, minDistanceM: Double) throws
- func locationStop() throws
- func sportWearScanStart() throws
- func sportWearScanStop() throws
- func askEnableBluetooth(completion: @escaping (Result<Bool, Error>) -> Void)
- func sportWearConnect(wear: SportWear, completion: @escaping (Result<Void, Error>) -> Void)
- func sportWearDisconnect(wear: SportWear, completion: @escaping (Result<Void, Error>) -> Void)
- /// 是否开启位置服务
- func isLocationServiceOpen() throws -> Bool
- func getYDPI() throws -> Double
- func getXDPI() throws -> Double
- /// 只需要空实现即可,class必须有函数引用才会生成代码
- func toGenAllClass(orientation: Orientation, hrm: HeartRateMeasurement, position: Position) throws
- }
- /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`.
- class SensorApiSetup {
- /// The codec used by SensorApi.
- static var codec: FlutterStandardMessageCodec { SensorApiCodec.shared }
- /// Sets up an instance of `SensorApi` to handle messages through the `binaryMessenger`.
- static func setUp(binaryMessenger: FlutterBinaryMessenger, api: SensorApi?) {
- /// 获取当前位置,[force]为 false 时,
- /// 优先使用 lastPosition,为 true 强制重新获取当前位置。
- let getCurrentPositionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.SensorApi.getCurrentPosition", binaryMessenger: binaryMessenger, codec: codec)
- if let api = api {
- getCurrentPositionChannel.setMessageHandler { message, reply in
- let args = message as! [Any]
- let forceArg = args[0] as! Bool
- api.getCurrentPosition(force: forceArg) { result in
- switch result {
- case .success(let res):
- reply(wrapResult(res))
- case .failure(let error):
- reply(wrapError(error))
- }
- }
- }
- } else {
- getCurrentPositionChannel.setMessageHandler(nil)
- }
- let locationStartChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.SensorApi.locationStart", binaryMessenger: binaryMessenger, codec: codec)
- if let api = api {
- locationStartChannel.setMessageHandler { message, reply in
- let args = message as! [Any]
- let minTimeMsArg = (args[0] is Int) ? Int64(args[0] as! Int) : args[0] as! Int64
- let minDistanceMArg = args[1] as! Double
- do {
- try api.locationStart(minTimeMs: minTimeMsArg, minDistanceM: minDistanceMArg)
- reply(wrapResult(nil))
- } catch {
- reply(wrapError(error))
- }
- }
- } else {
- locationStartChannel.setMessageHandler(nil)
- }
- let locationStopChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.SensorApi.locationStop", binaryMessenger: binaryMessenger, codec: codec)
- if let api = api {
- locationStopChannel.setMessageHandler { _, reply in
- do {
- try api.locationStop()
- reply(wrapResult(nil))
- } catch {
- reply(wrapError(error))
- }
- }
- } else {
- locationStopChannel.setMessageHandler(nil)
- }
- let sportWearScanStartChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.SensorApi.sportWearScanStart", binaryMessenger: binaryMessenger, codec: codec)
- if let api = api {
- sportWearScanStartChannel.setMessageHandler { _, reply in
- do {
- try api.sportWearScanStart()
- reply(wrapResult(nil))
- } catch {
- reply(wrapError(error))
- }
- }
- } else {
- sportWearScanStartChannel.setMessageHandler(nil)
- }
- let sportWearScanStopChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.SensorApi.sportWearScanStop", binaryMessenger: binaryMessenger, codec: codec)
- if let api = api {
- sportWearScanStopChannel.setMessageHandler { _, reply in
- do {
- try api.sportWearScanStop()
- reply(wrapResult(nil))
- } catch {
- reply(wrapError(error))
- }
- }
- } else {
- sportWearScanStopChannel.setMessageHandler(nil)
- }
- let askEnableBluetoothChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.SensorApi.askEnableBluetooth", binaryMessenger: binaryMessenger, codec: codec)
- if let api = api {
- askEnableBluetoothChannel.setMessageHandler { _, reply in
- api.askEnableBluetooth() { result in
- switch result {
- case .success(let res):
- reply(wrapResult(res))
- case .failure(let error):
- reply(wrapError(error))
- }
- }
- }
- } else {
- askEnableBluetoothChannel.setMessageHandler(nil)
- }
- let sportWearConnectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.SensorApi.sportWearConnect", binaryMessenger: binaryMessenger, codec: codec)
- if let api = api {
- sportWearConnectChannel.setMessageHandler { message, reply in
- let args = message as! [Any]
- let wearArg = args[0] as! SportWear
- api.sportWearConnect(wear: wearArg) { result in
- switch result {
- case .success:
- reply(wrapResult(nil))
- case .failure(let error):
- reply(wrapError(error))
- }
- }
- }
- } else {
- sportWearConnectChannel.setMessageHandler(nil)
- }
- let sportWearDisconnectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.SensorApi.sportWearDisconnect", binaryMessenger: binaryMessenger, codec: codec)
- if let api = api {
- sportWearDisconnectChannel.setMessageHandler { message, reply in
- let args = message as! [Any]
- let wearArg = args[0] as! SportWear
- api.sportWearDisconnect(wear: wearArg) { result in
- switch result {
- case .success:
- reply(wrapResult(nil))
- case .failure(let error):
- reply(wrapError(error))
- }
- }
- }
- } else {
- sportWearDisconnectChannel.setMessageHandler(nil)
- }
- /// 是否开启位置服务
- let isLocationServiceOpenChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.SensorApi.isLocationServiceOpen", binaryMessenger: binaryMessenger, codec: codec)
- if let api = api {
- isLocationServiceOpenChannel.setMessageHandler { _, reply in
- do {
- let result = try api.isLocationServiceOpen()
- reply(wrapResult(result))
- } catch {
- reply(wrapError(error))
- }
- }
- } else {
- isLocationServiceOpenChannel.setMessageHandler(nil)
- }
- let getYDPIChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.SensorApi.getYDPI", binaryMessenger: binaryMessenger, codec: codec)
- if let api = api {
- getYDPIChannel.setMessageHandler { _, reply in
- do {
- let result = try api.getYDPI()
- reply(wrapResult(result))
- } catch {
- reply(wrapError(error))
- }
- }
- } else {
- getYDPIChannel.setMessageHandler(nil)
- }
- let getXDPIChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.SensorApi.getXDPI", binaryMessenger: binaryMessenger, codec: codec)
- if let api = api {
- getXDPIChannel.setMessageHandler { _, reply in
- do {
- let result = try api.getXDPI()
- reply(wrapResult(result))
- } catch {
- reply(wrapError(error))
- }
- }
- } else {
- getXDPIChannel.setMessageHandler(nil)
- }
- /// 只需要空实现即可,class必须有函数引用才会生成代码
- let toGenAllClassChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.SensorApi.toGenAllClass", binaryMessenger: binaryMessenger, codec: codec)
- if let api = api {
- toGenAllClassChannel.setMessageHandler { message, reply in
- let args = message as! [Any]
- let orientationArg = args[0] as! Orientation
- let hrmArg = args[1] as! HeartRateMeasurement
- let positionArg = args[2] as! Position
- do {
- try api.toGenAllClass(orientation: orientationArg, hrm: hrmArg, position: positionArg)
- reply(wrapResult(nil))
- } catch {
- reply(wrapError(error))
- }
- }
- } else {
- toGenAllClassChannel.setMessageHandler(nil)
- }
- }
- }
|