Skip to content

Commit

Permalink
Merge pull request #359 from NordicSemiconductor/develop
Browse files Browse the repository at this point in the history
Version 3.1.4
  • Loading branch information
philips77 authored Jun 25, 2021
2 parents 5081085 + d97bb92 commit 4d455d3
Show file tree
Hide file tree
Showing 26 changed files with 167 additions and 132 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## Changelog
- **3.1.4**:
- Bugfix: Possible crash fixed when IVI was 1 and IV Index 0 (#358).
- Bugfix: Multiple `self` weakened (#356).
- Allowing groups to be null when importing (#348, #357).

- **3.1.3**:
- Improvement: Migration to Xcode 12.5.
* Improvement: CryptoSwift updated from 1.3.8 to 1.4.0 (https://github.com/krzyzanowskim/CryptoSwift/releases/tag/1.4.0).
Expand Down
2 changes: 1 addition & 1 deletion Documentation/SETTING_UP.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Using CocoaPods:
You can use [Swift Package Manager](https://swift.org/package-manager/) and specify dependency in `Package.swift` by adding this:

```swift
.package(url: "https://github.com/NordicSemiconductor/IOS-nRF-Mesh-Library", .upToNextMinor(from: "3.1.2"))
.package(url: "https://github.com/NordicSemiconductor/IOS-nRF-Mesh-Library", .upToNextMinor(from: "3.1.4"))
```

Also, have a look at [Swift Package Manager @ CryptoSwift](https://github.com/krzyzanowskim/CryptoSwift/blob/master/README.md#swift-package-manager).
Expand Down
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- CryptoSwift (1.4.0)
- nRFMeshProvision (3.1.3):
- nRFMeshProvision (3.1.4):
- CryptoSwift (= 1.4.0)

DEPENDENCIES:
Expand All @@ -16,7 +16,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
CryptoSwift: 7cc902df1784de3b389a387756c7d710f197730c
nRFMeshProvision: 7c95bc28df2ee8ba97ce1df73d04714b5abca1ca
nRFMeshProvision: 4b3e185fd13b077c997aadca6f54806f5c577cd7

PODFILE CHECKSUM: 69a81463322ef34ca0a20b98e90da2701d94e4ec

Expand Down
4 changes: 2 additions & 2 deletions Example/Pods/Local Podspecs/nRFMeshProvision.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions Example/nRFMeshProvision/Utils/UIViewController+Alert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ extension UIViewController {
// TODO: Should only iPad be handled differently? How about carPlay or Apple TV?
let ipad = UIDevice.current.userInterfaceIdiom == .pad
let style: UIAlertController.Style = ipad ? .alert : .actionSheet
DispatchQueue.main.async {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
let alert = UIAlertController(title: title, message: message, preferredStyle: style)
alert.addAction(UIAlertAction(title: "Confirm", style: .destructive, handler: handler))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel))
Expand All @@ -84,7 +85,8 @@ extension UIViewController {
func presentAlert(title: String?, message: String?, cancelable: Bool = false,
option action: UIAlertAction? = nil,
handler: ((UIAlertAction) -> Void)? = nil) {
DispatchQueue.main.async {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: cancelable ? "Cancel" : "OK", style: .cancel, handler: handler))
if let action = action {
Expand All @@ -107,7 +109,8 @@ extension UIViewController {
func presentRangeAlert(title: String?, message: String?, range: RangeObject? = nil,
type selector: Selector? = nil,
handler: ((ClosedRange<UInt16>) -> Void)? = nil) {
DispatchQueue.main.async {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
var alert: UIAlertController? = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert!.addTextField { textField in
textField.text = range?.lowerBound.hex
Expand Down Expand Up @@ -165,7 +168,8 @@ extension UIViewController {
func presentTextAlert(title: String?, message: String?, text: String? = "", placeHolder: String? = "",
type selector: Selector? = nil, option action: UIAlertAction? = nil,
cancelHandler: (() -> Void)? = nil, handler: ((String) -> Void)? = nil) {
DispatchQueue.main.async {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
var alert: UIAlertController? = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert!.addTextField { textField in
textField.text = text
Expand Down Expand Up @@ -219,7 +223,8 @@ extension UIViewController {
/// - handler: The OK or Generate button handler.
func presentKeyDialog(title: String?, message: String?, key: Data? = nil,
handler: ((Data) -> Void)? = nil) {
DispatchQueue.main.async {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
var alert: UIAlertController? = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert!.addTextField { textField in
textField.text = key?.hex ?? Data.random128BitKey().hex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ private extension AddGroupViewController {
}
presentTextAlert(title: "Group address", message: "Hexadecimal value in range\nC000 - FEFF.",
text: address?.hex, placeHolder: "Address", type: .groupAddressRequired,
option: action, cancelHandler: nil) { text in
self.address = MeshAddress(hex: text)
option: action, cancelHandler: nil) { [weak self] text in
self?.address = MeshAddress(hex: text)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ private extension SceneServerGroupCell {
}
let alert = UIAlertController(title: "Select scene", message: nil, preferredStyle: .actionSheet)
scenes.forEach { scene in
alert.addAction(UIAlertAction(title: scene.name, style: .default) { _ in
self.sendSceneRecall(scene.number)
alert.addAction(UIAlertAction(title: scene.name, style: .default) { [weak self] _ in
self?.sendSceneRecall(scene.number)
})
}
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ private extension SceneSetupServerGroupCell {
}
let alert = UIAlertController(title: "Select scene", message: nil, preferredStyle: .actionSheet)
network.scenes.forEach { scene in
alert.addAction(UIAlertAction(title: scene.name, style: .default) { _ in
self.sendSceneStore(scene.number)
alert.addAction(UIAlertAction(title: scene.name, style: .default) { [weak self] _ in
self?.sendSceneStore(scene.number)
})
}
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ private extension ConfigurationViewController {
let alert = UIAlertController(title: "Reset Node",
message: "Resetting the node will change its state back to unprovisioned state and remove it from the local database.",
preferredStyle: .actionSheet)
let resetAction = UIAlertAction(title: "Reset", style: .destructive) { _ in self.resetNode() }
let resetAction = UIAlertAction(title: "Reset", style: .destructive) { [weak self] _ in self?.resetNode() }
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
alert.addAction(resetAction)
alert.addAction(cancelAction)
Expand All @@ -390,7 +390,7 @@ private extension ConfigurationViewController {
let alert = UIAlertController(title: "Remove Node",
message: "The node will only be removed from the local database. It will still be able to send and receive messages from the network. Remove the node only if the device is no longer available.",
preferredStyle: .actionSheet)
let resetAction = UIAlertAction(title: "Remove", style: .destructive) { _ in self.removeNode() }
let resetAction = UIAlertAction(title: "Remove", style: .destructive) { [weak self] _ in self?.removeNode() }
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
alert.addAction(resetAction)
alert.addAction(cancelAction)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ private extension NodeScenesViewController {
return false
}
guard isSceneClientReady else {
let action = UIAlertAction(title: "Fix", style: .default) { [unowned self] action in
self.fixClient()
let action = UIAlertAction(title: "Fix", style: .default) { [weak self] action in
self?.fixClient()
}
presentAlert(title: "Client not ready",
message: "Scene Client model on local node is not bound to any of the "
Expand All @@ -390,8 +390,8 @@ private extension NodeScenesViewController {
return false
}
guard isSceneClientReadyToSetup else {
let action = UIAlertAction(title: "Fix", style: .default) { [unowned self] action in
self.fixClient()
let action = UIAlertAction(title: "Fix", style: .default) { [weak self] action in
self?.fixClient()
}
presentAlert(title: "Client not ready",
message: "Scene Client model on local node is not bound to any of the "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,13 @@ private extension SetPublicationViewController {
message: "TTL = Time To Live\n\nTTL limits the number of times a message can be relayed.\nMax value is 127. Message with TTL 0 will not be relayed.",
text: "5", placeHolder: "Default is 5",
type: .ttlRequired,
option: UIAlertAction(title: "Use Node's default", style: .default, handler: { _ in
option: UIAlertAction(title: "Use Node's default", style: .default) { _ in
self.ttl = 0xFF
}),
},
handler: { value in
self.ttl = UInt8(value)!
})
}
)
}

func periodSelected(_ period: Float) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@ extension OobSelector where Self: UIViewController {
}

let alert = UIAlertController(title: "Select OOB Type", message: nil, preferredStyle: .actionSheet)
alert.addAction(UIAlertAction(title: "No OOB", style: .destructive, handler: { _ in
alert.addAction(UIAlertAction(title: "No OOB", style: .destructive) { _ in
callback(.noOob)
}))
})
if capabilities.staticOobType.contains(.staticOobInformationAvailable) {
alert.addAction(UIAlertAction(title: "Static OOB", style: .default, handler: { _ in
alert.addAction(UIAlertAction(title: "Static OOB", style: .default) { _ in
callback(.staticOob)
}))
})
}
if !capabilities.outputOobActions.isEmpty {
alert.addAction(UIAlertAction(title: "Output OOB", style: .default, handler: { _ in
alert.addAction(UIAlertAction(title: "Output OOB", style: .default) { _ in
self.presentOutputOobOptionsDialog(for: provisioningManager, from: item, callback: callback)
}))
})
}
if !capabilities.inputOobActions.isEmpty {
alert.addAction(UIAlertAction(title: "Input OOB", style: .default, handler: { _ in
alert.addAction(UIAlertAction(title: "Input OOB", style: .default) { _ in
self.presentInputOobOptionsDialog(for: provisioningManager, from: item, callback: callback)
}))
})
}
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel))
alert.popoverPresentationController?.barButtonItem = item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ private extension ProvisioningViewController {
/// Presents a dialog to edit or unbind the Provisioner Unicast Address.
func presentUnicastAddressDialog() {
let manager = self.provisioningManager!
let action = UIAlertAction(title: "Automatic", style: .default) { _ in
let action = UIAlertAction(title: "Automatic", style: .default) { [weak self] _ in
guard let self = self else { return }
manager.unicastAddress = manager.suggestedUnicastAddress
self.unicastAddressLabel.text = manager.unicastAddress?.asString() ?? "Automatic"
let deviceSupported = manager.isDeviceSupported == true
Expand All @@ -168,7 +169,8 @@ private extension ProvisioningViewController {
}
presentTextAlert(title: "Unicast address", message: "Hexadecimal value in Provisioner's range.",
text: manager.unicastAddress?.hex, placeHolder: "Address", type: .unicastAddressRequired,
option: action, cancelHandler: nil) { text in
option: action, cancelHandler: nil) { [weak self] text in
guard let self = self else { return }
manager.unicastAddress = Address(text, radix: 16)
self.unicastAddressLabel.text = manager.unicastAddress!.asString()
let deviceSupported = manager.isDeviceSupported == true
Expand All @@ -181,7 +183,8 @@ private extension ProvisioningViewController {
}

func presentStatusDialog(message: String, animated flag: Bool = true, completion: (() -> Void)? = nil) {
DispatchQueue.main.async {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
if let alert = self.alert {
alert.message = message
completion?()
Expand All @@ -197,7 +200,8 @@ private extension ProvisioningViewController {
}

func dismissStatusDialog(completion: (() -> Void)? = nil) {
DispatchQueue.main.async {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
if let alert = self.alert {
alert.dismiss(animated: true, completion: completion)
} else {
Expand All @@ -208,7 +212,8 @@ private extension ProvisioningViewController {
}

func abort() {
DispatchQueue.main.async {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
self.alert?.title = "Aborting"
self.alert?.message = "Cancelling connection..."
self.bearer.close()
Expand Down Expand Up @@ -248,7 +253,8 @@ private extension ProvisioningViewController {
let outputOobNotSupported = capabilities.outputOobActions.isEmpty
let inputOobNotSupported = capabilities.inputOobActions.isEmpty
guard (staticOobNotSupported && outputOobNotSupported && inputOobNotSupported) || authenticationMethod != nil else {
presentOobOptionsDialog(for: provisioningManager, from: provisionButton) { method in
presentOobOptionsDialog(for: provisioningManager, from: provisionButton) { [weak self] method in
guard let self = self else { return }
self.authenticationMethod = method
self.startProvisioning()
}
Expand Down Expand Up @@ -291,7 +297,8 @@ extension ProvisioningViewController: GattBearerDelegate {
}

func bearerDidOpen(_ bearer: Bearer) {
presentStatusDialog(message: "Identifying...") {
presentStatusDialog(message: "Identifying...") { [weak self] in
guard let self = self else { return }
do {
try self.provisioningManager!.identify(andAttractFor: ProvisioningViewController.attentionTimer)
} catch {
Expand All @@ -303,15 +310,17 @@ extension ProvisioningViewController: GattBearerDelegate {

func bearer(_ bearer: Bearer, didClose error: Error?) {
guard case .complete = provisioningManager.state else {
dismissStatusDialog {
self.presentAlert(title: "Status", message: "Device disconnected.")
dismissStatusDialog { [weak self] in
self?.presentAlert(title: "Status", message: "Device disconnected.")
}
return
}
dismissStatusDialog {
self.presentAlert(title: "Success", message: "Provisioning complete.") { _ in
self.presentAlert(title: "Success", message: "Provisioning complete.") { [weak self] _ in
guard let self = self else { return }
if MeshNetworkManager.instance.save() {
self.dismiss(animated: true) {
self.dismiss(animated: true) { [weak self] in
guard let self = self else { return }
let network = MeshNetworkManager.instance.meshNetwork!
if let node = network.node(for: self.unprovisionedDevice) {
self.delegate?.provisionerDidProvisionNewDevice(node)
Expand All @@ -329,7 +338,8 @@ extension ProvisioningViewController: GattBearerDelegate {
extension ProvisioningViewController: ProvisioningDelegate {

func provisioningState(of unprovisionedDevice: UnprovisionedDevice, didChangeTo state: ProvisioningState) {
DispatchQueue.main.async {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
switch state {

case .requestingCapabilities:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class ScannerTableViewController: UITableViewController {
selectedDevice = discoveredPeripherals[indexPath.row].device

alert = UIAlertController(title: "Status", message: "Connecting...", preferredStyle: .alert)
alert!.addAction(UIAlertAction(title: "Cancel", style: .cancel) { [weak self, bearer] action in
alert!.addAction(UIAlertAction(title: "Cancel", style: .cancel) { [weak self] action in
action.isEnabled = false
self?.alert?.title = "Aborting"
self?.alert?.message = "Cancelling connection..."
Expand Down
Loading

0 comments on commit 4d455d3

Please sign in to comment.