Skip to content
This repository was archived by the owner on Jul 20, 2025. It is now read-only.

Commit 9175080

Browse files
author
Stephen Schiffli
committed
Merge branch 'release-3.1.6'
2 parents af953e0 + a272e8a commit 9175080

File tree

18 files changed

+72
-38
lines changed

18 files changed

+72
-38
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 3.1.5
2+
current_version = 3.1.6
33

44
[bumpversion:file:Docs/source/conf.py]
55

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88
### Added
9+
- MetaWearScanner.retrieveConnectedMetaWearsAsync function
10+
11+
### Changed
12+
- Save CBPeripheral's retrieved in willRestoreState
13+
14+
## [3.1.5] - 2018-07-27
15+
### Added
916
- Bluetooth State Restoration on MetaWearScanner.shared
1017

1118
### Changed
1219
- CPP submodule accessed with https instead of git protocol
1320

1421
## [3.1.4] - 2018-07-23
15-
1622
### Changed
1723
- Updated Podspec with the swift-version key and latest Bolts-Swift 1.4.0
1824
- MetaWear-SDK-Cpp v0.16.0

Docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
# built documents.
5656
#
5757
# The short X.Y version.
58-
version = '3.1.5'
58+
version = '3.1.6'
5959
# The full version, including alpha/beta/rc tags.
60-
release = '3.1.5'
60+
release = '3.1.6'
6161

6262
# The language for content autogenerated by Sphinx. Refer to documentation
6363
# for a list of supported languages.

MetaWear.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'MetaWear'
3-
s.version = '3.1.5'
3+
s.version = '3.1.6'
44
s.license = { :type => 'Commercial', :text => 'See https://www.mbientlab.com/terms/', :file => 'LICENSE' }
55
s.homepage = 'https://mbientlab.com'
66
s.summary = 'iOS/macOS/tvOS/watchOS API and documentation for the MetaWear platform'

MetaWear/Core/MetaWearScanner.swift

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ fileprivate var scannerCount = 0
4545
public class MetaWearScanner: NSObject {
4646
public static let shared = MetaWearScanner(restoreIdentifier: "MetaWearScanner.shared")
4747
public var central: CBCentralManager! = nil
48+
/// All devices that have been discovered in one way or another by this central
4849
public var deviceMap: [CBPeripheral: MetaWear] = [:]
4950
public var didUpdateState: ((CBCentralManager) -> Void)? {
5051
didSet {
@@ -96,7 +97,24 @@ public class MetaWearScanner: NSObject {
9697
}
9798
return source.task
9899
}
99-
100+
101+
/// List of devices that are already connected
102+
/// This is useful to check after state was restored
103+
public func retrieveConnectedMetaWearsAsync() -> Task<[MetaWear]> {
104+
let source = TaskCompletionSource<[MetaWear]>()
105+
runWhenPoweredOn {
106+
var devices: [MetaWear] = []
107+
let peripherals = self.central.retrieveConnectedPeripherals(withServices: [.metaWearService,
108+
.metaWearDfuService])
109+
devices = peripherals.map { peripheral -> MetaWear in
110+
let device = self.deviceMap[peripheral] ?? MetaWear(peripheral: peripheral, scanner: self)
111+
self.deviceMap[peripheral] = device
112+
return device
113+
}
114+
source.trySet(result: devices)
115+
}
116+
return source.task
117+
}
100118

101119
// Internal details below
102120
var allowDuplicates: Bool = false
@@ -230,9 +248,19 @@ extension MetaWearScanner: CBCentralManagerDelegate {
230248
public func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) {
231249
deviceMap[peripheral]?.didDisconnectPeripheral(error: error)
232250
}
233-
public func centralManager(_ central: CBCentralManager, willRestoreState dict: [String : Any]) {
251+
public func centralManager(_ central: CBCentralManager, willRestoreState dict: [String : Any]) {
234252
// As an SDK, we arn't sure what operations the user is acutally doing.
235253
// You should place code in didFinishLaunchingWithOptions to kick off any tasks
236254
// you expect to take place
255+
256+
// An array (an instance of NSArray) of CBPeripheral objects that contains
257+
// all of the peripherals that were connected to the central manager
258+
// (or had a connection pending) at the time the app was terminated by the system.
259+
if let peripherals = dict[CBCentralManagerRestoredStatePeripheralsKey] as? [CBPeripheral] {
260+
for peripheral in peripherals {
261+
let device = MetaWear(peripheral: peripheral, scanner: self)
262+
self.deviceMap[peripheral] = device
263+
}
264+
}
237265
}
238266
}

MetaWear/Podfile.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ PODS:
22
- Bolts-Swift (1.4.0)
33
- iOSDFULibrary (4.1.3):
44
- Zip (~> 1.0)
5-
- MetaWear/AsyncUtils (3.1.5):
5+
- MetaWear/AsyncUtils (3.1.6):
66
- MetaWear/Core
7-
- MetaWear/Core (3.1.5):
7+
- MetaWear/Core (3.1.6):
88
- Bolts-Swift (~> 1)
9-
- MetaWear/DFU (3.1.5):
9+
- MetaWear/DFU (3.1.6):
1010
- iOSDFULibrary (~> 4)
1111
- MetaWear/Core
12-
- MetaWear/Mocks (3.1.5):
12+
- MetaWear/Mocks (3.1.6):
1313
- MetaWear/Core
14-
- MetaWear/UI (3.1.5):
14+
- MetaWear/UI (3.1.6):
1515
- MetaWear/AsyncUtils
1616
- MetaWear/Core
1717
- Zip (1.1.0)
@@ -35,7 +35,7 @@ EXTERNAL SOURCES:
3535
SPEC CHECKSUMS:
3636
Bolts-Swift: 650d72e8017721b1a6bbe43d542c4578f8e5ba6f
3737
iOSDFULibrary: 921bc0e250ad204a68ffe0cc98a7cb6ac8b13b9f
38-
MetaWear: fd23fdf6ec1d6b9f19c58767ef53fa4ca04518f3
38+
MetaWear: 547e2a2665921d3c02bad90dd765a89ff29b6b72
3939
Zip: 8877eede3dda76bcac281225c20e71c25270774c
4040

4141
PODFILE CHECKSUM: 40f51631a47326fabd7a7939d3b4c5c6bc3dd8ba

MetaWear/Pods/Local Podspecs/MetaWear.podspec.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MetaWear/Pods/Manifest.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MetaWear/Pods/Target Support Files/MetaWear-AsyncUtils-Core-DFU-Mocks-UI-iOS/Info.plist

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MetaWear/Pods/Target Support Files/MetaWear-AsyncUtils-Core-DFU-Mocks-UI-macOS/Info.plist

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)