-
Notifications
You must be signed in to change notification settings - Fork 375
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
Conversation
willRestoreStateSubject.onNext(dict) | ||
} | ||
|
||
func peripheralManagerDidStartAdvertising(_: CBPeripheralManager, error: Error?) { |
There was a problem hiding this comment.
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.
Source/CentralManager.swift
Outdated
@@ -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) |
There was a problem hiding this comment.
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
Source/PeripheralManager.swift
Outdated
/// - 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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
queueScheduler is not needed.
Source/PeripheralManager.swift
Outdated
|
||
/// 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. |
There was a problem hiding this comment.
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
Source/PeripheralManager.swift
Outdated
} | ||
|
||
public typealias AdvertisingStarted = Void | ||
//TODO: Docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO?
Source/PeripheralManager.swift
Outdated
.subscribe(onNext: { [weak self] advertisement in | ||
self?.peripheralManager.startAdvertising(advertisement) | ||
}) | ||
strongSelf.peripheralManager.startAdvertising(advertisementData.value) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Thanks!
In this PR:
I've setup a new class for
CBPeripheralManager
reactive wrapper. I've renamed the currentBluetoothManager
intoCentralManager
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!