messages.m 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. // Autogenerated from Pigeon (v9.1.0), do not edit directly.
  2. // See also: https://pub.dev/packages/pigeon
  3. #import "messages.h"
  4. #import <Flutter/Flutter.h>
  5. #if !__has_feature(objc_arc)
  6. #error File requires ARC to be enabled.
  7. #endif
  8. static NSArray *wrapResult(id result, FlutterError *error) {
  9. if (error) {
  10. return @[
  11. error.code ?: [NSNull null], error.message ?: [NSNull null], error.details ?: [NSNull null]
  12. ];
  13. }
  14. return @[ result ?: [NSNull null] ];
  15. }
  16. static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
  17. id result = array[key];
  18. return (result == [NSNull null]) ? nil : result;
  19. }
  20. @interface FLTOrientation ()
  21. + (FLTOrientation *)fromList:(NSArray *)list;
  22. + (nullable FLTOrientation *)nullableFromList:(NSArray *)list;
  23. - (NSArray *)toList;
  24. @end
  25. @interface FLTPosition ()
  26. + (FLTPosition *)fromList:(NSArray *)list;
  27. + (nullable FLTPosition *)nullableFromList:(NSArray *)list;
  28. - (NSArray *)toList;
  29. @end
  30. @interface FLTSportWear ()
  31. + (FLTSportWear *)fromList:(NSArray *)list;
  32. + (nullable FLTSportWear *)nullableFromList:(NSArray *)list;
  33. - (NSArray *)toList;
  34. @end
  35. @interface FLTHeartRateMeasurement ()
  36. + (FLTHeartRateMeasurement *)fromList:(NSArray *)list;
  37. + (nullable FLTHeartRateMeasurement *)nullableFromList:(NSArray *)list;
  38. - (NSArray *)toList;
  39. @end
  40. @implementation FLTOrientation
  41. + (instancetype)makeWithX:(nullable NSNumber *)x
  42. y:(nullable NSNumber *)y
  43. z:(nullable NSNumber *)z {
  44. FLTOrientation* pigeonResult = [[FLTOrientation alloc] init];
  45. pigeonResult.x = x;
  46. pigeonResult.y = y;
  47. pigeonResult.z = z;
  48. return pigeonResult;
  49. }
  50. + (FLTOrientation *)fromList:(NSArray *)list {
  51. FLTOrientation *pigeonResult = [[FLTOrientation alloc] init];
  52. pigeonResult.x = GetNullableObjectAtIndex(list, 0);
  53. pigeonResult.y = GetNullableObjectAtIndex(list, 1);
  54. pigeonResult.z = GetNullableObjectAtIndex(list, 2);
  55. return pigeonResult;
  56. }
  57. + (nullable FLTOrientation *)nullableFromList:(NSArray *)list {
  58. return (list) ? [FLTOrientation fromList:list] : nil;
  59. }
  60. - (NSArray *)toList {
  61. return @[
  62. (self.x ?: [NSNull null]),
  63. (self.y ?: [NSNull null]),
  64. (self.z ?: [NSNull null]),
  65. ];
  66. }
  67. @end
  68. @implementation FLTPosition
  69. + (instancetype)makeWithLatitude:(nullable NSNumber *)latitude
  70. longitude:(nullable NSNumber *)longitude
  71. altitude:(nullable NSNumber *)altitude
  72. bearing:(nullable NSNumber *)bearing
  73. accuracy:(nullable NSNumber *)accuracy
  74. speed:(nullable NSNumber *)speed
  75. timeMs:(nullable NSNumber *)timeMs {
  76. FLTPosition* pigeonResult = [[FLTPosition alloc] init];
  77. pigeonResult.latitude = latitude;
  78. pigeonResult.longitude = longitude;
  79. pigeonResult.altitude = altitude;
  80. pigeonResult.bearing = bearing;
  81. pigeonResult.accuracy = accuracy;
  82. pigeonResult.speed = speed;
  83. pigeonResult.timeMs = timeMs;
  84. return pigeonResult;
  85. }
  86. + (FLTPosition *)fromList:(NSArray *)list {
  87. FLTPosition *pigeonResult = [[FLTPosition alloc] init];
  88. pigeonResult.latitude = GetNullableObjectAtIndex(list, 0);
  89. pigeonResult.longitude = GetNullableObjectAtIndex(list, 1);
  90. pigeonResult.altitude = GetNullableObjectAtIndex(list, 2);
  91. pigeonResult.bearing = GetNullableObjectAtIndex(list, 3);
  92. pigeonResult.accuracy = GetNullableObjectAtIndex(list, 4);
  93. pigeonResult.speed = GetNullableObjectAtIndex(list, 5);
  94. pigeonResult.timeMs = GetNullableObjectAtIndex(list, 6);
  95. return pigeonResult;
  96. }
  97. + (nullable FLTPosition *)nullableFromList:(NSArray *)list {
  98. return (list) ? [FLTPosition fromList:list] : nil;
  99. }
  100. - (NSArray *)toList {
  101. return @[
  102. (self.latitude ?: [NSNull null]),
  103. (self.longitude ?: [NSNull null]),
  104. (self.altitude ?: [NSNull null]),
  105. (self.bearing ?: [NSNull null]),
  106. (self.accuracy ?: [NSNull null]),
  107. (self.speed ?: [NSNull null]),
  108. (self.timeMs ?: [NSNull null]),
  109. ];
  110. }
  111. @end
  112. @implementation FLTSportWear
  113. + (instancetype)makeWithAddress:(nullable NSString *)address
  114. name:(nullable NSString *)name
  115. rssi:(nullable NSNumber *)rssi
  116. batteryLevel:(nullable NSNumber *)batteryLevel {
  117. FLTSportWear* pigeonResult = [[FLTSportWear alloc] init];
  118. pigeonResult.address = address;
  119. pigeonResult.name = name;
  120. pigeonResult.rssi = rssi;
  121. pigeonResult.batteryLevel = batteryLevel;
  122. return pigeonResult;
  123. }
  124. + (FLTSportWear *)fromList:(NSArray *)list {
  125. FLTSportWear *pigeonResult = [[FLTSportWear alloc] init];
  126. pigeonResult.address = GetNullableObjectAtIndex(list, 0);
  127. pigeonResult.name = GetNullableObjectAtIndex(list, 1);
  128. pigeonResult.rssi = GetNullableObjectAtIndex(list, 2);
  129. pigeonResult.batteryLevel = GetNullableObjectAtIndex(list, 3);
  130. return pigeonResult;
  131. }
  132. + (nullable FLTSportWear *)nullableFromList:(NSArray *)list {
  133. return (list) ? [FLTSportWear fromList:list] : nil;
  134. }
  135. - (NSArray *)toList {
  136. return @[
  137. (self.address ?: [NSNull null]),
  138. (self.name ?: [NSNull null]),
  139. (self.rssi ?: [NSNull null]),
  140. (self.batteryLevel ?: [NSNull null]),
  141. ];
  142. }
  143. @end
  144. @implementation FLTHeartRateMeasurement
  145. + (instancetype)makeWithDeviceMac:(nullable NSString *)deviceMac
  146. heartRate:(nullable NSNumber *)heartRate
  147. contactDetected:(nullable NSNumber *)contactDetected
  148. rrIntervals:(nullable NSArray<NSNumber *> *)rrIntervals
  149. timestampMill:(nullable NSNumber *)timestampMill {
  150. FLTHeartRateMeasurement* pigeonResult = [[FLTHeartRateMeasurement alloc] init];
  151. pigeonResult.deviceMac = deviceMac;
  152. pigeonResult.heartRate = heartRate;
  153. pigeonResult.contactDetected = contactDetected;
  154. pigeonResult.rrIntervals = rrIntervals;
  155. pigeonResult.timestampMill = timestampMill;
  156. return pigeonResult;
  157. }
  158. + (FLTHeartRateMeasurement *)fromList:(NSArray *)list {
  159. FLTHeartRateMeasurement *pigeonResult = [[FLTHeartRateMeasurement alloc] init];
  160. pigeonResult.deviceMac = GetNullableObjectAtIndex(list, 0);
  161. pigeonResult.heartRate = GetNullableObjectAtIndex(list, 1);
  162. pigeonResult.contactDetected = GetNullableObjectAtIndex(list, 2);
  163. pigeonResult.rrIntervals = GetNullableObjectAtIndex(list, 3);
  164. pigeonResult.timestampMill = GetNullableObjectAtIndex(list, 4);
  165. return pigeonResult;
  166. }
  167. + (nullable FLTHeartRateMeasurement *)nullableFromList:(NSArray *)list {
  168. return (list) ? [FLTHeartRateMeasurement fromList:list] : nil;
  169. }
  170. - (NSArray *)toList {
  171. return @[
  172. (self.deviceMac ?: [NSNull null]),
  173. (self.heartRate ?: [NSNull null]),
  174. (self.contactDetected ?: [NSNull null]),
  175. (self.rrIntervals ?: [NSNull null]),
  176. (self.timestampMill ?: [NSNull null]),
  177. ];
  178. }
  179. @end
  180. @interface FLTSensorApiCodecReader : FlutterStandardReader
  181. @end
  182. @implementation FLTSensorApiCodecReader
  183. - (nullable id)readValueOfType:(UInt8)type {
  184. switch (type) {
  185. case 128:
  186. return [FLTHeartRateMeasurement fromList:[self readValue]];
  187. case 129:
  188. return [FLTOrientation fromList:[self readValue]];
  189. case 130:
  190. return [FLTPosition fromList:[self readValue]];
  191. case 131:
  192. return [FLTSportWear fromList:[self readValue]];
  193. default:
  194. return [super readValueOfType:type];
  195. }
  196. }
  197. @end
  198. @interface FLTSensorApiCodecWriter : FlutterStandardWriter
  199. @end
  200. @implementation FLTSensorApiCodecWriter
  201. - (void)writeValue:(id)value {
  202. if ([value isKindOfClass:[FLTHeartRateMeasurement class]]) {
  203. [self writeByte:128];
  204. [self writeValue:[value toList]];
  205. } else if ([value isKindOfClass:[FLTOrientation class]]) {
  206. [self writeByte:129];
  207. [self writeValue:[value toList]];
  208. } else if ([value isKindOfClass:[FLTPosition class]]) {
  209. [self writeByte:130];
  210. [self writeValue:[value toList]];
  211. } else if ([value isKindOfClass:[FLTSportWear class]]) {
  212. [self writeByte:131];
  213. [self writeValue:[value toList]];
  214. } else {
  215. [super writeValue:value];
  216. }
  217. }
  218. @end
  219. @interface FLTSensorApiCodecReaderWriter : FlutterStandardReaderWriter
  220. @end
  221. @implementation FLTSensorApiCodecReaderWriter
  222. - (FlutterStandardWriter *)writerWithData:(NSMutableData *)data {
  223. return [[FLTSensorApiCodecWriter alloc] initWithData:data];
  224. }
  225. - (FlutterStandardReader *)readerWithData:(NSData *)data {
  226. return [[FLTSensorApiCodecReader alloc] initWithData:data];
  227. }
  228. @end
  229. NSObject<FlutterMessageCodec> *FLTSensorApiGetCodec() {
  230. static FlutterStandardMessageCodec *sSharedObject = nil;
  231. static dispatch_once_t sPred = 0;
  232. dispatch_once(&sPred, ^{
  233. FLTSensorApiCodecReaderWriter *readerWriter = [[FLTSensorApiCodecReaderWriter alloc] init];
  234. sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter];
  235. });
  236. return sSharedObject;
  237. }
  238. void FLTSensorApiSetup(id<FlutterBinaryMessenger> binaryMessenger, NSObject<FLTSensorApi> *api) {
  239. /// 获取当前位置,[force]为 false 时,
  240. /// 优先使用 lastPosition,为 true 强制重新获取当前位置。
  241. {
  242. FlutterBasicMessageChannel *channel =
  243. [[FlutterBasicMessageChannel alloc]
  244. initWithName:@"dev.flutter.pigeon.SensorApi.getCurrentPosition"
  245. binaryMessenger:binaryMessenger
  246. codec:FLTSensorApiGetCodec()];
  247. if (api) {
  248. NSCAssert([api respondsToSelector:@selector(getCurrentPositionForce:completion:)], @"FLTSensorApi api (%@) doesn't respond to @selector(getCurrentPositionForce:completion:)", api);
  249. [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
  250. NSArray *args = message;
  251. NSNumber *arg_force = GetNullableObjectAtIndex(args, 0);
  252. [api getCurrentPositionForce:arg_force completion:^(FLTPosition *_Nullable output, FlutterError *_Nullable error) {
  253. callback(wrapResult(output, error));
  254. }];
  255. }];
  256. } else {
  257. [channel setMessageHandler:nil];
  258. }
  259. }
  260. {
  261. FlutterBasicMessageChannel *channel =
  262. [[FlutterBasicMessageChannel alloc]
  263. initWithName:@"dev.flutter.pigeon.SensorApi.locationStart"
  264. binaryMessenger:binaryMessenger
  265. codec:FLTSensorApiGetCodec()];
  266. if (api) {
  267. NSCAssert([api respondsToSelector:@selector(locationStartMinTimeMs:minDistanceM:error:)], @"FLTSensorApi api (%@) doesn't respond to @selector(locationStartMinTimeMs:minDistanceM:error:)", api);
  268. [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
  269. NSArray *args = message;
  270. NSNumber *arg_minTimeMs = GetNullableObjectAtIndex(args, 0);
  271. NSNumber *arg_minDistanceM = GetNullableObjectAtIndex(args, 1);
  272. FlutterError *error;
  273. [api locationStartMinTimeMs:arg_minTimeMs minDistanceM:arg_minDistanceM error:&error];
  274. callback(wrapResult(nil, error));
  275. }];
  276. } else {
  277. [channel setMessageHandler:nil];
  278. }
  279. }
  280. {
  281. FlutterBasicMessageChannel *channel =
  282. [[FlutterBasicMessageChannel alloc]
  283. initWithName:@"dev.flutter.pigeon.SensorApi.locationStop"
  284. binaryMessenger:binaryMessenger
  285. codec:FLTSensorApiGetCodec()];
  286. if (api) {
  287. NSCAssert([api respondsToSelector:@selector(locationStopWithError:)], @"FLTSensorApi api (%@) doesn't respond to @selector(locationStopWithError:)", api);
  288. [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
  289. FlutterError *error;
  290. [api locationStopWithError:&error];
  291. callback(wrapResult(nil, error));
  292. }];
  293. } else {
  294. [channel setMessageHandler:nil];
  295. }
  296. }
  297. {
  298. FlutterBasicMessageChannel *channel =
  299. [[FlutterBasicMessageChannel alloc]
  300. initWithName:@"dev.flutter.pigeon.SensorApi.sportWearScanStart"
  301. binaryMessenger:binaryMessenger
  302. codec:FLTSensorApiGetCodec()];
  303. if (api) {
  304. NSCAssert([api respondsToSelector:@selector(sportWearScanStartWithError:)], @"FLTSensorApi api (%@) doesn't respond to @selector(sportWearScanStartWithError:)", api);
  305. [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
  306. FlutterError *error;
  307. [api sportWearScanStartWithError:&error];
  308. callback(wrapResult(nil, error));
  309. }];
  310. } else {
  311. [channel setMessageHandler:nil];
  312. }
  313. }
  314. {
  315. FlutterBasicMessageChannel *channel =
  316. [[FlutterBasicMessageChannel alloc]
  317. initWithName:@"dev.flutter.pigeon.SensorApi.sportWearScanStop"
  318. binaryMessenger:binaryMessenger
  319. codec:FLTSensorApiGetCodec()];
  320. if (api) {
  321. NSCAssert([api respondsToSelector:@selector(sportWearScanStopWithError:)], @"FLTSensorApi api (%@) doesn't respond to @selector(sportWearScanStopWithError:)", api);
  322. [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
  323. FlutterError *error;
  324. [api sportWearScanStopWithError:&error];
  325. callback(wrapResult(nil, error));
  326. }];
  327. } else {
  328. [channel setMessageHandler:nil];
  329. }
  330. }
  331. {
  332. FlutterBasicMessageChannel *channel =
  333. [[FlutterBasicMessageChannel alloc]
  334. initWithName:@"dev.flutter.pigeon.SensorApi.askEnableBluetooth"
  335. binaryMessenger:binaryMessenger
  336. codec:FLTSensorApiGetCodec()];
  337. if (api) {
  338. NSCAssert([api respondsToSelector:@selector(askEnableBluetoothWithCompletion:)], @"FLTSensorApi api (%@) doesn't respond to @selector(askEnableBluetoothWithCompletion:)", api);
  339. [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
  340. [api askEnableBluetoothWithCompletion:^(NSNumber *_Nullable output, FlutterError *_Nullable error) {
  341. callback(wrapResult(output, error));
  342. }];
  343. }];
  344. } else {
  345. [channel setMessageHandler:nil];
  346. }
  347. }
  348. {
  349. FlutterBasicMessageChannel *channel =
  350. [[FlutterBasicMessageChannel alloc]
  351. initWithName:@"dev.flutter.pigeon.SensorApi.sportWearConnect"
  352. binaryMessenger:binaryMessenger
  353. codec:FLTSensorApiGetCodec()];
  354. if (api) {
  355. NSCAssert([api respondsToSelector:@selector(sportWearConnectWear:completion:)], @"FLTSensorApi api (%@) doesn't respond to @selector(sportWearConnectWear:completion:)", api);
  356. [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
  357. NSArray *args = message;
  358. FLTSportWear *arg_wear = GetNullableObjectAtIndex(args, 0);
  359. [api sportWearConnectWear:arg_wear completion:^(FlutterError *_Nullable error) {
  360. callback(wrapResult(nil, error));
  361. }];
  362. }];
  363. } else {
  364. [channel setMessageHandler:nil];
  365. }
  366. }
  367. {
  368. FlutterBasicMessageChannel *channel =
  369. [[FlutterBasicMessageChannel alloc]
  370. initWithName:@"dev.flutter.pigeon.SensorApi.sportWearDisconnect"
  371. binaryMessenger:binaryMessenger
  372. codec:FLTSensorApiGetCodec()];
  373. if (api) {
  374. NSCAssert([api respondsToSelector:@selector(sportWearDisconnectWear:completion:)], @"FLTSensorApi api (%@) doesn't respond to @selector(sportWearDisconnectWear:completion:)", api);
  375. [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
  376. NSArray *args = message;
  377. FLTSportWear *arg_wear = GetNullableObjectAtIndex(args, 0);
  378. [api sportWearDisconnectWear:arg_wear completion:^(FlutterError *_Nullable error) {
  379. callback(wrapResult(nil, error));
  380. }];
  381. }];
  382. } else {
  383. [channel setMessageHandler:nil];
  384. }
  385. }
  386. /// 是否开启位置服务
  387. {
  388. FlutterBasicMessageChannel *channel =
  389. [[FlutterBasicMessageChannel alloc]
  390. initWithName:@"dev.flutter.pigeon.SensorApi.isLocationServiceOpen"
  391. binaryMessenger:binaryMessenger
  392. codec:FLTSensorApiGetCodec()];
  393. if (api) {
  394. NSCAssert([api respondsToSelector:@selector(isLocationServiceOpenWithError:)], @"FLTSensorApi api (%@) doesn't respond to @selector(isLocationServiceOpenWithError:)", api);
  395. [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
  396. FlutterError *error;
  397. NSNumber *output = [api isLocationServiceOpenWithError:&error];
  398. callback(wrapResult(output, error));
  399. }];
  400. } else {
  401. [channel setMessageHandler:nil];
  402. }
  403. }
  404. {
  405. FlutterBasicMessageChannel *channel =
  406. [[FlutterBasicMessageChannel alloc]
  407. initWithName:@"dev.flutter.pigeon.SensorApi.getYDPI"
  408. binaryMessenger:binaryMessenger
  409. codec:FLTSensorApiGetCodec()];
  410. if (api) {
  411. NSCAssert([api respondsToSelector:@selector(getYDPIWithError:)], @"FLTSensorApi api (%@) doesn't respond to @selector(getYDPIWithError:)", api);
  412. [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
  413. FlutterError *error;
  414. NSNumber *output = [api getYDPIWithError:&error];
  415. callback(wrapResult(output, error));
  416. }];
  417. } else {
  418. [channel setMessageHandler:nil];
  419. }
  420. }
  421. {
  422. FlutterBasicMessageChannel *channel =
  423. [[FlutterBasicMessageChannel alloc]
  424. initWithName:@"dev.flutter.pigeon.SensorApi.getXDPI"
  425. binaryMessenger:binaryMessenger
  426. codec:FLTSensorApiGetCodec()];
  427. if (api) {
  428. NSCAssert([api respondsToSelector:@selector(getXDPIWithError:)], @"FLTSensorApi api (%@) doesn't respond to @selector(getXDPIWithError:)", api);
  429. [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
  430. FlutterError *error;
  431. NSNumber *output = [api getXDPIWithError:&error];
  432. callback(wrapResult(output, error));
  433. }];
  434. } else {
  435. [channel setMessageHandler:nil];
  436. }
  437. }
  438. /// 只需要空实现即可,class必须有函数引用才会生成代码
  439. {
  440. FlutterBasicMessageChannel *channel =
  441. [[FlutterBasicMessageChannel alloc]
  442. initWithName:@"dev.flutter.pigeon.SensorApi.toGenAllClass"
  443. binaryMessenger:binaryMessenger
  444. codec:FLTSensorApiGetCodec()];
  445. if (api) {
  446. NSCAssert([api respondsToSelector:@selector(toGenAllClassOrientation:hrm:position:error:)], @"FLTSensorApi api (%@) doesn't respond to @selector(toGenAllClassOrientation:hrm:position:error:)", api);
  447. [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
  448. NSArray *args = message;
  449. FLTOrientation *arg_orientation = GetNullableObjectAtIndex(args, 0);
  450. FLTHeartRateMeasurement *arg_hrm = GetNullableObjectAtIndex(args, 1);
  451. FLTPosition *arg_position = GetNullableObjectAtIndex(args, 2);
  452. FlutterError *error;
  453. [api toGenAllClassOrientation:arg_orientation hrm:arg_hrm position:arg_position error:&error];
  454. callback(wrapResult(nil, error));
  455. }];
  456. } else {
  457. [channel setMessageHandler:nil];
  458. }
  459. }
  460. }