I am working on a Bluetooth LE application for iOS. I am using the Core Bluetooth framework within iOS to handle all communications.
Question & Description:
When I use a single tag, despite numerous connections and disconnections, the single tag connects seamlessly and the phone discovers it services.
Also, when multiple Bluetooth LE tags connect for the first time, they connect seamlessly and the phone discovers their services.
When the tags get disconnected and then reconnect to the phone, the tags connect fine. But one of the two tags (either one) does not seem to advertise its services. i.e when the app is open and the tag reconnects, the DiscoverServices method does not call the didDiscoverServices delegate.
Why is this happening only when connection with multiple devices takes place.
I have set the peripheral.delegate correctly. I have tried everything, including doing repeated re-connect, repeated DiscoverServices calls to the tag. Nothing seems to work.
How can I re-connect to multiple tags to the phone and still discover all services.
Please help
Thanks,
Manju
Turns out that there was command I was issuing to the device in the”didDiscovercharacteristicsForService” delegate method which was causing the connection instability.
If you are facing similar issues, I suggest you to let the delegate method complete without any intervention (of any kind) and pass the CBPeripheral to another function designed by you to pass any values / issue a command to the devices.
Thanks anyway Wilhemsen.
So the steps are as follows..
1> Search for Tag,
2> If in range, CONNECT to Tag
3> If Connected, call DISCOVER services method (do not interrupt)
4> IN DidDiscoverServices, call DISCOVER Characteristics Method
..
In DidDiscoverCharacteristics Method, wait until all Characteristics are discovered..
Then , at the end, call a function in your code that will do the necessary setup..
…
Code Sample