Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
In my CentralDelegateManager subclass I override RetrievedConnectedPeripherals. In that method I iterate through my CBPeripheral and for each peripheral I have tried both setting its delegate to a CBPeripheralDelegate subclass and hooking up to the DiscoveredService event. Then I call peripheral.DiscoverServices. I have tried both passing in the specific CBUUID for the service on my peripheral and passing in null in which case it should discover any CBServices.
However, neither the CBPeripheralDelegate DiscoveredService method nor my event handler for DiscoveredService ever get fired. In the Apple documentation it seems that the callback should be fired whether successfully or not, if unsuccessful there should be a non null NSError parameter passed in.
As an aside, when calling peripheral.DiscoverServices the current api is not great for passing in null because there is a CBUUID and a Guid passing in a simple null value is an ambiguous method call. So I have to declare:
CBUUID uuids = null;
which is not great.
I have been using the Wahoo Heart Rate Monitor to test this, as well as my own iPad 3 running as a CBPeripheralManager.
I ALWAYS get the didDiscoverServices callback invoked if I use Xcode, so the issue is most likely in MonoTouch. Additionally even though all the peripherals passed into RetrievedConnectedPeripherals are actually connected, peripheral.IsConnected always shows false. I'm sure this is related to the lack of a callback or event for service discovery.
Can you show all the bluetooth related code you have?
This is unfortunately something I can't debug myself, since I'd need to get a bluetooth device, but maybe I have any ideas what you can try out if I see your code.
Please disregard this. Turns out this isn't a Xamarin bug.
It's not an Apple bug either, but rather my confusion around how CoreBluetooth works due to Apple not providing useful documentation for it.
From trolling the dev forums I've found some useful information about this which is under NDA.