I am a new in Bluetooth connection and I want to add second device in my iOS project. I already have one device, and the new device is very similar with first one, but little bit deferent. I have one process for the two devices, and I did not change a lot of code, just created all value for the new device. My all devices have different name and identifier, first device is working fine. For creating UUID values, I used UUID generator.
let deviceTwoServiceUUID = “59DE3994-6A63-4654-8FF0-F85C5163B2F5”
let deviceTwoFirstCharacteristicUUID = “59DE3994-6A63-4654-8FF0-F85C5163B2F6”
let deviceTwoSecondCharacteristicUUID = “59DE3994-6A63-4654-8FF0-F85C5163B2F7”
let deviceOneServiceUUID = “A6AF4483-E210-457B-B9D6-B8A621513D1D”
let deviceOneFirstCharacteristicUUID = “A6AF4483-E210-457B-B9D6-B8A621513D2D”
let deviceOneSecondCharacteristicUUID = “A6AF4483-E210-457B-B9D6-B8A621513D2D”
}
class BleManager: NSObject, CBCentralManagerDelegate, CBPeripheralDelegate {
@objc private(set) static var sharedInstance = BleManager()
var cbManager : CBCentralManager? = nil
var currentPeripheral : CBPeripheral? = nil
var secondService : CBService? = nil
var firstService : CBService? = nil
var secondFirstCharacteristic : CBCharacteristic!
var secondSecondCharacteristic : CBCharacteristic!
var firstFirstCharacteristic : CBCharacteristic!
var firstSecondCharacteristic : CBCharacteristic!
func initCentralManager() {
		if cbManager == nil {
				cbManager = CBCentralManager(delegate: self, queue: nil, options: [CBCentralManagerOptionRestoreIdentifierKey : “MyApp”, CBCentralManagerOptionShowPowerAlertKey: true])						
		}
func deinitCentralManager() {
		cbManager = nil
}
func isBluetoothAvailable() -> Bool {
		return cbManager?.state == CBManagerState.poweredOn
}
func scan() {
		if (cbManager != nil && (cbManager?.isScanning)!) {
				return
		}
		
		discoveredPeripherals.removeAll()
		
		let serviceUUIDs = [CBUUID(string: BleConstants.deviceTwoServiceUUID), CBUUID(string: BleConstants.deviceOneServiceUUID)]
		
		cbManager?.scanForPeripherals(withServices: serviceUUIDs,
																	options: [CBCentralManagerScanOptionAllowDuplicatesKey : 1])
}
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
		if(!discoveredPeripherals.contains(peripheral)) {
				discoveredPeripherals.append(peripheral)
		}
}
func stopScan() {
		if cbManager != nil && (cbManager?.isScanning)! {
				cbManager?.stopScan()
		}
}
func connect(peripheral: CBPeripheral) {
		if cbManager?.state == CBManagerState.poweredOn {
				if currentPeripheral == nil || currentPeripheral?.state != CBPeripheralState.connected {
						cbManager?.connect(peripheral, options: nil)
				} else {
						cbManager?.cancelPeripheralConnection(peripheral)
				}
		}
}
func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
Device.savePeripheralString(peripheral: peripheral.identifier.uuidString)
		AutoConnect.stop()
DeviceUpdate.updateProgress = .None
Device.isDongleConnected = true
currentPeripheral = peripheral
currentPeripheral?.delegate = self
currentPeripheral?.discoverServices(nil)
disableSleep()
}
func disableSleep() {
		UIApplication.shared.isIdleTimerDisabled = true
}
func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
if error != nil {
				return
		}
		if let services = peripheral.services {
				for service in services {
						if service.uuid.uuidString == BleConstants.deviceTwoServiceUUID {
				Device.dongleType = port.second
										secondService = service
								peripheral.discoverCharacteristics(nil, for: service)
				}
						if service.uuid.uuidString == BleConstants.deviceOneServiceUUID {
				Device.dongleType = port.first
								firstService = service
								peripheral.discoverCharacteristics(nil, for: service)
						} else {
								Log.bt("didDiscoverServices for peripheral not found \(peripheral.identifier.uuidString)")
						}
				}
		}
}
func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) {
		for characteristic in service.characteristics! {
				if characteristic.uuid.uuidString == BleConstants.deviceOneFirstCharacteristicUUID {
		 firstCharacteristic = characteristic
				}	
		else if characteristic.uuid.uuidString == BleConstants.deviceOneSecondCharacteristicUUID {
					 firstSecondCharacteristic = characteristic
				else if characteristic.uuid.uuidString == BleConstants.deviceTwoFirstCharacteristicUUID {
						secondFirstCharacteristic = characteristic
				} else if characteristic.uuid.uuidString == BleConstants.deviceTwoSecondCharacteristicUUID {
		secondSecondCharacteristic = characteristic
				} else {
						Log.bt("didDiscoverCharacteristics not found \(characteristic.uuid.uuidString)")
				}
		}
		
		if Device.dongleType == .deviceTwo {
				 openPortDeviceTwo()
		} else {
				openPortDeviceOne()
		}
}
Do you have idea, Did I create UUIDs correct?
P.S: Android app works fine with both devices.
Thanks a lot!
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hello,
I got crash and I can see it in Crash Feedback, when I download zip file, I can see only feedback.json. Feedback.json file doesn't provide me information about the crash. Where is my Console.log or crash report and why it happened? And how I can fix it? I did not have this problem before, and I have some issues where I am able to get the Console.log and/or Crash report.
Thank you for your help.
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect
Tags:
App Store Connect
Xcode
TestFlight
I did not change nothing in my code, but after iOS 14 and Xcode 12 I started to get the crashes. Previous build was on Xcode 11 and I didn't see the crashes, I tried to create same test cases for deferent iOS and Xcode, and I don’t see the crashes in previous build. I started to get the crashes, only for iOS 14 operating systems and after using Xcode 12.
My function, where I think I have the crash, but I don't understand where exactly, because I didn't change nothing. Maybe something changed in Core Data?
(NSMutableArray *)getObjectsforEntity:(NSString *)strEntity sortBy:(NSString *)strSort isAscending:(BOOL)ascending predicate:(NSPredicate *)predicate {
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:strEntity];
if (strSort) {
NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:strSort ascending:ascending];
[fetchRequest setSortDescriptors:[NSArray arrayWithObject:sort]];
}
if (predicate) {
[fetchRequest setPredicate:predicate];
}
NSError *error;
NSMutableArray *result = [[[[self managedObjectContext] executeFetchRequest:fetchRequest error:&error] mutableCopy ]autorelease];
if (result == nil) {
return [[NSMutableArray alloc] init];
}
return result;
}
I tried to caught it and this is what I found:
==13048==ERROR: AddressSanitizer: allocator is out of memory trying to allocate 0x1a0 bytes
==13048==FATAL: AddressSanitizer: internal allocator is out of memory trying to allocate 0x50 bytes
AddressSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report.
(lldb) thread info -s
thread #1: tid = 0x12fa63, 0x00000001041961f8 libclangrt.asaniosdynamic.dylib`asan::AsanDie(), queue = 'SQLQueue 0x16572e2c0 for MyApp.sqlite', stop reason = AddressSanitizer detected: out-of-memory
{
"accesssize": 0,
"accesstype": 0,
"address": 0,
"description": "out-of-memory",
"instrumentationclass": "AddressSanitizer",
"pc": 0,
"stoptype": "fatalerror"
}
This is what I see in log:
self RMNDatabaseManager * 0x164416210 0x0000000164416210
NSObject NSObject
isa _unsafeunretained Class RMNDatabaseManager 0x000021a1019b6131
predicate NSPredicate * 0x2d7143b90 0x00000002d7143b90
NSObject NSObject
predicateFlags struct predicateFlags
evaluationBlocked unsigned int 0
reservedPredicateFlags unsigned int 0
reserved uint32t 0
fetchRequest NSFetchRequest * 0x2ce26f2d0 0x00000002ce26f2d0
NSPersistentStoreRequest NSPersistentStoreRequest
NSObject NSObject
isa unsafeunretained Class 0x61a1fb9ef989 0x000061a1fb9ef989
error NSError * domain: nil - code: 1287 0x0000000102957960
NSObject NSObject
isa _unsafeunretained Class 0x102957880 0x0000000102957880
reserved void * 0x10295792c 0x000000010295792c
code NSInteger 1287
domain NSString * 0x303 0x0000000000000303
NSObject NSObject
isa unsafeunretained Class 0x0
userInfo NSDictionary * 0x20ff 0x00000000000020ff
NSObject NSObject
isa unsafeunretained Class 0x0
result NSMutableArray * 0x2d5131420 0x00000002d5131420
NSArray NSArray
NSObject NSObject
isa _unsafeunretained Class 0x154000452 0x0000000154000452
Crashlog details:
[[Crashed: 0 CoreData 0x000000019d9fb6b8 PFObjectIDFastHash64 + 36 (NSBasicObjectID.m:707) 1 CoreData 0x000000019d9fb6b4 PFObjectIDFastHash64 + 32 (NSBasicObjectID.m:706) 2 CoreFoundation 0x0000000197c1c10c CFBasicHashRehash + 996 (CFBasicHash.c:477) 3 CoreFoundation 0x0000000197c1fdf4 CFBasicHashRemoveValue + 2352 (CFBasicHash.c:1386) 4 CoreFoundation 0x0000000197b3e2f8 CFDictionaryRemoveValue + 224 (CFDictionary.c:471) 5 CoreData 0x000000019d94b8e8 -[NSManagedObjectContext(NSInternalAdditions) forgetObject:propagateToObjectStore:removeFromRegistry:] + 120 (NSManagedObjectContext.m:5088) 6 CoreData 0x000000019d92b450 -[PFManagedObjectReferenceQueue processReferenceQueue:] + 864 (NSManagedObjectContext.m:5077) 7 CoreData 0x000000019da43578 90-[NSManagedObjectContext(NSInternalNotificationHandling) registerAsyncReferenceCallback]blockinvoke + 68 (NSManagedObjectContext.m:8825) 8 CoreData 0x000000019da39b18 developerSubmittedBlockToNSManagedObjectContextPerform + 156 (NSManagedObjectContext.m:3880) 9 libdispatch.dylib 0x000000019782b280 dispatchclientcallout + 16 (object.m:559) 10 libdispatch.dylib 0x00000001977d3fa8 dispatchlaneserialdrain$VARIANT$mp + 612 (inlineinternal.h:2548) 11 libdispatch.dylib 0x00000001977d4a84 dispatchlaneinvoke$VARIANT$mp + 424 (queue.c:3862) 12 libdispatch.dylib 0x00000001977de518 dispatchworkloopworkerthread + 712 (queue.c:6590) 13 libsystempthread.dylib 0x00000001dc7005a4 pthreadwqthread + 272 (pthread.c:2193) 14 libsystempthread.dylib 0x00000001dc703874 startwqthread + 8]]
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags:
iOS
Xcode
Xcode Sanitizers and Runtime Issues