Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for CBPeripheralManager #166

Closed
Kacper20 opened this issue Oct 23, 2017 · 7 comments
Closed

Support for CBPeripheralManager #166

Kacper20 opened this issue Oct 23, 2017 · 7 comments
Assignees
Labels

Comments

@Kacper20
Copy link
Contributor

Kacper20 commented Oct 23, 2017

Our library currently only supports CoreBluetooth central mode.
New object would be named PeripheralManager (with consistent naming to CentralManager)

Design

Since CBCentralManager and CBPeripheralManager both inherit from CBManager which consist state property it would be appropriate to map the same relationship in our hierarchy in order to avoid code duplication. It could be named BaseManager and should take CBManager instance in initializer. This class would expose functions that operate on state, that currently belong to the BluetoothManager, like continuous access to BluetoothState.
Then, both new CentralManager and PeripheralManager would inherit from BaseManager.

Design of PeripheralManager should be analogous to the current CentralManager (After changes from #162 . One that implements it should perform pairing of methods from CBPeripheralManager and the delegates callbacks. Then, every method should be wrapped in an reactive way. Delegate proxy for the CBPeripheralManagerDelegate should also be created.

In What’s New in CoreBluetooth, 712, WWDC 2017 session Apple has announced couple of new APIs as a part of iOS 11 & macOS 13. We would like to support it in our reactive wrappers.

L2CAPChannels

There were 2 main API changes introduced: L2CAPChannels capabilities in Central modes of the CoreBluetooth and enhancements in write without response. L2CAPChannels change should be also a part of #166 task.

CBPeripheralManager instance contains two methods for publishing and unpublishing channels:

  • publishL2CAPChannel(withEncryption: Bool)
  • unpublishL2CAPChannel(CBL2CAPPSM)
    These two have delegate methods that inform about the success of each operation. Exposed interface should be as follows:
  • func publishL2CAPChannel(withEncryption: Bool) -> Observable<CBL2CAPPSM>
  • func unpublishL2CAPChannel(CBL2CAPPSM) -> Observable<CBL2CAPPSM>
    Implementation is pretty standard —> connection to the delegate methods and performing function call on CBPeripheralManager instance. Proper errors should be introduced as a part of BluetoothError structure.

We should also allow user to monitor openings of L2CAPChannel. To do this we should expose function like func monitorL2CAPChannelOpenings -> Observable<CBL2CAPChannel. It would connect to this delegate method. We should probably provide function like publishAndMonitorOpeningsOfL2CAPChannel. Basically the design should be analogous to the setting notification as enabled and monitoring notifications on CBCharacteristic.

L2CAPChannel

It’s a wrapper around CBL2CAPChannel CoreBluetooth object. It should only be created if we would decide to wrap InputStream and OutputStream properties of CBL2CAPChannel into reactive wrappers. If it’ll not be the case (and it probably shouldn’t be) — all of the interface methods should simply return directly CBL2CAPChannel objects.

Affection to current users

Additive changes

@Kacper20 Kacper20 added the todo label Oct 23, 2017
@Kacper20 Kacper20 added this to the 5.0.0 milestone Oct 23, 2017
@Kacper20 Kacper20 self-assigned this Oct 24, 2017
@pouljohn1 pouljohn1 changed the title [5.0] Support for CBPeripheralManager Support for CBPeripheralManager Jan 25, 2018
@pouljohn1 pouljohn1 removed this from the 5.0.0 milestone Jan 25, 2018
@danielbotka
Copy link

Hi, is there any news about the shipping date of this feature (PeripheralManager)? I'd like to use it in the near future and really loved the CentralManager, so would be a clean approach to use this new feature as well.
Thanks for your work!

@pouljohn1
Copy link
Contributor

@danielbotka hey, we are on the final steps before releasing RC version with PeripheralManager support.
Problem here is that currently we are not developing any project that will use that feature. Would you like to test it before releasing stable version?

@danielbotka
Copy link

@paweljaneczek hey, yes, I'd be happy to play around a little, probably next week. Is it on a specific branch?

@pouljohn1
Copy link
Contributor

@danielbotka great to hear! In next week we will have probably RC library version so we will give a sign to you in this thread

@jodm
Copy link

jodm commented May 23, 2018

@paweljaneczek We also have a project that we could integrate this into. Should I try and integrate from the feature/peripheral_manager branch?

@pouljohn1
Copy link
Contributor

@jodm great! For now the newest changes are on feature/peripheral_manager_tests

@pouljohn1
Copy link
Contributor

@jodm @danielbotka We've just release version 5.1.0 with support for PeripheralManager. If you will find any bugs/problems for it just fill new issue on github. Closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants