generated from StanfordBDHG/SwiftPackageTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 4
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 retrieving known Peripherals #38
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #38 +/- ##
==========================================
+ Coverage 75.73% 77.19% +1.47%
==========================================
Files 99 102 +3
Lines 4523 5265 +742
==========================================
+ Hits 3425 4064 +639
- Misses 1098 1201 +103
Continue to review full report in Codecov by Sentry.
|
…r `discarded` property
…eziBluetoothServices
…guration of discovery options
1 task
Supereg
force-pushed
the
feature/accessory-discovery
branch
from
June 26, 2024 12:31
d746a50
to
4ba8359
Compare
Supereg
commented
Jun 26, 2024
Supereg
force-pushed
the
feature/accessory-discovery
branch
from
June 26, 2024 16:34
e5e773f
to
442fc0d
Compare
Supereg
commented
Jun 27, 2024
Supereg
commented
Jun 27, 2024
1 task
Supereg
added a commit
that referenced
this pull request
Jul 1, 2024
# Update SPI file with latest targets ## ♻️ Current situation & Problem This PR fixes documentation deployment as target names are outdate din the `.spi.yml` file after merging #38. ## ⚙️ Release Notes - Fix SPI target names for documentation deployment. ## 📝 Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md): - [x] I agree to follow the [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Support retrieving Peripherals
♻️ Current situation & Problem
SpeziBluetooth is currently optimized for device discovery and ad-hoc connection establishment. However, when dealing with device pairing, one typically scans for nearby devices once and saving the peripheral identifier and perform long running connection attempts (e.g., calling
retrievePeripherals(withidentifiers:)
and calling connect()). Connecting a peripheral does not time out and is therefore the most efficient way of establishing Bluetooth connecting with a set of known Bluetooth devices.To support this use case, some modifications have been made to the underlying SpeziBluetooth infrastructure. New mechanisms were introduced to retrieve known peripherals (
BluetoothManager/retrievePeripheral(for:with:)
andBluetooth/retrieveDevice(for:as:)
). These device instances can stay allocated and SpeziBluetooth automatically frees resources once the framework user deallocates the peripheral instances. Several changes to the lifecycle handling ofBluetoothPeripheral
s andBluetoothDevice
s have been made to support this new interfaces (e.g., carefully managing when objects are kept as strong references and when to reuse objects when, e.g., the same instance is getting discovered at the same time).SpeziDevices
SpeziDevices is an upcoming library to encapsulates a lot of standardized device interactions. This PR is driven by a lot of requirements of this library.
⚙️ Release Notes
BluetoothManager/retrievePeripheral(for:with:)
andBluetooth/retrieveDevice(for:as:)
.BluetoothViews
target was removed and integrated into theSpeziDevicesUI
of the SpezIDevices framework (see Bluetooth Device Pairing Infrastructure and Health Measurements SpeziDevices#1, Breaking).BluetoothServices
target was renamed toSpeziBluetoothServices
for more consistency (Breaking).accessory
discovery criteria.nearby
andlastActivity
state properties for peripherals and devices.name
property and thelocalName
property can now be accessed individually on a peripheral (Breaking).DiscoverySession
for better code overview.scanNearbyDevices(...)
methods and modifiers allowing for more dynamic configuration.Bluetooth/stateSubscription
andBluetoothManager/stateSubscription
to receive an AsyncStream ofBluetoothState
changes useful when required to observe CBCentral changes.CharacteristicAccessor/subscription
andDeviceStateAccessor/subscription
properties to receive an AsyncStream of changes to the characteristic value or device state.onChange(initial:perform:)
methods now must not be set up in the initializer anymore and must not create strong self references. Instead setup onChange handlers in theconfigure()
method and make sure to weakly captureself
. CallingonChange(initial:perform:)
method in the initializer results in a runtime crash with the error message providing a migration guide.powerOn()
andpowerOff()
methods to manually controlCBCentralManager
allocation.ManufacturerIdentifier
model supporting parsing of manufacturer data in the advertisement.ConnectedDevices
environment model to retrieve all connected devices from the SwiftUI environment.Codable
conformance to all Characteristics.This PR contains breaking changes, requiring a major version bump.
📚 Documentation
Documentation was updated to reflect changed symbols (README currently points to 404 pages). Retrieving devices was documented with a small code examples.
✅ Testing
Existing tests verify that refactoring did not break existing infrastructure. Additional test case was added to test retrieving peripherals and ensuring the new reference semantics do not break and peripherals are properly and expectedly deallocated.
📝 Code of Conduct & Contributing Guidelines
By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines: