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

Peripheral mode — basic setup, few methods implemented #177

Closed
wants to merge 6 commits into from

Conversation

Kacper20
Copy link
Contributor

In this PR:

I've setup a new class for CBPeripheralManager reactive wrapper. I've renamed the current BluetoothManager into CentralManager which probably makes more sense.
Implemented sharing of basic things like state management and helper function between two managers.
For PeripheralManager full wrappers around the delegates are written.
Also implemented initialisers, basic properties and startAdvertising method. It still needs some polishing like documentation. I will add this later today.

Partially addresses #166
More of the interface for PeripheralManager will be added in subsequent PRs — it's done this way to break it down into smaller pieces, more manageable to review them.

Please let me know what you think!

willRestoreStateSubject.onNext(dict)
}

func peripheralManagerDidStartAdvertising(_: CBPeripheralManager, error: Error?) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing logs for all other callbacks.

@@ -170,36 +168,31 @@ public class BluetoothManager {
return operation
}()
// Allow scanning as long as bluetooth is powered on
return strongSelf.ensure(.poweredOn, observable: observable)
return strongSelf.ensure(state: .poweredOn, observable: observable)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we are changing signature here we could rename second to for

/// - parameter peripheralManager: CBPeripheralManager instance used to perform peripheral mode operations
/// - parameter queueScheduler: Scheduler on which all serialised operations are executed (such as scans). By default main thread is used.
init(peripheralManager: CBPeripheralManager,
queueScheduler: SchedulerType = ConcurrentMainScheduler.instance) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

queueScheduler is not needed.


/// Creates new `PeripheralManager`
/// - parameter peripheralManager: CBPeripheralManager instance used to perform peripheral mode operations
/// - parameter queueScheduler: Scheduler on which all serialised operations are executed (such as scans). By default main thread is used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove line from comment as well

}

public typealias AdvertisingStarted = Void
//TODO: Docs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO?

.subscribe(onNext: { [weak self] advertisement in
self?.peripheralManager.startAdvertising(advertisement)
})
strongSelf.peripheralManager.startAdvertising(advertisementData.value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line and skip(1) from above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Thanks!

@Kacper20 Kacper20 closed this Jan 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants