react-native-bluetooth-escpos-printer-fork 0.0.19 → 0.0.20
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/RNBluetoothManager.m +32 -40
- package/package.json +1 -1
package/ios/RNBluetoothManager.m
CHANGED
|
@@ -280,7 +280,7 @@ RCT_EXPORT_METHOD(scanDevices:(RCTPromiseResolveBlock)resolve
|
|
|
280
280
|
[timer invalidate];
|
|
281
281
|
timer = nil;
|
|
282
282
|
}
|
|
283
|
-
timer = [NSTimer scheduledTimerWithTimeInterval:
|
|
283
|
+
timer = [NSTimer scheduledTimerWithTimeInterval:12 target:self selector:@selector(callStop) userInfo:nil repeats:NO];
|
|
284
284
|
|
|
285
285
|
}
|
|
286
286
|
@catch(NSException *exception){
|
|
@@ -540,52 +540,44 @@ RCT_EXPORT_METHOD(unpaire:(NSString *)address
|
|
|
540
540
|
|
|
541
541
|
// Try to infer device class from advertising data
|
|
542
542
|
// iOS BLE doesn't expose Classic Bluetooth device class, but we can make educated guesses
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
//
|
|
543
|
+
// Build advertisementData dictionary for JS layer
|
|
544
|
+
NSMutableDictionary *advData = [[NSMutableDictionary alloc] init];
|
|
545
|
+
|
|
546
|
+
// Service UUIDs
|
|
547
547
|
NSArray *serviceUUIDs = advertisementData[CBAdvertisementDataServiceUUIDsKey];
|
|
548
|
-
BOOL isPrinter = NO;
|
|
549
|
-
|
|
550
548
|
if (serviceUUIDs && serviceUUIDs.count > 0) {
|
|
549
|
+
NSMutableArray *uuidStrings = [[NSMutableArray alloc] init];
|
|
551
550
|
for (CBUUID *uuid in serviceUUIDs) {
|
|
552
|
-
|
|
553
|
-
// Serial Port Profile (SPP) UUID - common for printers
|
|
554
|
-
// Also check for other printer-related service UUIDs
|
|
555
|
-
if ([uuidString isEqualToString:@"00001101-0000-1000-8000-00805F9B34FB"] ||
|
|
556
|
-
[uuidString isEqualToString:@"49535343-FE7D-4AE5-8FA9-9FAFD205E455"] ||
|
|
557
|
-
[uuidString containsString:@"18F0"]) {
|
|
558
|
-
isPrinter = YES;
|
|
559
|
-
break;
|
|
560
|
-
}
|
|
551
|
+
[uuidStrings addObject:uuid.UUIDString];
|
|
561
552
|
}
|
|
553
|
+
[advData setObject:uuidStrings forKey:@"serviceUUIDs"];
|
|
562
554
|
}
|
|
563
|
-
|
|
564
|
-
//
|
|
565
|
-
NSString *
|
|
566
|
-
if (
|
|
567
|
-
[
|
|
568
|
-
[name containsString:@"ESCPOS"] ||
|
|
569
|
-
[name containsString:@"THERMAL"] ||
|
|
570
|
-
[name containsString:@"RECEIPT"]) {
|
|
571
|
-
isPrinter = YES;
|
|
555
|
+
|
|
556
|
+
// Local name (may differ from peripheral.name)
|
|
557
|
+
NSString *localName = advertisementData[CBAdvertisementDataLocalNameKey];
|
|
558
|
+
if (localName) {
|
|
559
|
+
[advData setObject:localName forKey:@"localName"];
|
|
572
560
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
majorDeviceClass = 1536; // 0x0600 in decimal
|
|
579
|
-
deviceClass = 1664; // 0x0680 in decimal
|
|
580
|
-
} else {
|
|
581
|
-
// Unknown/Unclassified device
|
|
582
|
-
// Major Device Class: 0x1F00 (Uncategorized)
|
|
583
|
-
majorDeviceClass = 7936; // 0x1F00 in decimal
|
|
584
|
-
deviceClass = 7936;
|
|
561
|
+
|
|
562
|
+
// Manufacturer data as base64
|
|
563
|
+
NSData *manufacturerData = advertisementData[CBAdvertisementDataManufacturerDataKey];
|
|
564
|
+
if (manufacturerData) {
|
|
565
|
+
[advData setObject:[manufacturerData base64EncodedStringWithOptions:0] forKey:@"manufacturerData"];
|
|
585
566
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
567
|
+
|
|
568
|
+
// TX power level
|
|
569
|
+
NSNumber *txPowerLevel = advertisementData[CBAdvertisementDataTxPowerLevelKey];
|
|
570
|
+
if (txPowerLevel) {
|
|
571
|
+
[advData setObject:txPowerLevel forKey:@"txPowerLevel"];
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// Connectable flag
|
|
575
|
+
NSNumber *isConnectable = advertisementData[CBAdvertisementDataIsConnectable];
|
|
576
|
+
if (isConnectable) {
|
|
577
|
+
[advData setObject:isConnectable forKey:@"isConnectable"];
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
[deviceInfo setObject:advData forKey:@"advertisementData"];
|
|
589
581
|
|
|
590
582
|
// Store the peripheral object for connection
|
|
591
583
|
NSDictionary *peripheralStored = @{peripheral.identifier.UUIDString:peripheral};
|