Closed brokkc1 closed 1 year ago
Hello, thanks for the feedback.
our delegate is thrown away
It is not thrown away, it's stored as delegate
. Jus the didSet
implementation doesn't touch it, just checks for presence. This delegate is then called in the code you provided: impl.delegate?...
.
Try changing:
peripheral.discoverServices([])
to
peripheral.discoverServices(nil)
Hi Phillip, Thanks for the quick response,
I've tried changing peripheral.discoverServices([])
to peripheral.discoverServices(nil)
still no luck sadly.
But I do now understand by our delegate is set to impl.delegate
, I can see that now thank you. I'll keep investigating it must be a config issue.
The issue was caused by our delegate being cleaned, keeping an internal reference stopped this from happening.
I am having an issue with service discovery, using version
0.16.1
via Swift package manager.After connecting to our physical device, and issuing
peripheral.discoverServices([])
our delegate is not receiving adidDiscoverCharacteristicsFor
callback.Stepping through the code I have found when we set our delegate it seems that inside
CBMCentralManagerNative.swift
our delegate is thrown away and a wrapper delegate (that has no reference to ours) is used in place.https://github.com/NordicSemiconductor/IOS-CoreBluetooth-Mock/blob/bc042dc9cb2833e3573f8b6d66a54c7a96690104/CoreBluetoothMock/CBMCentralManagerNative.swift#L464-L476
I can see
didDiscoverServices
is being called on theCBPeripheralDelegateWrapper
, but not being passed down to our delegate. https://github.com/NordicSemiconductor/IOS-CoreBluetooth-Mock/blob/bc042dc9cb2833e3573f8b6d66a54c7a96690104/CoreBluetoothMock/CBMCentralManagerNative.swift#L261-L265I set the delegate via the
CBPeripheral
we receive duringdidDiscover
phase. Everything works perfectly when mocking, seems like an issue with the native flow only.Other then that fantastic library, I wrote the code purely against this library and once we received the physical device everything else seems to work perfectly. Well done.