After updating to OSX 12 and revisiting an old project, I find that my CBCentralManager interfacing code no longer works:
// this does get called
- (void) controlSetup
{
NSLog(@"BLE::controlSetup");
self.CM = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
}
- (int) findBLEPeripherals:(int) timeout
{
if (self.CM.state != CBManagerStatePoweredOn)
{
return -1;
}
[NSTimer scheduledTimerWithTimeInterval:(float)timeout target:self selector:@selector(scanTimer:) userInfo:nil repeats:NO];
//[self.CM scanForPeripheralsWithServices:nil options:nil]; // doesn't work
// also doesn't work
NSDictionary *scanOptions = @{CBCentralManagerScanOptionAllowDuplicatesKey:@(YES)};
[self.CM scanForPeripheralsWithServices:nil options:scanOptions];
return 0; // Started scanning OK
}
// rest of CBCentralManagerDelegate methods omitted for brevity
// is no longer triggered:
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
{
NSLog(@"BLE::didDiscoverPeripheral didDiscoverPeripheral");
}
The CBCentralManager property is set up as strong and nonatomic, so I don't think it's getting collected anywhere:
@property (strong, nonatomic) CBCentralManager *CM;
This project is usually a plugin for Unity and until OSX12.0 was working as expected when run in the editor and in applications built in Unity. Does anyone have thoughts on why this might have suddenly stopped working or what I might try?