react-native-flic2 2.0.0-alpha.39 → 2.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ios/Flic2.mm CHANGED
@@ -8,16 +8,6 @@
8
8
  return self;
9
9
  }
10
10
 
11
- - (NSNumber *)multiply:(double)a b:(double)b {
12
-
13
- NSLog(@"multiply: %f * %f", a, b);
14
- NSNumber *result = @(a * b);
15
-
16
- [self emitOnMultiply:@{@"a": @(a), @"b": @(b), @"result": result}];
17
-
18
- return result;
19
- }
20
-
21
11
  // MARK: - FLICManager Methods
22
12
 
23
13
  - (void)initialize:(BOOL)background
@@ -28,7 +18,6 @@
28
18
  FLICManager *manager = [FLICManager configureWithDelegate:self buttonDelegate:self background:background];
29
19
 
30
20
  if (manager) {
31
- self.manager = manager; // Store reference for our own use
32
21
  resolve(@{@"success": @YES, @"message": @"Manager initialized successfully"});
33
22
  } else {
34
23
  reject(@"INIT_ERROR", @"Failed to initialize FLICManager", nil);
@@ -38,7 +27,7 @@
38
27
  - (void)getButtons:(RCTPromiseResolveBlock)resolve
39
28
  reject:(RCTPromiseRejectBlock)reject
40
29
  {
41
- if (!self.manager) {
30
+ if (![FLICManager sharedManager]) {
42
31
  reject(@"NOT_INITIALIZED", @"Manager not initialized", nil);
43
32
  return;
44
33
  }
@@ -61,7 +50,7 @@
61
50
  - (void)scanForButtons:(RCTPromiseResolveBlock)resolve
62
51
  reject:(RCTPromiseRejectBlock)reject
63
52
  {
64
- if (!self.manager) {
53
+ if (![FLICManager sharedManager]) {
65
54
  reject(@"NOT_INITIALIZED", @"Manager not initialized", nil);
66
55
  return;
67
56
  }
@@ -75,25 +64,25 @@
75
64
 
76
65
  __weak Flic2 *weakSelf = self;
77
66
 
78
- [[FLICManager sharedManager] scanForButtonsWithStateChangeHandler:^(FLICButtonScannerStatusEvent event) {
79
- NSLog(@"Scan state change: %@", [weakSelf scannerEventToString:event]);
67
+ // Emit started event
68
+ dispatch_async(dispatch_get_main_queue(), ^{
80
69
  [weakSelf emitOnScanStatusChange:@{
81
- @"event": @(event),
82
- @"eventName": [weakSelf scannerEventToString:event]
70
+ @"event": @"started",
71
+ @"eventName": @"started"
83
72
  }];
73
+ });
74
+
75
+ [[FLICManager sharedManager] scanForButtonsWithStateChangeHandler:^(FLICButtonScannerStatusEvent event) {
76
+
77
+ // Intermediate scan status events are intentionally not emitted
78
+
84
79
  } completion:^(FLICButton * _Nullable button, NSError * _Nullable error) {
85
80
  NSLog(@"Scan completion called - button: %@, error: %@", button ? @"YES" : @"NO", error);
86
81
 
82
+ NSInteger resultCode = [weakSelf mapScanErrorToResultCode:error];
83
+
87
84
  if (error) {
88
- NSLog(@"Scan error: %@ (code: %ld)", error.localizedDescription, (long)error.code);
89
- // Check for specific error codes
90
- if (error.code == FLICButtonScannerErrorCodeUserCanceled) {
91
- NSLog(@"Scan was cancelled by user");
92
- } else if (error.code == FLICButtonScannerErrorCodeNoPublicButtonDiscovered) {
93
- NSLog(@"No Flic button found in range");
94
- } else {
95
- NSLog(@"Scan error: %@", error.localizedDescription);
96
- }
85
+ NSLog(@"Scan error: %@ (code: %ld, mapped: %ld)", error.localizedDescription, (long)error.code, (long)resultCode);
97
86
  } else if (button) {
98
87
  NSLog(@"Button found: %@", button.uuid);
99
88
 
@@ -102,14 +91,26 @@
102
91
  [button connect];
103
92
 
104
93
  // Emit button event for discovered button
105
- [weakSelf emitOnButtonEvent:@{
106
- @"uuid": button.uuid,
107
- @"event": @"discovered",
108
- @"button": [weakSelf buttonToDictionary:button]
109
- }];
94
+ dispatch_async(dispatch_get_main_queue(), ^{
95
+ [weakSelf emitOnButtonEvent:@{
96
+ @"uuid": button.uuid,
97
+ @"event": @"discovered",
98
+ @"button": [weakSelf buttonToDictionary:button]
99
+ }];
100
+ });
101
+
110
102
  } else {
111
103
  NSLog(@"No button found and no error");
112
104
  }
105
+
106
+ // Emit scan completion with result code
107
+ dispatch_async(dispatch_get_main_queue(), ^{
108
+ [weakSelf emitOnScanStatusChange:@{
109
+ @"event": @"completion",
110
+ @"eventName": @"completion",
111
+ @"result": @(resultCode)
112
+ }];
113
+ });
113
114
  }];
114
115
 
115
116
  // Return immediately - scan results will come through events
@@ -119,13 +120,14 @@
119
120
  - (void)stopScan:(RCTPromiseResolveBlock)resolve
120
121
  reject:(RCTPromiseRejectBlock)reject
121
122
  {
122
- if (!self.manager) {
123
+ if (![FLICManager sharedManager]) {
123
124
  reject(@"NOT_INITIALIZED", @"Manager not initialized", nil);
124
125
  return;
125
126
  }
126
127
 
127
128
  NSLog(@"Stopping scan");
128
129
  [[FLICManager sharedManager] stopScan];
130
+
129
131
  resolve(@{@"success": @YES, @"message": @"Scan stopped"});
130
132
  }
131
133
 
@@ -133,20 +135,12 @@
133
135
  resolve:(RCTPromiseResolveBlock)resolve
134
136
  reject:(RCTPromiseRejectBlock)reject
135
137
  {
136
- if (!self.manager) {
138
+ if (![FLICManager sharedManager]) {
137
139
  reject(@"NOT_INITIALIZED", @"Manager not initialized", nil);
138
140
  return;
139
141
  }
140
142
 
141
- // Find button in shared manager's buttons array
142
- NSArray<FLICButton *> *buttons = [[FLICManager sharedManager] buttons];
143
- FLICButton *button = nil;
144
- for (FLICButton *btn in buttons) {
145
- if ([btn.uuid isEqualToString:uuid]) {
146
- button = btn;
147
- break;
148
- }
149
- }
143
+ FLICButton *button = [self findButtonByUUID:uuid];
150
144
 
151
145
  if (!button) {
152
146
  reject(@"BUTTON_NOT_FOUND", @"Button not found", nil);
@@ -171,15 +165,7 @@
171
165
  resolve:(RCTPromiseResolveBlock)resolve
172
166
  reject:(RCTPromiseRejectBlock)reject
173
167
  {
174
- // Find button in shared manager's buttons array
175
- NSArray<FLICButton *> *buttons = [[FLICManager sharedManager] buttons];
176
- FLICButton *button = nil;
177
- for (FLICButton *btn in buttons) {
178
- if ([btn.uuid isEqualToString:uuid]) {
179
- button = btn;
180
- break;
181
- }
182
- }
168
+ FLICButton *button = [self findButtonByUUID:uuid];
183
169
 
184
170
  if (!button) {
185
171
  reject(@"BUTTON_NOT_FOUND", @"Button not found", nil);
@@ -194,15 +180,7 @@
194
180
  resolve:(RCTPromiseResolveBlock)resolve
195
181
  reject:(RCTPromiseRejectBlock)reject
196
182
  {
197
- // Find button in shared manager's buttons array
198
- NSArray<FLICButton *> *buttons = [[FLICManager sharedManager] buttons];
199
- FLICButton *button = nil;
200
- for (FLICButton *btn in buttons) {
201
- if ([btn.uuid isEqualToString:uuid]) {
202
- button = btn;
203
- break;
204
- }
205
- }
183
+ FLICButton *button = [self findButtonByUUID:uuid];
206
184
 
207
185
  if (!button) {
208
186
  reject(@"BUTTON_NOT_FOUND", @"Button not found", nil);
@@ -217,15 +195,7 @@
217
195
  resolve:(RCTPromiseResolveBlock)resolve
218
196
  reject:(RCTPromiseRejectBlock)reject
219
197
  {
220
- // Find button in shared manager's buttons array
221
- NSArray<FLICButton *> *buttons = [[FLICManager sharedManager] buttons];
222
- FLICButton *button = nil;
223
- for (FLICButton *btn in buttons) {
224
- if ([btn.uuid isEqualToString:uuid]) {
225
- button = btn;
226
- break;
227
- }
228
- }
198
+ FLICButton *button = [self findButtonByUUID:uuid];
229
199
 
230
200
  if (!button) {
231
201
  reject(@"BUTTON_NOT_FOUND", @"Button not found", nil);
@@ -240,15 +210,7 @@
240
210
  resolve:(RCTPromiseResolveBlock)resolve
241
211
  reject:(RCTPromiseRejectBlock)reject
242
212
  {
243
- // Find button in shared manager's buttons array
244
- NSArray<FLICButton *> *buttons = [[FLICManager sharedManager] buttons];
245
- FLICButton *button = nil;
246
- for (FLICButton *btn in buttons) {
247
- if ([btn.uuid isEqualToString:uuid]) {
248
- button = btn;
249
- break;
250
- }
251
- }
213
+ FLICButton *button = [self findButtonByUUID:uuid];
252
214
 
253
215
  if (!button) {
254
216
  reject(@"BUTTON_NOT_FOUND", @"Button not found", nil);
@@ -263,15 +225,7 @@
263
225
  resolve:(RCTPromiseResolveBlock)resolve
264
226
  reject:(RCTPromiseRejectBlock)reject
265
227
  {
266
- // Find button in shared manager's buttons array
267
- NSArray<FLICButton *> *buttons = [[FLICManager sharedManager] buttons];
268
- FLICButton *button = nil;
269
- for (FLICButton *btn in buttons) {
270
- if ([btn.uuid isEqualToString:uuid]) {
271
- button = btn;
272
- break;
273
- }
274
- }
228
+ FLICButton *button = [self findButtonByUUID:uuid];
275
229
 
276
230
  if (!button) {
277
231
  reject(@"BUTTON_NOT_FOUND", @"Button not found", nil);
@@ -287,7 +241,7 @@
287
241
  - (void)connectAllKnownButtons:(RCTPromiseResolveBlock)resolve
288
242
  reject:(RCTPromiseRejectBlock)reject
289
243
  {
290
- if (!self.manager) {
244
+ if (![FLICManager sharedManager]) {
291
245
  reject(@"NOT_INITIALIZED", @"Manager not initialized", nil);
292
246
  return;
293
247
  }
@@ -306,7 +260,7 @@
306
260
  - (void)disconnectAllKnownButtons:(RCTPromiseResolveBlock)resolve
307
261
  reject:(RCTPromiseRejectBlock)reject
308
262
  {
309
- if (!self.manager) {
263
+ if (![FLICManager sharedManager]) {
310
264
  reject(@"NOT_INITIALIZED", @"Manager not initialized", nil);
311
265
  return;
312
266
  }
@@ -324,7 +278,7 @@
324
278
  - (void)forgetAllButtons:(RCTPromiseResolveBlock)resolve
325
279
  reject:(RCTPromiseRejectBlock)reject
326
280
  {
327
- if (!self.manager) {
281
+ if (![FLICManager sharedManager]) {
328
282
  reject(@"NOT_INITIALIZED", @"Manager not initialized", nil);
329
283
  return;
330
284
  }
@@ -344,7 +298,7 @@
344
298
  - (void)isScanning:(RCTPromiseResolveBlock)resolve
345
299
  reject:(RCTPromiseRejectBlock)reject
346
300
  {
347
- if (!self.manager) {
301
+ if (![FLICManager sharedManager]) {
348
302
  reject(@"NOT_INITIALIZED", @"Manager not initialized", nil);
349
303
  return;
350
304
  }
@@ -358,36 +312,44 @@
358
312
  - (void)managerDidRestoreState:(FLICManager *)manager {
359
313
  self.managerRestored = YES;
360
314
  NSLog(@"Manager state restored - ready for operations");
361
- [self emitOnManagerStateChange:@{
362
- @"event": @"restored",
363
- @"message": @"Manager state restored"
364
- }];
315
+ dispatch_async(dispatch_get_main_queue(), ^{
316
+ [self emitOnManagerStateChange:@{
317
+ @"event": @"restored",
318
+ @"message": @"Manager state restored"
319
+ }];
320
+ });
365
321
  }
366
322
 
367
323
  - (void)manager:(FLICManager *)manager didUpdateState:(FLICManagerState)state {
368
- [self emitOnManagerStateChange:@{
369
- @"state": @(state),
370
- @"stateName": [self managerStateToString:state],
371
- @"event": @"stateChanged"
372
- }];
324
+ dispatch_async(dispatch_get_main_queue(), ^{
325
+ [self emitOnManagerStateChange:@{
326
+ @"state": @(state),
327
+ @"stateName": [self managerStateToString:state],
328
+ @"event": @"stateChanged"
329
+ }];
330
+ });
373
331
  }
374
332
 
375
333
  // MARK: - FLICButtonDelegate
376
334
 
377
335
  - (void)buttonDidConnect:(FLICButton *)button {
378
- [self emitOnButtonEvent:@{
379
- @"uuid": button.uuid,
380
- @"event": @"connected",
381
- @"button": [self buttonToDictionary:button]
382
- }];
336
+ dispatch_async(dispatch_get_main_queue(), ^{
337
+ [self emitOnButtonEvent:@{
338
+ @"uuid": button.uuid,
339
+ @"event": @"connected",
340
+ @"button": [self buttonToDictionary:button]
341
+ }];
342
+ });
383
343
  }
384
344
 
385
345
  - (void)buttonIsReady:(FLICButton *)button {
386
- [self emitOnButtonEvent:@{
387
- @"uuid": button.uuid,
388
- @"event": @"ready",
389
- @"button": [self buttonToDictionary:button]
390
- }];
346
+ dispatch_async(dispatch_get_main_queue(), ^{
347
+ [self emitOnButtonEvent:@{
348
+ @"uuid": button.uuid,
349
+ @"event": @"ready",
350
+ @"button": [self buttonToDictionary:button]
351
+ }];
352
+ });
391
353
  }
392
354
 
393
355
  - (void)button:(FLICButton *)button didDisconnectWithError:(NSError * _Nullable)error {
@@ -404,99 +366,129 @@
404
366
  };
405
367
  }
406
368
 
407
- [self emitOnButtonEvent:eventData];
369
+ dispatch_async(dispatch_get_main_queue(), ^{
370
+ [self emitOnButtonEvent:eventData];
371
+ });
408
372
  }
409
373
 
410
374
  - (void)button:(FLICButton *)button didFailToConnectWithError:(NSError * _Nullable)error {
411
- [self emitOnButtonEvent:@{
412
- @"uuid": button.uuid,
413
- @"event": @"connectionFailed",
414
- @"error": @{
415
- @"code": @(error.code),
416
- @"message": error.localizedDescription
417
- },
418
- @"button": [self buttonToDictionary:button]
419
- }];
375
+ dispatch_async(dispatch_get_main_queue(), ^{
376
+ [self emitOnButtonEvent:@{
377
+ @"uuid": button.uuid,
378
+ @"event": @"connectionFailed",
379
+ @"error": @{
380
+ @"code": @(error.code),
381
+ @"message": error.localizedDescription
382
+ },
383
+ @"button": [self buttonToDictionary:button]
384
+ }];
385
+ });
420
386
  }
421
387
 
422
388
  - (void)button:(FLICButton *)button didReceiveButtonDown:(BOOL)queued age:(NSInteger)age {
423
- [self emitOnButtonEvent:@{
424
- @"uuid": button.uuid,
425
- @"event": @"buttonDown",
426
- @"queued": @(queued),
427
- @"age": @(age),
428
- @"button": [self buttonToDictionary:button]
429
- }];
389
+ dispatch_async(dispatch_get_main_queue(), ^{
390
+ [self emitOnButtonEvent:@{
391
+ @"uuid": button.uuid,
392
+ @"event": @"buttonDown",
393
+ @"queued": @(queued),
394
+ @"age": @(age),
395
+ @"button": [self buttonToDictionary:button]
396
+ }];
397
+ });
430
398
  }
431
399
 
432
400
  - (void)button:(FLICButton *)button didReceiveButtonUp:(BOOL)queued age:(NSInteger)age {
433
- [self emitOnButtonEvent:@{
434
- @"uuid": button.uuid,
435
- @"event": @"buttonUp",
436
- @"queued": @(queued),
437
- @"age": @(age),
438
- @"button": [self buttonToDictionary:button]
439
- }];
401
+ dispatch_async(dispatch_get_main_queue(), ^{
402
+ [self emitOnButtonEvent:@{
403
+ @"uuid": button.uuid,
404
+ @"event": @"buttonUp",
405
+ @"queued": @(queued),
406
+ @"age": @(age),
407
+ @"button": [self buttonToDictionary:button]
408
+ }];
409
+ });
440
410
  }
441
411
 
442
412
  - (void)button:(FLICButton *)button didReceiveButtonClick:(BOOL)queued age:(NSInteger)age {
443
- [self emitOnButtonEvent:@{
444
- @"uuid": button.uuid,
445
- @"event": @"click",
446
- @"queued": @(queued),
447
- @"age": @(age),
448
- @"button": [self buttonToDictionary:button]
449
- }];
413
+ dispatch_async(dispatch_get_main_queue(), ^{
414
+ [self emitOnButtonEvent:@{
415
+ @"uuid": button.uuid,
416
+ @"event": @"click",
417
+ @"queued": @(queued),
418
+ @"age": @(age),
419
+ @"button": [self buttonToDictionary:button]
420
+ }];
421
+ });
450
422
  }
451
423
 
452
424
  - (void)button:(FLICButton *)button didReceiveButtonDoubleClick:(BOOL)queued age:(NSInteger)age {
453
- [self emitOnButtonEvent:@{
454
- @"uuid": button.uuid,
455
- @"event": @"doubleClick",
456
- @"queued": @(queued),
457
- @"age": @(age),
458
- @"button": [self buttonToDictionary:button]
459
- }];
425
+ dispatch_async(dispatch_get_main_queue(), ^{
426
+ [self emitOnButtonEvent:@{
427
+ @"uuid": button.uuid,
428
+ @"event": @"doubleClick",
429
+ @"queued": @(queued),
430
+ @"age": @(age),
431
+ @"button": [self buttonToDictionary:button]
432
+ }];
433
+ });
460
434
  }
461
435
 
462
436
  - (void)button:(FLICButton *)button didReceiveButtonHold:(BOOL)queued age:(NSInteger)age {
463
- [self emitOnButtonEvent:@{
464
- @"uuid": button.uuid,
465
- @"event": @"hold",
466
- @"queued": @(queued),
467
- @"age": @(age),
468
- @"button": [self buttonToDictionary:button]
469
- }];
437
+ dispatch_async(dispatch_get_main_queue(), ^{
438
+ [self emitOnButtonEvent:@{
439
+ @"uuid": button.uuid,
440
+ @"event": @"hold",
441
+ @"queued": @(queued),
442
+ @"age": @(age),
443
+ @"button": [self buttonToDictionary:button]
444
+ }];
445
+ });
470
446
  }
471
447
 
472
448
  - (void)button:(FLICButton *)button didUnpairWithError:(NSError * _Nullable)error {
473
- [self emitOnButtonEvent:@{
474
- @"uuid": button.uuid,
475
- @"event": @"unpaired",
476
- @"button": [self buttonToDictionary:button]
477
- }];
449
+ dispatch_async(dispatch_get_main_queue(), ^{
450
+ [self emitOnButtonEvent:@{
451
+ @"uuid": button.uuid,
452
+ @"event": @"unpaired",
453
+ @"button": [self buttonToDictionary:button]
454
+ }];
455
+ });
478
456
  }
479
457
 
480
458
  - (void)button:(FLICButton *)button didUpdateBatteryVoltage:(float)voltage {
481
- [self emitOnButtonEvent:@{
482
- @"uuid": button.uuid,
483
- @"event": @"batteryUpdate",
484
- @"voltage": @(voltage),
485
- @"button": [self buttonToDictionary:button]
486
- }];
459
+ dispatch_async(dispatch_get_main_queue(), ^{
460
+ [self emitOnButtonEvent:@{
461
+ @"uuid": button.uuid,
462
+ @"event": @"batteryUpdate",
463
+ @"voltage": @(voltage),
464
+ @"button": [self buttonToDictionary:button]
465
+ }];
466
+ });
487
467
  }
488
468
 
489
469
  - (void)button:(FLICButton *)button didUpdateNickname:(NSString *)nickname {
490
- [self emitOnButtonEvent:@{
491
- @"uuid": button.uuid,
492
- @"event": @"nicknameUpdate",
493
- @"nickname": nickname,
494
- @"button": [self buttonToDictionary:button]
495
- }];
470
+ dispatch_async(dispatch_get_main_queue(), ^{
471
+ [self emitOnButtonEvent:@{
472
+ @"uuid": button.uuid,
473
+ @"event": @"nicknameUpdate",
474
+ @"nickname": nickname,
475
+ @"button": [self buttonToDictionary:button]
476
+ }];
477
+ });
496
478
  }
497
479
 
498
480
  // MARK: - Helper Methods
499
481
 
482
+ - (FLICButton *)findButtonByUUID:(NSString *)uuid {
483
+ NSArray<FLICButton *> *buttons = [[FLICManager sharedManager] buttons];
484
+ for (FLICButton *button in buttons) {
485
+ if ([button.uuid isEqualToString:uuid]) {
486
+ return button;
487
+ }
488
+ }
489
+ return nil;
490
+ }
491
+
500
492
  - (NSDictionary *)buttonToDictionary:(FLICButton *)button {
501
493
  return @{
502
494
  @"uuid": button.uuid,
@@ -579,18 +571,54 @@
579
571
  }
580
572
  }
581
573
 
582
- - (NSString *)scannerEventToString:(FLICButtonScannerStatusEvent)event {
583
- switch (event) {
584
- case FLICButtonScannerStatusEventDiscovered:
585
- return @"discovered";
586
- case FLICButtonScannerStatusEventConnected:
587
- return @"connected";
588
- case FLICButtonScannerStatusEventVerified:
589
- return @"verified";
590
- case FLICButtonScannerStatusEventVerificationFailed:
591
- return @"verificationFailed";
574
+ - (NSInteger)mapScanErrorToResultCode:(NSError *)error {
575
+ if (!error) {
576
+ return 0; // SUCCESS
577
+ }
578
+
579
+ switch (error.code) {
580
+ case FLICButtonScannerErrorCodeBluetoothNotActivated:
581
+ return 2; // BLUETOOTH_NOT_ACTIVATED
582
+ case FLICButtonScannerErrorCodeUnknown:
583
+ return 3; // UNKNOWN
584
+ case FLICButtonScannerErrorCodeNoPublicButtonDiscovered:
585
+ return 4; // NO_PUBLIC_BUTTON_DISCOVERED
586
+ case FLICButtonScannerErrorCodeAlreadyConnectedToAnotherDevice:
587
+ return 5; // ALREADY_CONNECTED_TO_ANOTHER_DEVICE
588
+ case FLICButtonScannerErrorCodeConnectionTimeout:
589
+ return 6; // CONNECTION_TIMEOUT
590
+ case FLICButtonScannerErrorCodeInvalidVerifier:
591
+ return 7; // INVALID_VERIFIER
592
+ case FLICButtonScannerErrorCodeBLEPairingFailedPreviousPairingAlreadyExisting:
593
+ return 8; // BLE_PAIRING_FAILED_PREVIOUS_PAIRING_ALREADY_EXISTING
594
+ case FLICButtonScannerErrorCodeBLEPairingFailedUserCanceled:
595
+ return 9; // BLE_PAIRING_FAILED_USER_CANCELED
596
+ case FLICButtonScannerErrorCodeBLEPairingFailedUnknownReason:
597
+ return 10; // BLE_PAIRING_FAILED_UNKNOWN_REASON
598
+ case FLICButtonScannerErrorCodeAppCredentialsDontMatch:
599
+ return 11; // APP_CREDENTIALS_DONT_MATCH
600
+ case FLICButtonScannerErrorCodeUserCanceled:
601
+ return 12; // USER_CANCELED
602
+ case FLICButtonScannerErrorCodeInvalidBluetoothAddress:
603
+ return 13; // INVALID_BLUETOOTH_ADDRESS
604
+ case FLICButtonScannerErrorCodeGenuineCheckFailed:
605
+ return 14; // GENUINE_CHECK_FAILED
606
+ case FLICButtonScannerErrorCodeTooManyApps:
607
+ return 15; // TOO_MANY_APPS
608
+ case FLICButtonScannerErrorCodeCouldNotSetBluetoothNotify:
609
+ return 16; // COULD_NOT_SET_BLUETOOTH_NOTIFY
610
+ case FLICButtonScannerErrorCodeCouldNotDiscoverBluetoothServices:
611
+ return 17; // COULD_NOT_DISCOVER_BLUETOOTH_SERVICES
612
+ case FLICButtonScannerErrorCodeButtonDisconnectedDuringVerification:
613
+ return 18; // BUTTON_DISCONNECTED_DURING_VERIFICATION
614
+ case FLICButtonScannerErrorCodeFailedToEstablish:
615
+ return 19; // FAILED_TO_ESTABLISH
616
+ case FLICButtonScannerErrorCodeConnectionLimitReached:
617
+ return 20; // CONNECTION_LIMIT_REACHED
618
+ case FLICButtonScannerErrorCodeNotInPublicMode:
619
+ return 21; // NOT_IN_PUBLIC_MODE
592
620
  default:
593
- return @"unknown";
621
+ return 3; // UNKNOWN
594
622
  }
595
623
  }
596
624
 
@@ -4,6 +4,32 @@ import { TurboModuleRegistry } from 'react-native';
4
4
 
5
5
  // MARK: - Event Types
6
6
 
7
+ export let ScanResult = /*#__PURE__*/function (ScanResult) {
8
+ ScanResult[ScanResult["SUCCESS"] = 0] = "SUCCESS";
9
+ ScanResult[ScanResult["ALREADY_RUNNING"] = 1] = "ALREADY_RUNNING";
10
+ ScanResult[ScanResult["BLUETOOTH_NOT_ACTIVATED"] = 2] = "BLUETOOTH_NOT_ACTIVATED";
11
+ ScanResult[ScanResult["UNKNOWN"] = 3] = "UNKNOWN";
12
+ ScanResult[ScanResult["NO_PUBLIC_BUTTON_DISCOVERED"] = 4] = "NO_PUBLIC_BUTTON_DISCOVERED";
13
+ ScanResult[ScanResult["ALREADY_CONNECTED_TO_ANOTHER_DEVICE"] = 5] = "ALREADY_CONNECTED_TO_ANOTHER_DEVICE";
14
+ ScanResult[ScanResult["CONNECTION_TIMEOUT"] = 6] = "CONNECTION_TIMEOUT";
15
+ ScanResult[ScanResult["INVALID_VERIFIER"] = 7] = "INVALID_VERIFIER";
16
+ ScanResult[ScanResult["BLE_PAIRING_FAILED_PREVIOUS_PAIRING_ALREADY_EXISTING"] = 8] = "BLE_PAIRING_FAILED_PREVIOUS_PAIRING_ALREADY_EXISTING";
17
+ ScanResult[ScanResult["BLE_PAIRING_FAILED_USER_CANCELED"] = 9] = "BLE_PAIRING_FAILED_USER_CANCELED";
18
+ ScanResult[ScanResult["BLE_PAIRING_FAILED_UNKNOWN_REASON"] = 10] = "BLE_PAIRING_FAILED_UNKNOWN_REASON";
19
+ ScanResult[ScanResult["APP_CREDENTIALS_DONT_MATCH"] = 11] = "APP_CREDENTIALS_DONT_MATCH";
20
+ ScanResult[ScanResult["USER_CANCELED"] = 12] = "USER_CANCELED";
21
+ ScanResult[ScanResult["INVALID_BLUETOOTH_ADDRESS"] = 13] = "INVALID_BLUETOOTH_ADDRESS";
22
+ ScanResult[ScanResult["GENUINE_CHECK_FAILED"] = 14] = "GENUINE_CHECK_FAILED";
23
+ ScanResult[ScanResult["TOO_MANY_APPS"] = 15] = "TOO_MANY_APPS";
24
+ ScanResult[ScanResult["COULD_NOT_SET_BLUETOOTH_NOTIFY"] = 16] = "COULD_NOT_SET_BLUETOOTH_NOTIFY";
25
+ ScanResult[ScanResult["COULD_NOT_DISCOVER_BLUETOOTH_SERVICES"] = 17] = "COULD_NOT_DISCOVER_BLUETOOTH_SERVICES";
26
+ ScanResult[ScanResult["BUTTON_DISCONNECTED_DURING_VERIFICATION"] = 18] = "BUTTON_DISCONNECTED_DURING_VERIFICATION";
27
+ ScanResult[ScanResult["FAILED_TO_ESTABLISH"] = 19] = "FAILED_TO_ESTABLISH";
28
+ ScanResult[ScanResult["CONNECTION_LIMIT_REACHED"] = 20] = "CONNECTION_LIMIT_REACHED";
29
+ ScanResult[ScanResult["NOT_IN_PUBLIC_MODE"] = 21] = "NOT_IN_PUBLIC_MODE";
30
+ return ScanResult;
31
+ }({});
32
+
7
33
  // MARK: - Flic2 Types
8
34
 
9
35
  // MARK: - Mode Types
@@ -1 +1 @@
1
- {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeFlic2.ts"],"mappings":";;AAAA,SACEA,mBAAmB,QAGd,cAAc;;AAErB;;AA+CA;;AAsDA;;AAKA;;AA4CA,eAAeA,mBAAmB,CAACC,YAAY,CAAO,OAAO,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["TurboModuleRegistry","ScanResult","getEnforcing"],"sourceRoot":"../../src","sources":["NativeFlic2.ts"],"mappings":";;AAAA,SACEA,mBAAmB,QAGd,cAAc;;AAErB;;AASA,WAAYC,UAAU,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA;;AA6DtB;;AAgDA;;AAKA;;AAwCA,eAAeD,mBAAmB,CAACE,YAAY,CAAO,OAAO,CAAC","ignoreList":[]}