Skip to content

Registry lastConnectedPeripheral is always nil #48

@drdaz

Description

@drdaz

I've got the following code:

    self.bluetoothDeviceManager = [WLXBluetoothDeviceManager deviceManager];
    id<WLXBluetoothDeviceRepository> repository = [[WLXBluetoothDeviceUserDefaultsRepository alloc] initWithUserDefaults:[NSUserDefaults standardUserDefaults]];
    WLXBluetoothDeviceRegistry * registry = [self.bluetoothDeviceManager deviceRegistryWithRepository:repository];
    registry.enabled = YES;
    [registry fetchLastConnectedPeripheralWithBlock:^(NSError *error, CBPeripheral *peripheral) {
        if (peripheral) {
            // Connect
            [self connectToPeripheral:peripheral];
        }
        else
        {
            // Discover
            NSObject<WLXDeviceDiscoverer> *discoverer = self.bluetoothDeviceManager.discoverer;
            discoverer.delegate = self;
            [discoverer discoverDevicesNamed:@"MyDeviceName" withServices:nil andTimeout:30000];
        }
    }];

Later on in the flow, I consistently get a connection. But the peripheral variable in the fetchLastConnectedPeripheralWithBlock always comes back nil on next run. In addition the wiki says there's a property called lastConnectedPeripheral on the object we should use, rather than the block-based method.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions